|
From: Chris B. <buc...@us...> - 2012-03-29 15:39:36
|
Update of /cvsroot/sblim/sfcb
In directory vz-cvs-3.sog:/tmp/cvs-serv19647
Modified Files:
interopProvider.c providerDrv.c sfcb.cfg.pre.in
Log Message:
[ 3512575 ] Add indication delivery thread limit and timeout
Index: sfcb.cfg.pre.in
===================================================================
RCS file: /cvsroot/sblim/sfcb/sfcb.cfg.pre.in,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- sfcb.cfg.pre.in 4 Feb 2012 01:03:31 -0000 1.30
+++ sfcb.cfg.pre.in 29 Mar 2012 15:39:33 -0000 1.31
@@ -256,6 +256,25 @@
## Default is 0. If trace mask is set (by any method) the default is 1.
#traceLevel: 0
+##---------------------------- Indications ----------------------------
+
+## Indication provider calls to CBDeliverIndication() cause a thread to spawn
+## which will handle the delivery. This allows CBDeliverIndication() to return
+## without waiting for the delivery to complete. However, spawning an unlimited
+## number of threads will cause increased resource usage. This limit will
+## prevent unlimited thread creation. If the limit is reached, calls to
+## CBDeliverIndication will block.
+## Default is 30
+#indicationDeliveryThreadLimit: 30
+
+## When the indicationDeliveryThreadLimit is reached, delivery requests will
+## block, waiting to create a thread. This timeout allows for the indication
+## to be dropped if a new thread cannot be created within a given time.
+## Note that this dropped indication will not be retried, even if reliable
+## indications support is enabled.
+## Default is 0 (no timeout)
+#indicationDeliveryThreadTimeout: 0
+
##----------------------------Reliable Indications ----------------------------
## Interval between indication retry attempts
## Default is 20 seconds
Index: interopProvider.c
===================================================================
RCS file: /cvsroot/sblim/sfcb/interopProvider.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- interopProvider.c 29 Mar 2012 13:57:10 -0000 1.57
+++ interopProvider.c 29 Mar 2012 15:39:33 -0000 1.58
@@ -86,6 +86,18 @@
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;
+
/* ------------------------------------------------------------------------- */
static int interOpNameSpace(
@@ -760,7 +772,11 @@
CMRelease(enm);
}
CMRelease(ctxLocal);
-
+
+ getControlNum("indicationDeliveryThreadLimit",&MAX_IND_THREADS);
+ getControlNum("indicationDeliveryThreadTimeout",&IND_THREAD_TO);
+ sem_init(&availThreadsSem, 0, MAX_IND_THREADS);
+
_SFCB_EXIT();
}
@@ -1241,12 +1257,6 @@
_SFCB_RETURN(st);
}
-typedef struct delivery_info {
- const CMPIContext* ctx;
- CMPIObjectPath *hop;
- CMPIArgs* hin;
-} DeliveryInfo;
-
void * sendIndForDelivery(void *di) {
_SFCB_ENTER(TRACE_INDPROVIDER, "sendIndForDelivery");
@@ -1259,6 +1269,7 @@
CMRelease(delInfo->hop);
CMRelease(delInfo->hin);
free(di);
+ sem_post(&availThreadsSem);
pthread_exit(NULL);
}
@@ -1334,9 +1345,25 @@
di->hop = CMClone(su->ha->hop, NULL);
di->hin = CMClone(hin, NULL);
- pthread_create(&ind_thread, &it_attr,&sendIndForDelivery,(void *) di);
+ 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");
- _SFCB_TRACE(1,("--- invoke handler status: %d",st.rc));
}
}
}
@@ -1383,7 +1410,7 @@
_SFCB_TRACE(1,("--- Invalid request method: %s",methodName));
setStatus(&st, CMPI_RC_ERR_METHOD_NOT_FOUND, "Invalid request method");
}
-
+
_SFCB_RETURN(st);
}
Index: providerDrv.c
===================================================================
RCS file: /cvsroot/sblim/sfcb/providerDrv.c,v
retrieving revision 1.111
retrieving revision 1.112
diff -u -d -r1.111 -r1.112
--- providerDrv.c 26 Mar 2012 18:32:25 -0000 1.111
+++ providerDrv.c 29 Mar 2012 15:39:33 -0000 1.112
@@ -3113,8 +3113,11 @@
processProviderInvocationRequestsThread(parms);
}
else {
- pthread_create(&t, &tattr, (void *(*)(void *))
+ 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 {
|