|
From: Narasimha S. <nsh...@us...> - 2012-04-04 17:54:14
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "SFCB - Small Footprint CIM Broker".
The branch, master has been updated
via 4699356c2c7973994aa0ad280d1a848c984d9a0f (commit)
from 3429a6d00ca9ec7e3c138ddbfcfb767b70bd4301 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 4699356c2c7973994aa0ad280d1a848c984d9a0f
Author: nsharoff <nsharoff@nsharoff.(none)>
Date: Wed Apr 4 10:53:18 2012 -0700
[ 3497096 ] double free during stopProc()
-----------------------------------------------------------------------
Summary of changes:
diff --git a/ChangeLog b/ChangeLog
index 52d9310..163f43b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2012-04-04 Narasimha Sharoff <nsh...@us...>
+ * providerDrv.c, providerMgr.c, sfcBroker.c:
+ [ 3497096 ] double free during stopProc()
+
+2012-04-04 Narasimha Sharoff <nsh...@us...>
+
* providerDrv.c, providerMgr.c, providerMgr.h, support.c:
[ 3416060 ] SIGSEGV in tool_mm_flush()
diff --git a/providerDrv.c b/providerDrv.c
index 0398ec8..4a8d4b0 100644
--- a/providerDrv.c
+++ b/providerDrv.c
@@ -503,11 +503,11 @@ stopProc(void *p)
mlogf(M_INFO, M_SHOW, "--- stopped %s %d\n", processName, getpid());
ctx->ft->release(ctx);
- uninit_sfcBroker();
- uninitProvProcCtl();
- uninitSocketPairs();
- sunsetControl();
- uninitGarbageCollector();
+ //uninit_sfcBroker(); /* 3497096 */
+ //uninitProvProcCtl();
+ //uninitSocketPairs();
+ //sunsetControl();
+ //uninitGarbageCollector();
exit(0);
}
diff --git a/providerMgr.c b/providerMgr.c
index 8516e33..1270a0b 100644
--- a/providerMgr.c
+++ b/providerMgr.c
@@ -115,6 +115,9 @@ notSupported(int *requestor, OperationHdr * req)
free(req);
}
+int prov_rdy_state = -1; /* 3497096 :77022 - stopBroker() reads this value */
+pthread_mutex_t syncMtx=PTHREAD_MUTEX_INITIALIZER; /* shared with stopBroker */
+
/*
* ------------- --- Instance Provider support ---className -------------
*/
@@ -1034,11 +1037,19 @@ processProviderMgrRequests()
req->nameSpace.data, req->className.data, req->type,
requestor));
+ pthread_mutex_lock(&syncMtx); /* 77022 */
+ prov_rdy_state = -1;
+ pthread_mutex_unlock(&syncMtx);
+
sigprocmask(SIG_SETMASK, &mask, &old_mask);
hdlr = mHandlers[req->type];
hdlr.handler(&requestor, req);
sigprocmask(SIG_SETMASK, &old_mask, NULL);
+ pthread_mutex_lock(&syncMtx); /* 77022 */
+ prov_rdy_state = 1;
+ pthread_mutex_unlock(&syncMtx);
+
_SFCB_TRACE(1,
("--- Mgr request for %s-%s DONE", req->nameSpace.data,
req->className.data));
diff --git a/sfcBroker.c b/sfcBroker.c
index 7a62a25..d45c1eb 100644
--- a/sfcBroker.c
+++ b/sfcBroker.c
@@ -161,6 +161,10 @@ stopNextAdapter()
return 0;
}
+/* 3497096 :77022 */
+extern pthread_mutex_t syncMtx; /* syncronize provider state */
+extern int prov_rdy_state; /* -1 indicates not ready */
+
static pthread_mutex_t sdMtx = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t sdCnd = PTHREAD_COND_INITIALIZER;
static int stopping = 0;
@@ -170,11 +174,34 @@ static void
stopBroker(void *p)
{
struct timespec waitTime;
- int rc,
- sa = 0,
- sp = 0;
+ int rc,sa=0,sp=0, count = 0;
+
+ /* SF 3497096 bugzilla 77022 */
+ /* stopping is set to prevent other threads calling this routine */
+ pthread_mutex_lock(&syncMtx);
+ if (stopping) {
+ printf("Stopping sfcb is in progress. Please wait...\n");
+ pthread_mutex_unlock(&syncMtx);
+ return;
+ }
+ else {
+ stopping=1;
+ pthread_mutex_unlock(&syncMtx);
+ }
- stopping = 1;
+ /* Look for providers ready status. A 5 seconds wait is performed to
+ * avoid a hang here in the event of provider looping, crashing etc
+ */
+ for (;;) {
+ pthread_mutex_lock(&syncMtx);
+ if (prov_rdy_state == -1) {
+ if (count >= 5) break; /* lock will be released later */
+ pthread_mutex_unlock(&syncMtx);
+ sleep(1);
+ count++;
+ }
+ else break; /* lock will be released later */
+ }
stopLocalConnectServer();
@@ -182,7 +209,7 @@ stopBroker(void *p)
if (adaptersStopped == 0) {
pthread_mutex_lock(&sdMtx);
- waitTime.tv_sec = time(NULL) + 5;
+ waitTime.tv_sec = time(NULL) + 1; //5
waitTime.tv_nsec = 0;
if (sa == 0)
fprintf(stderr, "--- Stopping adapters\n");
@@ -200,7 +227,7 @@ stopBroker(void *p)
if (adaptersStopped) {
pthread_mutex_lock(&sdMtx);
- waitTime.tv_sec = time(NULL) + 5;
+ waitTime.tv_sec = time(NULL) + 1; //5
waitTime.tv_nsec = 0;
if (sp == 0)
fprintf(stderr, "--- Stopping providers\n");
@@ -220,10 +247,12 @@ stopBroker(void *p)
uninitProvProcCtl();
uninitSocketPairs();
sunsetControl();
- // uninitGarbageCollector();
+ uninitGarbageCollector();
closeLogging();
free((void *)sfcBrokerStart);
+ pthread_mutex_unlock(&syncMtx);
+
if (restartBroker) {
char *emsg = strerror(errno);
execvp("sfcbd", restartArgv);
hooks/post-receive
--
SFCB - Small Footprint CIM Broker
|