Arquivos
hhvm/hphp/runtime/server/libevent_server_factory.cpp
T
mwilliams a946a8eb35 Get rid of TimeoutThread(s)
Use timer events instead. A side effect is that we now
support timeout in client mode. We also get much more
accurate timeouts. Previously starting a server with
a timeout of 4s, and GETing an endpoint that just looped,
would timeout somewhere between 3.5(!) and 8 seconds. Now
it times out between 4.0001 and 4.02s.

This will also make fixing pagelet timeouts much easier.
2013-07-24 10:35:43 -07:00

69 linhas
2.6 KiB
C++

/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#include "hphp/runtime/server/libevent_server.h"
#include "hphp/runtime/server/libevent_server_with_fd.h"
#include "hphp/runtime/server/libevent_server_with_takeover.h"
#include <boost/make_shared.hpp>
namespace HPHP {
///////////////////////////////////////////////////////////////////////////////
class LibEventServerFactory : public ServerFactory {
public:
LibEventServerFactory() {}
virtual ServerPtr createServer(const ServerOptions& options);
};
ServerPtr LibEventServerFactory::createServer(const ServerOptions& options) {
if (options.m_serverFD != -1 || options.m_sslFD != -1) {
auto const server = boost::make_shared<LibEventServerWithFd>
(options.m_address, options.m_port, options.m_numThreads);
server->setServerSocketFd(options.m_serverFD);
server->setSSLSocketFd(options.m_sslFD);
return server;
}
if (!options.m_takeoverFilename.empty()) {
auto const server = boost::make_shared<LibEventServerWithTakeover>
(options.m_address, options.m_port, options.m_numThreads);
server->setTransferFilename(options.m_takeoverFilename);
return server;
}
return boost::make_shared<LibEventServer>(options.m_address, options.m_port,
options.m_numThreads);
}
///////////////////////////////////////////////////////////////////////////////
}
extern "C" {
/*
* Automatically register LibEventServerFactory on program start
*/
void register_libevent_server() __attribute__((constructor));
void register_libevent_server() {
auto registry = HPHP::ServerFactoryRegistry::getInstance();
auto factory = boost::make_shared<HPHP::LibEventServerFactory>();
registry->registerFactory("libevent", factory);
}
}