1
0
mirror of https://github.com/haiwen/libsearpc.git synced 2025-06-21 11:21:55 +00:00

Merge pull request #44 from haiwen/fix_memory_leak

Fix memory leak.
This commit is contained in:
Jiaqiang Xu 2019-09-25 12:04:37 +08:00 committed by GitHub
commit 317877f996
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 6 deletions

View File

@ -158,7 +158,6 @@ failed:
}
typedef struct {
SearpcNamedPipeServer *server;
SearpcNamedPipe connfd;
} ServerHandlerData;
@ -169,7 +168,6 @@ static void* named_pipe_listen(void *arg)
while (1) {
int connfd = accept (server->pipe_fd, NULL, 0);
ServerHandlerData *data = g_malloc(sizeof(ServerHandlerData));
data->server = server;
data->connfd = connfd;
g_thread_pool_push (server->named_pipe_server_thread_pool, data, NULL);
}
@ -209,7 +207,6 @@ static void* named_pipe_listen(void *arg)
/* g_debug ("Accepted a named pipe client\n"); */
ServerHandlerData *data = g_malloc(sizeof(ServerHandlerData));
data->server = server;
data->connfd = connfd;
g_thread_pool_push (server->named_pipe_server_thread_pool, data, NULL);
}
@ -220,7 +217,6 @@ static void* named_pipe_listen(void *arg)
static void named_pipe_client_handler(void *data, void *user_data)
{
ServerHandlerData *handler_data = data;
// SearpcNamedPipeServer *server = data->server;
SearpcNamedPipe connfd = handler_data->connfd;
guint32 len;
@ -248,7 +244,6 @@ static void named_pipe_client_handler(void *data, void *user_data)
if (pipe_read_n(connfd, buf, len) < 0 || len == 0) {
g_warning("failed to read rpc request: %s\n", strerror(errno));
g_free (buf);
break;
}
@ -284,6 +279,8 @@ static void named_pipe_client_handler(void *data, void *user_data)
DisconnectNamedPipe(connfd);
CloseHandle(connfd);
#endif // !defined(WIN32)
g_free (data);
g_free (buf);
}

View File

@ -30,7 +30,6 @@ typedef int SearpcNamedPipe;
struct _SearpcNamedPipeServer {
char path[4096];
pthread_t listener_thread;
GList *handlers;
SearpcNamedPipe pipe_fd;
GThreadPool *named_pipe_server_thread_pool;
};