diff options
Diffstat (limited to 'ctrl/libhicnctrl/src')
-rw-r--r-- | ctrl/libhicnctrl/src/api.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/ctrl/libhicnctrl/src/api.c b/ctrl/libhicnctrl/src/api.c index b836ef800..23a314c0c 100644 --- a/ctrl/libhicnctrl/src/api.c +++ b/ctrl/libhicnctrl/src/api.c @@ -26,6 +26,12 @@ #include <sys/socket.h> // socket #include <unistd.h> // close, fcntl #include <fcntl.h> // fcntl +#include <sys/types.h> // getpid +#include <unistd.h> // getpid +#ifdef __linux__ +#include <sys/syscall.h> +#define gettid() syscall(SYS_gettid) +#endif /* __linux__ */ #include <hicn/ctrl/api.h> #include <hicn/ctrl/commands.h> @@ -435,7 +441,11 @@ hc_sock_parse_url(const char * url, struct sockaddr * sa) /* FIXME URL parsing is currently not implemented */ assert(!url); - srand(time(NULL)); +#ifdef __linux__ + srand(time(NULL) ^ getpid() ^ gettid()); +#else + srand(time(NULL) ^ getpid()); +#endif /* __linux__ */ /* * A temporary solution is to inspect the sa_family fields of the passed in @@ -757,9 +767,8 @@ hc_sock_callback(hc_sock_t * s, hc_data_t ** pdata) for (;;) { int n = hc_sock_recv(s); - if (n == 0) { + if (n == 0) goto ERR_EOF; - } if (n < 0) { switch(errno) { case ECONNRESET: @@ -858,7 +867,7 @@ hc_execute_command(hc_sock_t * s, hc_msg_t * msg, size_t msg_len, } int seq = hc_sock_get_next_seq(s); - + /* Create state used to process the request */ hc_sock_request_t * request = NULL; request = hc_sock_request_create(seq, data, params->parse); @@ -887,8 +896,11 @@ hc_execute_command(hc_sock_t * s, hc_msg_t * msg, size_t msg_len, * several times before success... shall we alternate between blocking * and non-blocking mode ? */ - if (hc_sock_recv(s) < 0) - continue; //break; + int n = hc_sock_recv(s); + if (n == 0) + goto ERR_EOF; + if (n < 0) + break; int rc = hc_sock_process(s, pdata); switch(rc) { case 0: @@ -906,7 +918,10 @@ hc_execute_command(hc_sock_t * s, hc_msg_t * msg, size_t msg_len, } } +ERR_EOF: ret = data->ret; + if (!data->complete) + return -1; if (!pdata) hc_data_free(data); |