68b9f4ff4154fcade7c63ae6f7629a5ef721d5a6 galt Sat Dec 7 21:25:11 2024 -0800 putting back the way it was just in case. diff --git src/lib/https.c src/lib/https.c index aa2814e..fe8d324 100644 --- src/lib/https.c +++ src/lib/https.c @@ -140,46 +140,48 @@ fd_set readfds; fd_set writefds; struct timeval tv; int err; char sbuf[32768]; // socket buffer sv[1] to user char bbuf[32768]; // bio buffer int srd = 0; int swt = 0; int brd = 0; int bwt = 0; int fd = 0; +while (1) + { + // Do not move this to before the loop. /* Get underlying file descriptor, needed for select call */ fd = BIO_get_fd(params->sbio, NULL); if (fd == -1) { xerr("BIO doesn't seem to be initialized in https, unable to get descriptor."); goto cleanup; } // The earlier call to BIO_set_nbio() should have turned non-blocking io on already. -if (fcntl(fd, F_SETFL, SOCK_NONBLOCK) == -1) { + if (fcntl(fd, F_SETFL, SOCK_NONBLOCK) == -1) + { xerr("Could not switch to non-blocking.\n"); goto cleanup; } -while (1) - { FD_ZERO(&readfds); FD_ZERO(&writefds); if (brd == 0) FD_SET(fd, &readfds); if (swt < srd) FD_SET(fd, &writefds); if (srd == 0) FD_SET(params->sv[1], &readfds); tv.tv_sec = 90; // timeout 90 seconds needed for slow CGIs respsonse time. tv.tv_usec = 0; err = select(max(fd,params->sv[1]) + 1, &readfds, &writefds, NULL, &tv);