diff options
author | Jesse Hall <jessehall@google.com> | 2012-07-11 16:25:37 -0700 |
---|---|---|
committer | Jesse Hall <jessehall@google.com> | 2012-07-11 16:45:58 -0700 |
commit | dca7f2a6ac56567850e0e03a063e1739e43c5ce2 (patch) | |
tree | db0b5bd48d23a9bd1e03c23f1995802222516775 /emulator/opengl/shared/OpenglCodecCommon/Win32PipeStream.cpp | |
parent | 310777dae93bc4e402ec8a807ce3151271d1038b (diff) | |
download | sdk-dca7f2a6ac56567850e0e03a063e1739e43c5ce2.zip sdk-dca7f2a6ac56567850e0e03a063e1739e43c5ce2.tar.gz sdk-dca7f2a6ac56567850e0e03a063e1739e43c5ce2.tar.bz2 |
Use a per-process server address for the GLES server
Previously we used a hardcoded address (tcp port, unix pipe path,
etc.) for the OpenGLRender system. Multiple emulators would all try to
listen on the same address, with the system non-deterministically (?)
choosing which one accepted each new connection. This resulted in
frames going to the wrong emulator window, one emulator shutting down
another's OpenGL system, etc.
Now the OpenGLRender server requests an unused tcp port or derives a
path from the pid, and reports the address back to the emulator client
to use for future connections from the guest.
Change-Id: I6af2eac0c7f27670a3b6595772eebc7aa2b24688
Diffstat (limited to 'emulator/opengl/shared/OpenglCodecCommon/Win32PipeStream.cpp')
-rw-r--r-- | emulator/opengl/shared/OpenglCodecCommon/Win32PipeStream.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/emulator/opengl/shared/OpenglCodecCommon/Win32PipeStream.cpp b/emulator/opengl/shared/OpenglCodecCommon/Win32PipeStream.cpp index e1a0b9b..76907a0 100644 --- a/emulator/opengl/shared/OpenglCodecCommon/Win32PipeStream.cpp +++ b/emulator/opengl/shared/OpenglCodecCommon/Win32PipeStream.cpp @@ -73,10 +73,10 @@ make_pipe_name(char *path, size_t pathlen, int port_number) * Also, connect() must create a pipe handle with CreateFile() and * wait for a server instance with WaitNamedPipe() */ -int Win32PipeStream::listen(unsigned short port) +int Win32PipeStream::listen(char addrstr[MAX_ADDRSTR_LEN]) { - // just save the port number for accept() - m_port = port; + m_port = GetCurrentProcessId(); + make_pipe_name(addrstr, MAX_ADDRSTR_LEN, m_port); return 0; } @@ -120,20 +120,17 @@ SocketStream * Win32PipeStream::accept() return clientStream; } -int Win32PipeStream::connect(unsigned short port) +int Win32PipeStream::connect(const char* addr) { - char path[NAMED_PIPE_MAX+1]; HANDLE pipe; int tries = 10; - make_pipe_name(path, sizeof(path), port); - /* We're going to loop in order to wait for the pipe server to * be setup properly. */ for (; tries > 0; tries--) { pipe = ::CreateFile( - path, // pipe name + addr, // pipe name GENERIC_READ | GENERIC_WRITE, // read & write 0, // no sharing NULL, // default security attrs @@ -161,7 +158,7 @@ int Win32PipeStream::connect(unsigned short port) } /* Wait for 5 seconds */ - if ( !WaitNamedPipe(path, 5000) ) { + if ( !WaitNamedPipe(addr, 5000) ) { ERR("%s: WaitNamedPipe failed: %d\n", __FUNCTION__, (int)GetLastError()); errno = EINVAL; return -1; |