From 68cdd9df5c923cca591dfe7d22207d7d31ef4928 Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Fri, 23 Oct 2015 15:17:44 -0400 Subject: [PATCH 69/75] Ticket 48311 - nunc-stans: Attempt to release connection that is not acquired Bug Description: ns_connection_post_io_or_closing() was not aquiring the connection in the optimized build, which led to the connection ref count getting out sequence. Fix Description Do not call connection_acquire_nolock() inside a PR_ASSERT call. Also changed other PR_ASSERTs to only be called if DEBUG is set https://fedorahosted.org/389/ticket/48311 Reviewed by: nhosoi(Thanks!) (cherry picked from commit 97946bd212c5094a490d6a3429e0d5763ccd39ce) (cherry picked from commit a8d30b356f312b24132f4ced324a67601b7cfb9b) --- ldap/servers/slapd/daemon.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c index ba73da3..82099bc 100644 --- a/ldap/servers/slapd/daemon.c +++ b/ldap/servers/slapd/daemon.c @@ -1836,7 +1836,11 @@ ns_handle_closure(struct ns_job_t *job) int do_yield = 0; /* this function must be called from the event loop thread */ +#ifdef DEBUG PR_ASSERT(0 == NS_JOB_IS_THREAD(ns_job_get_type(job))); +#else + NS_JOB_IS_THREAD(ns_job_get_type(job)); +#endif PR_Lock(c->c_mutex); connection_release_nolock_ext(c, 1); /* release ref acquired for event framework */ PR_ASSERT(c->c_ns_close_jobs == 1); /* should be exactly 1 active close job - this one */ @@ -1889,7 +1893,11 @@ ns_connection_post_io_or_closing(Connection *conn) /* process event normally - wait for I/O until idletimeout */ tv.tv_sec = conn->c_idletimeout; tv.tv_usec = 0; - PR_ASSERT(0 == connection_acquire_nolock(conn)); /* event framework now has a reference */ +#ifdef DEBUG + PR_ASSERT(0 == connection_acquire_nolock(conn)); +#else + connection_acquire_nolock(conn); /* event framework now has a reference */ +#endif ns_add_io_timeout_job(conn->c_tp, conn->c_prfd, &tv, NS_JOB_READ|NS_JOB_PRESERVE_FD, ns_handle_pr_read_ready, conn, NULL); @@ -1911,7 +1919,11 @@ ns_handle_pr_read_ready(struct ns_job_t *job) Connection *c = (Connection *)ns_job_get_data(job); /* this function must be called from the event loop thread */ +#ifdef DEBUG PR_ASSERT(0 == NS_JOB_IS_THREAD(ns_job_get_type(job))); +#else + NS_JOB_IS_THREAD(ns_job_get_type(job)); +#endif PR_Lock(c->c_mutex); LDAPDebug2Args(LDAP_DEBUG_CONNS, "activity on conn %" NSPRIu64 " for fd=%d\n", -- 2.4.3