Skip to content

Commit

Permalink
Revert "Fix /stop command issued when hhvm can't bind port"
Browse files Browse the repository at this point in the history
This reverts D944849

Reviewed By: @bertmaher

Differential Revision: D1047984
  • Loading branch information
paroski authored and sgolemon committed Nov 8, 2013
1 parent 6b1aaf3 commit 0641b1d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 51 deletions.
2 changes: 0 additions & 2 deletions hphp/runtime/server/fastcgi/fastcgi-server.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ class FastCGIServer : public Server,
}
virtual void start() override;
virtual void waitForEnd() override;
virtual void waitForJobs() override { always_assert(false); }
virtual void closePort() override { always_assert(false); }
virtual void stop() override;
virtual int getActiveWorker() override {
return m_dispatcher.getActiveWorker();
Expand Down
32 changes: 7 additions & 25 deletions hphp/runtime/server/http-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,15 +284,14 @@ void HttpServer::run() {
if (m_stopReason) {
Logger::Warning("Server stopping with reason: %s\n", m_stopReason);
}
removePid();
Logger::Info("page server stopped");
}

onServerShutdown(); // dangling server already started here
time_t t0 = time(0);
if (RuntimeOption::ServerPort) {
m_pageServer->waitForJobs();
removePid();
m_pageServer->closePort();
m_pageServer->stop();
}
time_t t1 = time(0);
if (!m_danglings.empty() && RuntimeOption::ServerDanglingWait > 0) {
Expand Down Expand Up @@ -472,31 +471,14 @@ bool HttpServer::startServer(bool pageServer) {

HttpClient http;
string url = "http://";
if (!RuntimeOption::ServerIP.empty()) {
url += RuntimeOption::ServerIP;
} else {
url += "localhost";
}
url += RuntimeOption::ServerIP;
url += ":";
url += lexical_cast<string>(RuntimeOption::AdminServerPort);
url += "/stop";
if (!RuntimeOption::AdminPasswords.empty()) {
for (auto it = RuntimeOption::AdminPasswords.begin();
it != RuntimeOption::AdminPasswords.end();
++it) {
string passUrl = url + "?auth=" + *it;
StringBuffer response;
http.get(passUrl.c_str(), response);
sleep(1);
}
} else {
if (!RuntimeOption::AdminPassword.empty()) {
url += "?auth=" + RuntimeOption::AdminPassword;
}
StringBuffer response;
http.get(url.c_str(), response);
sleep(1);
}
StringBuffer response;
http.get(url.c_str(), response);

sleep(1);
}
}

Expand Down
15 changes: 3 additions & 12 deletions hphp/runtime/server/libevent-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,8 @@ int LibEventServer::getLibEventConnectionCount() {
void LibEventServer::start() {
if (getStatus() == RunStatus::RUNNING) return;

if (m_server != nullptr) {
if (getAcceptSocket() != 0) {
throw FailedToListenException(m_address, m_port);
}
if (getAcceptSocket() != 0) {
throw FailedToListenException(m_address, m_port);
}

if (m_server_ssl != nullptr) {
Expand Down Expand Up @@ -316,7 +314,7 @@ void LibEventServer::dispatch() {
}
}

void LibEventServer::waitForJobs() {
void LibEventServer::stop() {
Lock lock(m_mutex);
if (getStatus() != RunStatus::RUNNING || m_server == nullptr) return;

Expand Down Expand Up @@ -365,18 +363,11 @@ void LibEventServer::waitForJobs() {
// an error occured but we're in shutdown already, so ignore
}
m_dispatcherThread.waitForEnd();
}

void LibEventServer::closePort() {
evhttp_free(m_server);
m_server = nullptr;
}

void LibEventServer::stop() {
waitForJobs();
closePort();
}

///////////////////////////////////////////////////////////////////////////////
// SSL handling

Expand Down
2 changes: 0 additions & 2 deletions hphp/runtime/server/libevent-server.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ class LibEventServer : public Server, public TakeoverAgent::Callback {
// implementing Server
virtual void start();
virtual void waitForEnd();
virtual void waitForJobs();
virtual void closePort();
virtual void stop();
virtual int getActiveWorker() {
return m_dispatcher.getActiveWorker();
Expand Down
10 changes: 0 additions & 10 deletions hphp/runtime/server/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,16 +195,6 @@ class Server {
*/
virtual void waitForEnd() = 0;

/*
* Stop accepting new connections and finish ongoing requests.
*/
virtual void waitForJobs() = 0;

/*
* Close the port this server is listening on.
*/
virtual void closePort() = 0;

/**
* Gracefully stop this web server. We will stop accepting new connections
* and finish ongoing requests without being interrupted in the middle of
Expand Down

0 comments on commit 0641b1d

Please sign in to comment.