From 9f91a5f8412b56a0e8cb71e05329c5f7983e2a9f Mon Sep 17 00:00:00 2001 From: Jan-Philipp Litza Date: Thu, 9 Jul 2015 20:18:11 +0200 Subject: [PATCH] gluon-neighbour-info: Support sub-second timeout --- .../gluon-neighbour-info/src/gluon-neighbour-info.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package/gluon-neighbour-info/src/gluon-neighbour-info.c b/package/gluon-neighbour-info/src/gluon-neighbour-info.c index 192b736e..46e6324d 100644 --- a/package/gluon-neighbour-info/src/gluon-neighbour-info.c +++ b/package/gluon-neighbour-info/src/gluon-neighbour-info.c @@ -78,7 +78,7 @@ ssize_t recvtimeout(int socket, void *buffer, size_t length, int flags, struct t return ret; } -int request(const int sock, const struct sockaddr_in6 *client_addr, const char *request, bool sse, int timeout) { +int request(const int sock, const struct sockaddr_in6 *client_addr, const char *request, bool sse, double timeout) { ssize_t ret; char buffer[8192]; @@ -90,8 +90,8 @@ int request(const int sock, const struct sockaddr_in6 *client_addr, const char * } struct timeval tv_timeout, tv_offset; - tv_timeout.tv_sec = timeout; - tv_timeout.tv_usec = 0; + tv_timeout.tv_sec = (int) timeout; + tv_timeout.tv_usec = ((int) (timeout * 1000000)) % 1000000; getclock(&tv_offset); @@ -137,7 +137,7 @@ int main(int argc, char **argv) { int port_set = 0; int destination_set = 0; - int timeout = 3; + double timeout = 3.0; bool sse = false; int c; @@ -163,7 +163,7 @@ int main(int argc, char **argv) { request_string = optarg; break; case 't': - timeout = atoi(optarg); + timeout = atof(optarg); break; case 's': sse = true;