From e6c2d4c9c6b8b12bbcf7bc8bd494b3ba56133e1f Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Fri, 23 Feb 2024 09:29:47 +0100 Subject: lib: Revise app flow allocation This revises the application flow allocator to use the flow_info struct/message between the components. Revises the messaging to move the use protocol buffers to its own source (serdes-irm). Adds a timeout to the IRMd flow allocator to make sure flow allocations don't hang forever (this was previously taken care of by the sanitize thread). Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/lib/sockets.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'src/lib/sockets.c') diff --git a/src/lib/sockets.c b/src/lib/sockets.c index 9c5b7a51..13219db0 100644 --- a/src/lib/sockets.c +++ b/src/lib/sockets.c @@ -21,6 +21,7 @@ */ #include +#include #include #include @@ -29,7 +30,6 @@ #include #include #include -#include #include /* Apple doesn't support SEQPACKET. */ @@ -118,7 +118,8 @@ irm_msg_t * send_recv_irm_msg(irm_msg_t * msg) pthread_cleanup_push(__cleanup_close_ptr, &sockfd); - if (write(sockfd, buf, len) != -1) + len = write(sockfd, buf, len); + if (len >= 0) len = read(sockfd, buf, SOCK_BUF_SIZE); pthread_cleanup_pop(true); @@ -131,6 +132,28 @@ irm_msg_t * send_recv_irm_msg(irm_msg_t * msg) return NULL; } +int send_recv_msg(buffer_t * msg) +{ + int sockfd; + ssize_t len = 0; + + sockfd = client_socket_open(IRM_SOCK_PATH); + if (sockfd < 0) + return -1; + + pthread_cleanup_push(__cleanup_close_ptr, &sockfd); + + len = write(sockfd, msg->data, msg->len); + if (len >= 0) + len = read(sockfd, msg->data, SOCK_BUF_SIZE); + + pthread_cleanup_pop(true); + + msg->len = (size_t) len; + + return len < 0 ? -1 : 0; +} + char * ipcp_sock_path(pid_t pid) { char * full_name = NULL; -- cgit v1.2.3