summaryrefslogtreecommitdiff
path: root/src/lib/sockets.c
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@intec.ugent.be>2016-10-07 15:47:32 +0200
committerSander Vrijders <sander.vrijders@intec.ugent.be>2016-10-07 15:47:32 +0200
commit55d5b9157b78d90d4f6a575d253c58fd50ca531f (patch)
tree90d6031870d02b557107b0bc2623a129c4b1d074 /src/lib/sockets.c
parente351576c01e5f705ed21289aa48f23f345d7c7e1 (diff)
parent71f10f5efab37f3df3d909d324cff2e098d21c85 (diff)
downloadouroboros-55d5b9157b78d90d4f6a575d253c58fd50ca531f.tar.gz
ouroboros-55d5b9157b78d90d4f6a575d253c58fd50ca531f.zip
Merged in dstaesse/ouroboros/be-async-dealloc (pull request #257)
lib, dev: Add asynchronous deallocation
Diffstat (limited to 'src/lib/sockets.c')
-rw-r--r--src/lib/sockets.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/lib/sockets.c b/src/lib/sockets.c
index 408e79e7..c8375c22 100644
--- a/src/lib/sockets.c
+++ b/src/lib/sockets.c
@@ -154,6 +154,39 @@ static irm_msg_t * send_recv_irm_msg_timed(irm_msg_t * msg, bool timed)
return recv_msg;
}
+void send_irm_msg(irm_msg_t * msg)
+{
+ int sockfd;
+ buffer_t buf;
+
+ sockfd = client_socket_open(IRM_SOCK_PATH);
+ if (sockfd < 0)
+ return;
+
+ buf.len = irm_msg__get_packed_size(msg);
+ if (buf.len == 0) {
+ close(sockfd);
+ return;
+ }
+
+ buf.data = malloc(buf.len);
+ if (buf.data == NULL) {
+ close(sockfd);
+ return;
+ }
+
+ pthread_cleanup_push(close_ptr, &sockfd);
+ pthread_cleanup_push((void (*)(void *)) free, (void *) buf.data);
+
+ irm_msg__pack(msg, buf.data);
+
+ if (write(sockfd, buf.data, buf.len) < 0)
+ return;
+
+ pthread_cleanup_pop(true);
+ pthread_cleanup_pop(true);
+}
+
irm_msg_t * send_recv_irm_msg(irm_msg_t * msg)
{ return send_recv_irm_msg_timed(msg, true); }