* Change to main server loop. All threads block on accept() instead of using a mutex...
authorArt Cancro <ajc@citadel.org>
Fri, 21 May 2010 14:53:58 +0000 (14:53 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 21 May 2010 14:53:58 +0000 (14:53 +0000)
webcit/sysdep.c
webcit/tcp_sockets.c
webcit/webcit.h

index 00fafbbed19a4d4510584cff1749ab76df4963b2..afaef1a1db4052834ae3e952cca8534ececb9ce1 100644 (file)
@@ -143,18 +143,11 @@ void worker_entry(void)
        int ssock;
        int i = 0;
        int fail_this_transaction = 0;
-       int ret;
-       struct timeval tv;
-       fd_set readset, tempset;
        ParsedHttpHdrs Hdr;
 
        memset(&Hdr, 0, sizeof(ParsedHttpHdrs));
        Hdr.HR.eReqType = eGET;
        http_new_modules(&Hdr); 
-       tv.tv_sec = 0;
-       tv.tv_usec = 10000;
-       FD_ZERO(&readset);
-       FD_SET(msock, &readset);
 
        do {
                /* Only one thread can accept at a time */
@@ -162,25 +155,13 @@ void worker_entry(void)
                ssock = -1; 
                errno = EAGAIN;
                do {
-                       ret = -1; /* just one at once should select... */
-                       begin_critical_section(S_SELECT);
-
-                       FD_ZERO(&tempset);
-                       if (msock > 0) FD_SET(msock, &tempset);
-                       tv.tv_sec = 0;
-                       tv.tv_usec = 10000;
-                       if (msock > 0)  ret = select(msock+1, &tempset, NULL, NULL,  &tv);
-                       end_critical_section(S_SELECT);
-                       if ((ret < 0) && (errno != EINTR) && (errno != EAGAIN))
-                       {/* EINTR and EAGAIN are thrown but not of interest. */
-                               lprintf(2, "accept() failed:%d %s\n",
-                                       errno, strerror(errno));
-                       }
-                       else if ((ret > 0) && (msock > 0) && FD_ISSET(msock, &tempset))
-                       {/* Successfully selected, and still not shutting down? Accept! */
-                               ssock = accept(msock, NULL, 0);
-                       }
-                       
+                       ssock = accept(msock, NULL, 0);
+                       lprintf(9, "\033[3%dmthread %u woke up, accept() returned %d %s\033[0m\n",
+                               ((pthread_self() % 6) + 1),
+                               pthread_self(),
+                               ssock,
+                               ((ssock >= 0) ? "" : strerror(errno))
+                       );
                } while ((msock > 0) && (ssock < 0)  && (time_to_die == 0));
 
                if ((msock == -1)||(time_to_die))
index 1fef4173775eda9565c384cf86abb1331f2f31de..b4197e5d925d7dfc5e9d70ea563e6e3e97224936 100644 (file)
@@ -653,13 +653,6 @@ int ig_tcp_server(char *ip_addr, int port_number, int queue_len)
        i = 1;
        setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &i, sizeof(i));
 
-       #ifndef __APPLE__
-       fcntl(s, F_SETFL, O_NONBLOCK); /* maide: this statement is incorrect
-                                         there should be a preceding F_GETFL
-                                         and a bitwise OR with the previous
-                                         fd flags */
-       #endif
-       
        if (bind(s, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
                lprintf(1, "Can't bind: %s\n", strerror(errno));
                return (-WC_EXIT_BIND);
index 91feac91bdd2fa5ca9baf0965ed8bd297101861e..b8f0d4e1238ee256bbad3c8bbd350bff1bff3761 100644 (file)
@@ -587,7 +587,6 @@ void RegisterHeaderHandler(const char *Name, long Len, Header_Evaluator F);
 
 
 enum {
-       S_SELECT,
        S_SHUTDOWN,
        MAX_SEMAPHORES
 };