summaryrefslogtreecommitdiff
path: root/src/local.c
diff options
context:
space:
mode:
authorAlex Harpin <development@landsofshadow.co.uk>2015-11-26 22:10:55 +0000
committerAlex Harpin <development@landsofshadow.co.uk>2015-11-26 22:10:55 +0000
commit71f0da9318b926578ed44818f4b2709a821980ae (patch)
tree86c9f489859ccfdacdb1860fa6d3e6cc869c11d6 /src/local.c
parentfc3a760c5e481a8302d166f7e7f758f027545f33 (diff)
parent5df0941f73bffabd775d1c14e62295cfe46956eb (diff)
downloadconntrack-tools-71f0da9318b926578ed44818f4b2709a821980ae.tar.gz
conntrack-tools-71f0da9318b926578ed44818f4b2709a821980ae.zip
Merge tag 'conntrack-tools-1.4.3' into lithium
conntrack-tools 1.4.3 release
Diffstat (limited to 'src/local.c')
-rw-r--r--src/local.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/local.c b/src/local.c
index feff608..3395b4c 100644
--- a/src/local.c
+++ b/src/local.c
@@ -77,7 +77,7 @@ int do_local_server_step(struct local_server *server, void *data,
int rfd;
struct sockaddr_un local;
socklen_t sin_size = sizeof(struct sockaddr_un);
-
+
rfd = accept(server->fd, (struct sockaddr *) &local, &sin_size);
if (rfd == -1)
return -1;
@@ -117,11 +117,10 @@ void local_client_destroy(int fd)
int do_local_client_step(int fd, void (*process)(char *buf))
{
- int numbytes;
char buf[1024];
memset(buf, 0, sizeof(buf));
- while ((numbytes = recv(fd, buf, sizeof(buf)-1, 0)) > 0) {
+ while (recv(fd, buf, sizeof(buf)-1, 0) > 0) {
buf[sizeof(buf)-1] = '\0';
if (process)
process(buf);
@@ -148,11 +147,14 @@ int do_local_request(int request,
ret = send(fd, &request, sizeof(int), 0);
if (ret == -1)
- return -1;
+ goto err1;
do_local_client_step(fd, step);
local_client_destroy(fd);
-
+
return 0;
+err1:
+ local_client_destroy(fd);
+ return -1;
}