From: Chris B. <buc...@us...> - 2012-03-29 18:26:20
|
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 a1daaf13257360db66b9bef6fc03961d90b4e2ac (commit) from befeb9d217f804a51bd5536fa47a2f833803c18c (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 a1daaf13257360db66b9bef6fc03961d90b4e2ac Author: buccella <buc...@li...> Date: Thu Mar 29 14:25:55 2012 -0400 [ 3512575 ] Add indication delivery thread limit and timeout ----------------------------------------------------------------------- Summary of changes: diff --git a/ChangeLog b/ChangeLog index 3740b12..c0af307 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-03-29 Chris Buccella <buc...@li...> + + * interopProvider.c, providerDrv.c, control.c, sfcb.cfg.pre.in: + [ 3512575 ] Add indication delivery thread limit and timeout + 2012-03-28 Chris Buccella <buc...@li...> * cimXmlOps.y: diff --git a/NEWS b/NEWS index 7187ff2..f730c2e 100644 --- a/NEWS +++ b/NEWS @@ -100,6 +100,7 @@ New Features: - 3367332 RHOST Support for PAM - 3367361 Allow for releasing auth handle after CIM request completes - 3367363 Add CMPIRole Support +- 3512575 Add indication delivery thread limit and timeout Bugs Fixed: diff --git a/control.c b/control.c index 108d227..3b2e7f3 100644 --- a/control.c +++ b/control.c @@ -126,6 +126,8 @@ Control init[] = { {"DeliveryRetryAttempts",1,"3"}, {"SubscriptionRemovalTimeInterval",1,"2592000"}, {"SubscriptionRemovalAction",1,"2"}, + {"indicationDeliveryThreadLimit",1,"30"}, + {"indicationDeliveryThreadTimeout",1,"0"}, }; diff --git a/interopProvider.c b/interopProvider.c index 84b4cd9..8f44a21 100644 --- a/interopProvider.c +++ b/interopProvider.c @@ -37,6 +37,7 @@ #include "objectpath.h" #include <time.h> #include "instance.h" +#include "control.h" #define LOCALCLASSNAME "InteropProvider" @@ -87,6 +88,19 @@ static UtilHashTable *filterHt = NULL; static UtilHashTable *handlerHt = NULL; static UtilHashTable *subscriptionHt = NULL; +/* for indication delivery */ +static long MAX_IND_THREADS; +static long IND_THREAD_TO; +static sem_t availThreadsSem; +struct timespec availThreadWait; + +typedef struct delivery_info { + const CMPIContext* ctx; + CMPIObjectPath *hop; + CMPIArgs* hin; +} DeliveryInfo; + + /* * ------------------------------------------------------------------------- */ @@ -817,6 +831,10 @@ initInterOp(const CMPIBroker * broker, const CMPIContext *ctx) } CMRelease(ctxLocal); + getControlNum("indicationDeliveryThreadLimit",&MAX_IND_THREADS); + getControlNum("indicationDeliveryThreadTimeout",&IND_THREAD_TO); + sem_init(&availThreadsSem, 0, MAX_IND_THREADS); + _SFCB_EXIT(); } @@ -1340,24 +1358,22 @@ InteropProviderMethodCleanup(CMPIMethodMI * mi, * ------------------------------------------------------------------------- */ -typedef struct delivery_info { - const CMPIContext* ctx; - CMPIObjectPath *hop; - CMPIArgs* hin; -} DeliveryInfo; void * sendIndForDelivery(void *di) { _SFCB_ENTER(TRACE_INDPROVIDER, "sendIndForDelivery"); + fprintf(stderr, "thread started %p\n", (void*)pthread_self()); DeliveryInfo* delInfo; delInfo = (DeliveryInfo*)di; CBInvokeMethod(_broker,delInfo->ctx,delInfo->hop,"_deliver",delInfo->hin,NULL,NULL); - + sleep(5); CMRelease((CMPIContext*)delInfo->ctx); CMRelease(delInfo->hop); CMRelease(delInfo->hin); free(di); + sem_post(&availThreadsSem); + fprintf(stderr, "thread exiting %p\n", (void*)pthread_self()); pthread_exit(NULL); } @@ -1438,10 +1454,25 @@ InteropProviderInvokeMethod(CMPIMethodMI * mi, di->ctx = native_clone_CMPIContext(ctx); di->hop = CMClone(su->ha->hop, NULL); di->hin = CMClone(hin, NULL); - - pthread_create(&ind_thread, &it_attr,&sendIndForDelivery,(void *) di); - - _SFCB_TRACE(1, ("--- invoke handler status: %d", st.rc)); + if (IND_THREAD_TO > 0) { + availThreadWait.tv_sec = time(NULL) + IND_THREAD_TO; + while ((sem_timedwait(&availThreadsSem, &availThreadWait)) == -1) { + if (errno == ETIMEDOUT) { + mlogf(M_ERROR,M_SHOW,"Timedout waiting to create indication delivery thread; dropping indication\n"); + break; + } + else /* probably EINTR */ + continue; + } + } + else { + sem_wait(&availThreadsSem); + } + int pcrc = pthread_create(&ind_thread, &it_attr,&sendIndForDelivery,(void *) di); + + _SFCB_TRACE(1,("--- indication delivery thread status: %d", pcrc)); + if (pcrc) + mlogf(M_ERROR,M_SHOW,"pthread_create() failed for indication delivery thread\n"); } } } diff --git a/providerDrv.c b/providerDrv.c index a198e81..c506947 100644 --- a/providerDrv.c +++ b/providerDrv.c @@ -3561,9 +3561,12 @@ processProviderInvocationRequests(char *name) if (parms->req->operation == OPS_LoadProvider || debugMode) { processProviderInvocationRequestsThread(parms); } else { - pthread_create(&t, &tattr, (void *(*)(void *)) - processProviderInvocationRequestsThread, - (void *) parms); + int pcrc = pthread_create(&t, &tattr, (void *(*)(void *)) + processProviderInvocationRequestsThread, + (void *) parms); + if (pcrc) + mlogf(M_ERROR,M_SHOW,"pthread_create() failed for handling provider request\n"); + } } else { free(parms); hooks/post-receive -- SFCB - Small Footprint CIM Broker |