fb_shutdown_callback has no effect when used in a multithreaded environment ---------------------------------------------------------------------------
Key: CORE-3635 URL: http://tracker.firebirdsql.org/browse/CORE-3635 Project: Firebird Core Issue Type: Bug Components: API / Client Library Affects Versions: 2.5.0 Environment: Linux Debian-Squeeze libfbclient2 Build 26054 Firebird SS 2.5.0.26054 Application written in C++ is using omniORB for IPC and the POSIX threading from omniORB Reporter: Eberhard Leba The Application using the fbclient library has its own shutdown handler running in a dedicated thread. Database queries and modifications are done in a separate worker thread that serializes the requests. Starting using FB version 2.5.0 the application process has been terminated ungracefully by the worker thread * loosing connection to the database (Cursor failed arg:, SQLCODE:-902) * loosing IPC because omniorb DTOR is called. After the problem was analyzed a fb_shutdown_callback was implemented, as shown in the example, but the database connection still gets lost when the value 1 is returned. int FB_shutdownCallbackHandler(const int reason, const int mask, void* arg){ log_FUNC_m(FB_shutdownCallback); int rc = 0; // Do not terminate on SIGTERM or SIGINT if (mask == fb_shut_preproviders && reason == fb_shutrsn_signal) { rc = 1; // do not shut down g_ShutdownPermitted.Wait(); } log_DBG_m(dbg_LOW, "***** Reason = " << reason << " mask = 0x" << hex << mask << " ***** returning " << rc ); return rc; } As a workaround FB_shutdownCallbackHandler is now blocked on a semaphore (the g_ShutdownPermitted.Wait stuff) until the application shutdown did its work. In this case the app shuts down as designed, but there is still a race condition left. BTW: I have also tried to return 0 from the handler in case of mask == fb_shut_preproviders && reason == fb_shutrsn_signal but it does not seem to have an effect either. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://tracker.firebirdsql.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2d-oct Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel