necouchman commented on code in PR #415:
URL: https://github.com/apache/guacamole-server/pull/415#discussion_r1145566747


##########
src/protocols/telnet/telnet.c:
##########
@@ -424,9 +424,25 @@ static telnet_t* __guac_telnet_create_session(guac_client* 
client) {
                 NI_NUMERICHOST | NI_NUMERICSERV)))
             guac_client_log(client, GUAC_LOG_DEBUG, "Unable to resolve host: 
%s", gai_strerror(retval));
 
-        /* Connect */
-        if (connect(fd, current_address->ai_addr,
-                        current_address->ai_addrlen) == 0) {
+        fd_set fdset;
+        FD_ZERO(&fdset);
+        FD_SET(fd, &fdset);
+
+        struct timeval timeout_tv;
+        timeout_tv.tv_sec = settings->timeout;
+        timeout_tv.tv_usec = 0;
+
+        connect(fd, current_address->ai_addr, current_address->ai_addrlen);

Review Comment:
   I'll have to re-locate the sources I was using when I was researching how to 
do this, but my recollection is that adding the `fd` to `fd_set` before calling 
`connect()` essentially makes that into an asynchronous call, and the `fd_set` 
is then monitored for activity via the `select()` call, including handling the 
timeout.
   
   I suppose it may still be worthwhile to check the return value of 
`connect()` just to make that something unexpected doesn't occur, so I should 
probably put that back in there.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to