Keep FastCGI available during restarts
This commit is contained in:
@@ -206,7 +206,6 @@ FastCGIServer::shutdown()
|
||||
{
|
||||
printf("Closing server socket %i\n", *it);
|
||||
close(*it);
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
for (std::vector<std::string>::iterator it = listen_unlink.begin();
|
||||
@@ -223,7 +222,6 @@ FastCGIServer::shutdown()
|
||||
delete it->second;
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
server_sockets.clear();
|
||||
|
||||
}
|
||||
@@ -264,6 +262,22 @@ FastCGIServer::listen(unsigned tcp_port)
|
||||
return(listen(tcp_port, "0.0.0.0"));
|
||||
}
|
||||
|
||||
int
|
||||
FastCGIServer::adopt_listener(int socket_handle, char type)
|
||||
{
|
||||
int accepting = 0;
|
||||
socklen_t accepting_size = sizeof(accepting);
|
||||
if(socket_handle < 0 || getsockopt(socket_handle, SOL_SOCKET, SO_ACCEPTCONN,
|
||||
&accepting, &accepting_size) != 0 || !accepting)
|
||||
throw std::runtime_error("inherited descriptor is not a listening socket");
|
||||
set_socket_nonblocking(socket_handle);
|
||||
server_sockets.push_back(socket_handle);
|
||||
server_socket_types[socket_handle] = type;
|
||||
printf("(P) adopted #%i inherited %s listener\n", socket_handle,
|
||||
type == 'F' ? "FastCGI" : "server");
|
||||
return(socket_handle);
|
||||
}
|
||||
|
||||
int
|
||||
FastCGIServer::listen(unsigned tcp_port, const std::string& bind_address)
|
||||
{
|
||||
|
||||
@@ -57,6 +57,7 @@ public:
|
||||
int listen_http(unsigned tcp_port, const std::string& bind_address);
|
||||
int listen_cli(const std::string& local_path);
|
||||
int listen(const std::string& local_path);
|
||||
int adopt_listener(int socket_handle, char type = 'F');
|
||||
|
||||
void process(int timeout_ms = -1); // timeout_ms<0 blocks forever
|
||||
void process_forever();
|
||||
|
||||
Reference in New Issue
Block a user