src/ngx_event_connection.cc
// Deserialize ps_event_data's from the pipe as they become available.
// Subsequently do some bookkeeping, cleanup, and error checking to keep
// the mess out of ps_base_fetch_handler.
Deserialize ps_event_data's from the pipe as they become available.
Subsequently do some bookkeeping, cleanup, and error checking to keep
the mess out of ps_base_fetch_handler.
Deserialize ps_event_data ' s from the pipe as they become available . Subsequently do some bookkeeping cleanup and error checking to keep the mess out of ps_base_fetch_handler .
bool NgxEventConnection::ReadAndNotify(ngx_fd_t fd) {
  while (true) {
    ps_event_data data;
    ngx_int_t size = read(fd, static_cast<void*>(&data), sizeof(data));
    if (size == -1) {
      if (errno == EINTR) {
        continue;
      } else if (ngx_errno == EAGAIN || ngx_errno == EWOULDBLOCK) {
        return true;
      }
    }
    if (size <= 0) {
      return false;
    }
    data.connection->event_handler_(data);
    return true;
  }
}
bool NgxEventConnection :: ReadAndNotify ( ngx_fd_t fd ) { while ( true ) { ps_event_data data ; ngx_int_t size = read ( fd , static_cast < void * > ( & data ) , sizeof ( data ) ) ; if ( size == -1 ) { if ( errno == EINTR ) { continue ; } else if ( ngx_errno == EAGAIN || ngx_errno == EWOULDBLOCK ) { return true ; } } if ( size <= 0 ) { return false ; } data . connection -> event_handler_ ( data ) ; return true ; } }
Deserialize ps_event_data's from the pipe as they become available.
Deserialize ps_event_data ' s from the pipe as they become available .
// We read only one ps_event_data at a time for now: // We can end up recursing all the way and end up calling ourselves here. // If that happens in the middle of looping over multiple ps_event_data's we // have obtained with read(), the results from the next read() will make us // process events out of order. Which can give headaches. // Alternatively, we could maintain a queue to make sure we process in // sequence // TODO(oschaaf): should we worry about spinning here?