[Date Prev][Date Next] [Chronological] [Thread] [Top]

RE: slapadd hang in bdb_tool_entry_close / ldap_pvt_thread_cond_wait



> The cond_signal calls are all contained within one big mutex_lock.

Sorry, I missed the fact that ldap_pvt_thread_cond_wait() inside bdb_tool_trickle_task() will unlock the bdb_tool_trickle_mutex.

But then, I think the author of the trickle task function has also forgotten this, because later on:

        bdb_tool_trickle_active = 0;
        ldap_pvt_thread_cond_signal( &bdb_tool_trickle_cond_end );
        ldap_pvt_thread_mutex_unlock( &bdb_tool_trickle_mutex );

Why even try to unlock the mutex when the earlier call to ldap_pvt_thread_cond_wait() will have done that already?  Perhaps the intention was for the ldap_pvt_thread_cond_signal() to be called when the mutex was locked?

Actually, that might explain things, because the previous line:

        bdb_tool_trickle_active = 0;

... is being called without holding the mutex, whereas bdb_tool_entry_close() is testing for !bdb_tool_trickle_active after acquiring the mutex.  I think the fix is probably to do another mutex_lock() inside bdb_tool_trickle_task() prior to setting bdb_tool_trickle_active to 0.  Like this:

--- servers/slapd/back-bdb/tools.c.orig 2012-02-29 17:37:09.000000000 +0000
+++ servers/slapd/back-bdb/tools.c      2016-05-27 12:35:31.285728000 +0100
@@ -1283,6 +1283,7 @@
                        break;
                env->memp_trickle( env, 30, &wrote );
        }
+       ldap_pvt_thread_mutex_lock( &bdb_tool_trickle_mutex );
        bdb_tool_trickle_active = 0;
        ldap_pvt_thread_cond_signal( &bdb_tool_trickle_cond_end );
        ldap_pvt_thread_mutex_unlock( &bdb_tool_trickle_mutex );



--------------------------------------------------------------------------------

NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions or views contained herein are not intended to be, and do not constitute, advice within the meaning of Section 975 of the Dodd-Frank Wall Street Reform and Consumer Protection Act. If you have received this communication in error, please destroy all electronic and paper copies; do not disclose, use or act upon the information; and notify the sender immediately. Mistransmission is not intended to waive confidentiality or privilege. Morgan Stanley reserves the right, to the extent permitted under applicable law, to monitor electronic communications. This message is subject to terms available at the following link: http://www.morganstanley.com/disclaimers. If you cannot access these links, please notify us by reply message and we will send the contents to you. By messaging with Morgan Stanley you consent to the foregoing.