eBay / NuRaft

C++ implementation of Raft core logic as a replication library
Apache License 2.0
1.02k stars 240 forks source link

Use pthread_exit to terminate raft service. #536

Closed szmyd closed 2 months ago

szmyd commented 2 months ago

Allow the process to handle termination of raft service rather than force process wide exit()

Addresses #535

szmyd commented 2 months ago

I dunno if this should have a compile/runtime condition around it similar to:

#ifdef USE_PTHREAD_EXIT
pthread_exit(nullptr);
#else 
exit(-1)
#endif

to avoid behavior change for those relying on this?

greensky00 commented 2 months ago

Does it work correctly on Mac? I believe it doesn't work at least on Windows. We should write a helper function that works differently according to compiler flag, as you mentioned.

szmyd commented 2 months ago

Does it work correctly on Mac? I believe it doesn't work at least on Windows. We should write a helper function that works differently according to compiler flag, as you mentioned.

It definitely doesn't work on Windows; but should on Mac...Mac has pthread_exit(3). I guess the question is, if it's compile time determined what should be the default? exit()?