summaryrefslogtreecommitdiff
path: root/src/lib/ipcp.c
diff options
context:
space:
mode:
authorSander Vrijders <[email protected]>2016-08-09 19:51:44 +0200
committerSander Vrijders <[email protected]>2016-08-09 19:51:44 +0200
commit3eb6acfd135cdfb82d19a4f445776ea2f13fd4e1 (patch)
tree96fe9ca4332c43b620f64f3f7bb4550c52191a97 /src/lib/ipcp.c
parentfa719e594be2a6d3132706c11166fd4ad4d57e01 (diff)
parent1c67b4cd199f9efed96468a2a2ee69fd755bcf7c (diff)
downloadouroboros-3eb6acfd135cdfb82d19a4f445776ea2f13fd4e1.tar.gz
ouroboros-3eb6acfd135cdfb82d19a4f445776ea2f13fd4e1.zip
Merged in dstaesse/ouroboros/be-bugfixing (pull request #197)
irmd: Close filedescriptor on exit
Diffstat (limited to 'src/lib/ipcp.c')
-rw-r--r--src/lib/ipcp.c22
1 files changed, 4 insertions, 18 deletions
diff --git a/src/lib/ipcp.c b/src/lib/ipcp.c
index 76098691..141db43d 100644
--- a/src/lib/ipcp.c
+++ b/src/lib/ipcp.c
@@ -81,25 +81,11 @@ static ipcp_msg_t * send_recv_ipcp_msg(pid_t api,
ipcp_msg__pack(msg, buf.data);
- if (write(sockfd, buf.data, buf.len) == -1) {
- free(buf.data);
- close(sockfd);
- return NULL;
- }
-
- count = read(sockfd, buf.data, IPCP_MSG_BUF_SIZE);
- if (count <= 0) {
- free(buf.data);
- close(sockfd);
- return NULL;
- }
+ if (write(sockfd, buf.data, buf.len) != -1)
+ count = read(sockfd, buf.data, IPCP_MSG_BUF_SIZE);
- recv_msg = ipcp_msg__unpack(NULL, count, buf.data);
- if (recv_msg == NULL) {
- free(buf.data);
- close(sockfd);
- return NULL;
- }
+ if (count > 0)
+ recv_msg = ipcp_msg__unpack(NULL, count, buf.data);
pthread_cleanup_pop(true);
pthread_cleanup_pop(true);