Reputation: 668
I start a TNonblockingServer from one thread:
void *start_server(void *) {
server->serve();
return NULL;
}
pthread_create(&daemon_thread, NULL, start_server, NULL);
, and call server->stop()
from the main thread, then try to use pthread_join
to wait the background thread exiting gracefully. However the main thread hangs at the pthread_join
call.
How could I shut down the thrift server gracefully?
Upvotes: 0
Views: 2539
Reputation: 5999
Sorry for the late response
You would just need to stop the underlying libevent
For example, a slightly delayed stop:
tv.tv_usec = 500000;
tv.tv_sec = 0;
event_base_loopexit(myTNonBlockSvr->getEventBase(), &tv);
Upvotes: 1
Reputation: 21073
AFAICT TNonblockingServer::stop()
is not implemented. The TNonblockingServer
destructor does attempt a clean shutdown though, so you might be able to delete server and have the server shutdown.
This is a complete hack though, and ideally stop()
would be properly implemented.
Upvotes: 0