Create the server pipes on the client side and transfer them to the
server on thread creation.
Use a single per-process socket instead of one per thread for
transferring file handles between client and server.
diff --git a/server/process.c b/server/process.c
index 9f4bdc4..39f40e6 100644
--- a/server/process.c
+++ b/server/process.c
@@ -147,6 +147,7 @@
{
struct process *process;
struct thread *thread = NULL;
+ int request_pipe[2];
if (!(process = alloc_object( &process_ops, fd ))) return NULL;
process->next = NULL;
@@ -180,7 +181,14 @@
if (!(process->init_event = create_event( NULL, 0, 1, 0 ))) goto error;
/* create the main thread */
- if (!(thread = create_thread( dup(fd), process ))) goto error;
+ if (pipe( request_pipe ) == -1)
+ {
+ file_set_error();
+ goto error;
+ }
+ send_client_fd( process, request_pipe[1], 0 );
+ close( request_pipe[1] );
+ if (!(thread = create_thread( request_pipe[0], process ))) goto error;
set_select_events( &process->obj, POLLIN ); /* start listening to events */
release_object( process );