742b9a6d0c3106759a3086307cb4184cc4d01a77
galt
  Thu Dec 5 03:05:25 2024 -0800
Minor improvement in efficiency for https.c.

diff --git src/lib/https.c src/lib/https.c
index e1a997c..aa2814e 100644
--- src/lib/https.c
+++ src/lib/https.c
@@ -139,48 +139,47 @@
  * to see if we need to ferry data from one to the other */
 
 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 outside the while 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) {
     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);