Explorar o código

Fix incorrect test of select() return code

Thanks to Thomas Stalder and Torello Querci for the report.
Stéphane Raimbault %!s(int64=13) %!d(string=hai) anos
pai
achega
30054b90c5
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      src/modbus-tcp.c

+ 1 - 1
src/modbus-tcp.c

@@ -253,7 +253,7 @@ static int _connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen,
         FD_ZERO(&wset);
         FD_SET(sockfd, &wset);
         rc = select(sockfd + 1, NULL, &wset, NULL, tv);
-        if (rc < 0) {
+        if (rc <= 0) {
             /* Timeout or fail */
             return -1;
         }