예제 #1
0
void LibEventServer::onRequest(struct evhttp_request *request) {
  // If we are in the process of crashing, we want to reject incoming work.
  // This will prompt the load balancers to choose another server. Using
  // shutdown rather than close has the advantage that it makes fewer changes
  // to the process (eg, it doesn't close the FD so if the FD number were
  // corrupted it would be mostly harmless).
  //
  // Setting accept sock to -1 will leak FDs. But we're crashing anyways.
  if (IsCrashing) {
    if (m_accept_sock != -1) {
      shutdown(m_accept_sock, SHUT_FBLISTEN);
      m_accept_sock = -1;
    }
    if (m_accept_sock_ssl != -1) {
      shutdown(m_accept_sock_ssl, SHUT_FBLISTEN);
      m_accept_sock_ssl = -1;
    }
    return;
  }

  if (RuntimeOption::EnableKeepAlive &&
      RuntimeOption::ConnectionTimeoutSeconds > 0) {
    // before processing request, set the connection timeout
    // it's just writing a variable in libevent
    evhttp_connection_set_timeout(request->evcon,
                                  RuntimeOption::ConnectionTimeoutSeconds);
  }
  if (getStatus() == RunStatus::RUNNING) {
    RequestPriority priority = getRequestPriority(request);
    m_dispatcher.enqueue(LibEventJobPtr(new LibEventJob(request)), priority);
  } else {
    Logger::Error("throwing away one new request while shutting down");
  }
}
예제 #2
0
void LibEventServer::onRequest(struct evhttp_request *request) {
  if (getStatus() == RUNNING) {
    m_dispatcher.enqueue(LibEventJobPtr(new LibEventJob(request)));
  } else {
    Logger::Error("throwing away one new request while shutting down");
  }
}
예제 #3
0
void LibEventServer::onRequest(struct evhttp_request *request) {
  if (RuntimeOption::EnableKeepAlive &&
      RuntimeOption::ConnectionTimeoutSeconds > 0) {
    // before processing request, set the connection timeout
    // it's just writing a variable in libevent
    evhttp_connection_set_timeout(request->evcon,
                                  RuntimeOption::ConnectionTimeoutSeconds);
  }
  if (getStatus() == RunStatus::RUNNING) {
    m_dispatcher.enqueue(LibEventJobPtr(new LibEventJob(request)));
  } else {
    Logger::Error("throwing away one new request while shutting down");
  }
}