diff --git a/lib/Makefile.am b/lib/Makefile.am index e875292..c35610a 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -13,6 +13,6 @@ libsearpc_la_SOURCES = searpc-client.c searpc-server.c searpc-utils.c searpc-nam libsearpc_la_LDFLAGS = -version-info 1:2:0 -no-undefined -libsearpc_la_LIBADD = @GLIB_LIBS@ @JANSSON_LIBS@ +libsearpc_la_LIBADD = @GLIB_LIBS@ @JANSSON_LIBS@ -lpthread dist_bin_SCRIPTS = searpc-codegen.py diff --git a/lib/searpc-named-pipe-transport.c b/lib/searpc-named-pipe-transport.c index b8ec8cf..231ae09 100644 --- a/lib/searpc-named-pipe-transport.c +++ b/lib/searpc-named-pipe-transport.c @@ -1,9 +1,10 @@ +#include +#include #include #include #include #include #include -#include #include #include @@ -189,6 +190,8 @@ static void* named_pipe_client_handler(void *arg) } } + close(connfd); + return NULL; } diff --git a/lib/searpc-named-pipe-transport.h b/lib/searpc-named-pipe-transport.h index 676cdf5..229d222 100644 --- a/lib/searpc-named-pipe-transport.h +++ b/lib/searpc-named-pipe-transport.h @@ -5,6 +5,17 @@ #include #include +// Implementatin of a searpc transport based on named pipe. It uses unix domain +// sockets on linux/osx, and named pipes on windows. +// +// On the server side, there is a thread that listens for incoming connections, +// and it would create a new thread to handle each connection. Thus the RPC +// functions on the server side may be called from different threads, and it's +// the RPC functions implementation's responsibility to guarantee thread safety +// of the RPC calls. (e.g. using mutexes). + +// Server side interface. + typedef struct { char path[4096]; pthread_t listener_thread; @@ -12,6 +23,12 @@ typedef struct { int pipe_fd; } SearpcNamedPipeServer; +SearpcNamedPipeServer* searpc_create_named_pipe_server(const char *path); + +int searpc_named_pipe_server_start(SearpcNamedPipeServer *server); + +// Client side interface. + typedef struct { char path[4096]; int pipe_fd; @@ -19,12 +36,8 @@ typedef struct { SearpcNamedPipeClient* searpc_create_named_pipe_client(const char *path); -SearpcNamedPipeServer* searpc_create_named_pipe_server(const char *path); - SearpcClient * searpc_client_with_named_pipe_transport(SearpcNamedPipeClient *client, const char *service); -int searpc_named_pipe_server_start(SearpcNamedPipeServer *server); - int searpc_named_pipe_client_connect(SearpcNamedPipeClient *client); #endif // SEARPC_NAMED_PIPE_TRANSPORT_H