/[monit]/monit/http/engine.c
ViewVC logotype

Diff of /monit/http/engine.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.30 by martinp, Sun Sep 14 11:27:05 2003 UTC revision 1.31 by martinp, Sun Sep 14 13:14:17 2003 UTC
# Line 74  Line 74 
74  #include <arpa/inet.h>  #include <arpa/inet.h>
75  #endif  #endif
76    
77    #ifdef HAVE_SYS_POLL_H
78    #include <sys/poll.h>
79    #endif
80    
81  #include "http_utils.h"  #include "http_utils.h"
82  #include "engine.h"  #include "engine.h"
83    
# Line 443  static int is_host_allow(char *name) { Line 447  static int is_host_allow(char *name) {
447  /**  /**
448   * Accept connections from Clients and create a RequestWraper object   * Accept connections from Clients and create a RequestWraper object
449   * for each successful accept. If accept fails, return a NULL object   * for each successful accept. If accept fails, return a NULL object
  * which will terminate the server.  
450   */   */
451  static RequestWrapper socket_producer(int server) {  static RequestWrapper socket_producer(int server) {
452    
453    int client;    int client, rv;
454    int len= sizeof(struct sockaddr_in);    int len= sizeof(struct sockaddr_in);
455    struct sockaddr_in in;    struct sockaddr_in in;
456      struct pollfd fds[1];
457    
458      fds[0].fd = server;
459      fds[0].events = POLLIN | POLLPRI;
460    
461    again:    again:
462    errno= 0;    errno= 0;
463    if((client= accept(server, (struct sockaddr*)&in, &len)) < 0) {  
464          if( (rv= poll(fds, 1, 1000)) > 0) {
465      if(stopped) {  
466        log("http server: service stopped\n");      if( (client= accept(server, (struct sockaddr*)&in, &len)) < 0) {
467      } else if(errno == EINTR) {  
468        goto again;        if(stopped) {
469      } else {          log("http server: service stopped\n");
470        log("http server: cannot accept connection -- %s\n", STRERROR);        } else if(errno == EINTR) {
471            goto again;
472          } else {
473            log("http server: cannot accept connection -- %s\n", STRERROR);
474          }
475    
476          return NULL;
477    
478      }      }
479        
480      } else {
481    
482        if(rv < 0)
483          log("http server: cannot poll server socket -- %s\n", STRERROR);
484    
485        /* in the case that timeout or error occured, return NULL to allow
486         * the caller handle various states (such as stopped) which can
487         * occure in the meantime */
488      return NULL;      return NULL;
489        
490    }    }
491    
492    if(set_noblock(client) < 0) {    if(set_noblock(client) < 0) {

Legend:
Removed from v.1.30  
changed lines
  Added in v.1.31

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26