Message ID | 1435132311-31452-4-git-send-email-eric@regit.org |
---|---|
State | Not Applicable |
Delegated to: | Pablo Neira |
Headers | show |
Hello, Following live discussion with Pablo, please disregard this patch. Sending a v2 in the following minutes. BR, On Wed, 2015-06-24 at 09:51 +0200, Eric Leblond wrote: > This patch explicitely set timeout for select in mnl_batch_talk. > Timeout used at the second call was the time spend on first select > and this was not looking correct. Instead this patch set a short > timeout as we are supposed to dequeue waiting kernel messages. > > Signed-off-by: Eric Leblond <eric@regit.org> > --- > src/mnl.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/src/mnl.c b/src/mnl.c > index 76a9714..2da1074 100644 > --- a/src/mnl.c > +++ b/src/mnl.c > @@ -246,7 +246,7 @@ int mnl_batch_talk(struct mnl_socket *nl, struct > list_head *err_list) > char rcv_buf[MNL_SOCKET_BUFFER_SIZE]; > fd_set readfds; > struct timeval tv = { > - .tv_sec = 0, > + .tv_sec = 10, > .tv_usec = 0 > }; > > @@ -274,6 +274,8 @@ int mnl_batch_talk(struct mnl_socket *nl, struct > list_head *err_list) > if (ret == -1) > mnl_err_list_node_add(err_list, errno, nlh > ->nlmsg_seq); > > + tv.tv_sec = 0; > + tv.tv_usec = 1000; > ret = select(fd+1, &readfds, NULL, NULL, &tv); > if (ret == -1) > return -1;
diff --git a/src/mnl.c b/src/mnl.c index 76a9714..2da1074 100644 --- a/src/mnl.c +++ b/src/mnl.c @@ -246,7 +246,7 @@ int mnl_batch_talk(struct mnl_socket *nl, struct list_head *err_list) char rcv_buf[MNL_SOCKET_BUFFER_SIZE]; fd_set readfds; struct timeval tv = { - .tv_sec = 0, + .tv_sec = 10, .tv_usec = 0 }; @@ -274,6 +274,8 @@ int mnl_batch_talk(struct mnl_socket *nl, struct list_head *err_list) if (ret == -1) mnl_err_list_node_add(err_list, errno, nlh->nlmsg_seq); + tv.tv_sec = 0; + tv.tv_usec = 1000; ret = select(fd+1, &readfds, NULL, NULL, &tv); if (ret == -1) return -1;
This patch explicitely set timeout for select in mnl_batch_talk. Timeout used at the second call was the time spend on first select and this was not looking correct. Instead this patch set a short timeout as we are supposed to dequeue waiting kernel messages. Signed-off-by: Eric Leblond <eric@regit.org> --- src/mnl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)