From: Dave H. <hel...@us...> - 2013-09-25 21:07:06
|
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_1.3 has been updated via f2c44c35521a5c0900d0e38730711926ba17f62a (commit) from 7a65569051f0601c69c62c9eeb85097dc238001b (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 f2c44c35521a5c0900d0e38730711926ba17f62a Author: Dave Heller <hel...@us...> Date: Wed Sep 25 17:06:43 2013 -0400 [sfcb-tix:#78] Simplify mutex handling in instance.c ----------------------------------------------------------------------- Summary of changes: instance.c | 33 ++++++++------------------------- 1 files changed, 8 insertions(+), 25 deletions(-) diff --git a/instance.c b/instance.c index e015bce..12af95f 100644 --- a/instance.c +++ b/instance.c @@ -72,7 +72,10 @@ struct native_instance { char **key_list; }; +static pthread_mutex_t gopMtx = PTHREAD_MUTEX_INITIALIZER; + #ifdef HAVE_DEFAULT_PROPERTIES +static pthread_mutex_t ifdpMtx = PTHREAD_MUTEX_INITIALIZER; static int instFillDefaultProperties(struct native_instance *inst, const char * ns, const char * cn); #endif @@ -439,7 +442,6 @@ static CMPIStatus __ift_setObjectPath(CMPIInstance * inst, static CMPIObjectPath *__ift_getObjectPath(const CMPIInstance * instance, CMPIStatus * rc) { - static CMPI_MUTEX_TYPE * mtx = NULL; static UtilHashTable *klt = NULL; int j, f = 0; CMPIStatus tmp; @@ -480,18 +482,7 @@ static CMPIObjectPath *__ift_getObjectPath(const CMPIInstance * instance, CMPIData d; unsigned int e, m; - if (mtx == NULL) { - int dummy = 0; - mtx = memAlloc(MEM_TRACKED, sizeof(CMPI_MUTEX_TYPE), &dummy); - *mtx = Broker->xft->newMutex(0); - } - if (! *mtx) { - mlogf(M_ERROR, M_SHOW, "--- Could not get op for instance of %s; mutex creation failure\n", cn); - if(rc) - CMSetStatus(rc, CMPI_RC_ERR_FAILED); - return NULL; - } - Broker->xft->lockMutex(*mtx); + pthread_mutex_lock(&gopMtx); if (klt == NULL) klt = UtilFactory->newHashTable(61, UtilHashTable_charKey | UtilHashTable_ignoreKeyCase); @@ -504,11 +495,11 @@ static CMPIObjectPath *__ift_getObjectPath(const CMPIInstance * instance, if(rc) { CMSetStatus(rc, CMPI_RC_ERR_INVALID_CLASS); } - Broker->xft->unlockMutex(*mtx); + pthread_mutex_unlock(&gopMtx); return NULL; } } - Broker->xft->unlockMutex(*mtx); + pthread_mutex_unlock(&gopMtx); m = kl->ft->getSize(kl, NULL); for (e = 0; e < m; e++) { @@ -1030,7 +1021,6 @@ void setInstanceLocalMode(int mode) static int instFillDefaultProperties(struct native_instance *inst, const char * ns, const char * cn) { - static CMPI_MUTEX_TYPE * mtx = NULL; static UtilHashTable *clt = NULL; CMPIConstClass *cc; CMPICount pc; @@ -1039,14 +1029,7 @@ static int instFillDefaultProperties(struct native_instance *inst, CMPIString *pn = NULL; CMPIValue *vp; - if (mtx == NULL) { - mtx = malloc(sizeof(CMPI_MUTEX_TYPE)); - *mtx = Broker->xft->newMutex(0); - } - if (!*mtx) { - return -1; - } - Broker->xft->lockMutex(*mtx); + pthread_mutex_lock(&ifdpMtx); if (clt == NULL) clt = UtilFactory->newHashTable(61, UtilHashTable_charKey | UtilHashTable_ignoreKeyCase); @@ -1057,7 +1040,7 @@ static int instFillDefaultProperties(struct native_instance *inst, clt->ft->put(clt, strdup(cn), cc->ft->clone(cc,NULL)); } } - Broker->xft->unlockMutex(*mtx); + pthread_mutex_unlock(&ifdpMtx); if (cc) { pc = cc->ft->getPropertyCount(cc,NULL); while (pc > 0) { hooks/post-receive -- sfcb - Small Footprint CIM Broker |