timeval.tv_usec shouldn't be bigger than 10^6, as then it overlaps
.tv_sec.
The fix is to normalize the fields regarding their resolutions.
Fixes: 7824c18d65ab ("libteamdctl: increase usock timeout to 5secs")
Reported-by: Vitezslav Humpa <vhumpa(a)redhat.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner(a)gmail.com>
---
libteamdctl/cli_usock.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/libteamdctl/cli_usock.c b/libteamdctl/cli_usock.c
index 0136d6909ea620584b6ee9f42917481f642f7761..0dc97ae53f89931a7854a5218d9f6cbdd9e84495
100644
--- a/libteamdctl/cli_usock.c
+++ b/libteamdctl/cli_usock.c
@@ -79,7 +79,8 @@ static int cli_usock_send(int sock, char *msg)
return 0;
}
-#define WAIT_USEC (TEAMDCTL_REPLY_TIMEOUT * 1000)
+#define WAIT_SEC (TEAMDCTL_REPLY_TIMEOUT / 1000)
+#define WAIT_USEC (TEAMDCTL_REPLY_TIMEOUT % 1000 * 1000)
static int cli_usock_wait_recv(int sock)
{
@@ -88,7 +89,7 @@ static int cli_usock_wait_recv(int sock)
int ret;
struct timeval tv;
- tv.tv_sec = 0;
+ tv.tv_sec = WAIT_SEC;
tv.tv_usec = WAIT_USEC;
FD_ZERO(&rfds);
FD_SET(sock, &rfds);
--
2.4.3