From: Chris B. <buc...@us...> - 2012-03-30 01:55:53
|
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 9dc17f55fdb6f60fadb2933bbf04f3704b4439dd (commit) via 012889dc75df54ff558d2756fe256118900fc233 (commit) from a1daaf13257360db66b9bef6fc03961d90b4e2ac (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 9dc17f55fdb6f60fadb2933bbf04f3704b4439dd Author: buccella <buc...@li...> Date: Thu Mar 29 21:55:46 2012 -0400 [ 3408288 ] Safer Signal Handlers commit 012889dc75df54ff558d2756fe256118900fc233 Author: buccella <buc...@li...> Date: Thu Mar 29 21:53:25 2012 -0400 [ 3512575 ] Add indication delivery thread limit and timeout ----------------------------------------------------------------------- Summary of changes: diff --git a/ChangeLog b/ChangeLog index c0af307..eaffa80 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2012-03-29 Chris Buccella <buc...@li...> + * providerDrv.c: + [ 3408288 ] Safer Signal Handlers + * interopProvider.c, providerDrv.c, control.c, sfcb.cfg.pre.in: [ 3512575 ] Add indication delivery thread limit and timeout diff --git a/NEWS b/NEWS index f730c2e..48918d8 100644 --- a/NEWS +++ b/NEWS @@ -125,6 +125,7 @@ Bugs Fixed: - 3504607 CMPIRole Support in brokerUpc - 3510458 Malformed XML response to GetProperty - 3510456 GetProperty calls not passing keys to providers +- 3408288 Safer Signal Handlers Changes in 1.3.13 ================= diff --git a/providerDrv.c b/providerDrv.c index c506947..5660743 100644 --- a/providerDrv.c +++ b/providerDrv.c @@ -174,6 +174,10 @@ extern void uninitSocketPairs(); extern void sunsetControl(); extern void uninitGarbageCollector(); +static BinResponseHdr *err_crash_resp; /* holds generic "we crashed" response */ +static long ecr_len; +static long makeSafeResponse(BinResponseHdr *hdr, BinResponseHdr **out); + typedef struct parms { int requestor; BinRequestHdr *req; @@ -520,19 +524,14 @@ static void handleSigSegv(int sig) { Parms *threads = activeThreadsFirst; - char msg[1024]; - BinResponseHdr *resp; + int dmy = -1; mlogf(M_ERROR, M_SHOW, "-#- %s - %d provider exiting due to a SIGSEGV signal\n", processName, currentProc); while (threads) { - snprintf(msg, 1023, - "*** Provider %s(%d) exiting due to a SIGSEGV signal", - threads->pInfo->providerName, currentProc); - resp = errorCharsResp(CMPI_RC_ERR_FAILED, msg); - sendResponse(threads->requestor, resp); - threads = threads->next; + spSendResult(&threads->requestor, &dmy, err_crash_resp, ecr_len); + threads=threads->next; } } @@ -1005,6 +1004,13 @@ getProcess(ProviderInfo * info, ProviderProcess ** proc) _SFCB_ABORT(); } + char msg[1024]; + snprintf(msg,1023, "*** Provider %s(%d) exiting due to a SIGSEGV signal", + processName, currentProc); + BinResponseHdr* buf = errorCharsResp(CMPI_RC_ERR_FAILED, msg); + + ecr_len = makeSafeResponse(buf, &err_crash_resp); + processProviderInvocationRequests(info->providerName); _SFCB_RETURN(0); } @@ -1116,123 +1122,127 @@ typedef struct provHandler { int requestor); } ProvHandler; -static int -sendResponse(int requestor, BinResponseHdr * hdr) +static long +makeSafeResponse(BinResponseHdr* hdr, BinResponseHdr** out) { - _SFCB_ENTER(TRACE_PROVIDERDRV, "sendResponse"); - int i, - rvl = 0, - ol, - size, - dmy = -1; - long l; - char str_time[26]; - BinResponseHdr *buf; + int i, rvl=0, ol, size; + long len; + char str_time[26]; + BinResponseHdr *outHdr = NULL; size = sizeof(BinResponseHdr) + ((hdr->count - 1) * sizeof(MsgSegment)); if (hdr->rvValue) { - switch (hdr->rv.type) { + switch(hdr->rv.type) { case CMPI_string: if (hdr->rv.value.string) { - if (hdr->rv.value.string->hdl) { - hdr->rv.value.string = hdr->rv.value.string->hdl; - } else - hdr->rv.value.string = NULL; + if (hdr->rv.value.string->hdl) { + hdr->rv.value.string= hdr->rv.value.string->hdl; + } + else hdr->rv.value.string=NULL; } - hdr->rv.type = CMPI_chars; + + hdr->rv.type=CMPI_chars; + /* note: a break statement is NOT missing here... */ case CMPI_chars: - hdr->rvEnc = setCharsMsgSegment((char *) hdr->rv.value.string); - rvl = hdr->rvEnc.length; + hdr->rvEnc=setCharsMsgSegment((char*)hdr->rv.value.string); + rvl=hdr->rvEnc.length; break; case CMPI_dateTime: dateTime2chars(hdr->rv.value.dateTime, NULL, str_time); - hdr->rvEnc.type = MSG_SEG_CHARS; - hdr->rvEnc.length = rvl = 26; - hdr->rvEnc.data = &str_time; + hdr->rvEnc.type=MSG_SEG_CHARS; + hdr->rvEnc.length=rvl=26; + hdr->rvEnc.data=&str_time; break; case CMPI_ref: - mlogf(M_ERROR, M_SHOW, "-#- not supporting refs\n"); + mlogf(M_ERROR,M_SHOW,"-#- not supporting refs\n"); abort(); - default:; + default: ; } } - for (l = size, i = 0; i < hdr->count; i++) { - /* - * add padding length to calculation - */ - l += (hdr->object[i].type == - MSG_SEG_CHARS ? PADDED_LEN(hdr->object[i].length) : hdr-> - object[i].length); + for (len = size, i = 0; i < hdr->count; i++) { + /* add padding length to calculation */ + len += (hdr->object[i].type == MSG_SEG_CHARS ? PADDED_LEN(hdr->object[i].length) : hdr->object[i].length); } - buf = (BinResponseHdr *) malloc(l + rvl + 8); - memcpy(buf, hdr, size); + outHdr = malloc(len +rvl + 8); + memcpy(outHdr, hdr, size); if (rvl) { ol = hdr->rvEnc.length; - l = size; + len=size; switch (hdr->rvEnc.type) { case MSG_SEG_CHARS: - memcpy(((char *) buf) + l, hdr->rvEnc.data, ol); - buf->rvEnc.data = (void *) l; - l += ol; + memcpy(((char *) outHdr) + len, hdr->rvEnc.data, ol); + outHdr->rvEnc.data = (void *) len; + len += ol; break; - } - size = l; + } + size=len; } - for (l = size, i = 0; i < hdr->count; i++) { + for (len = size, i = 0; i < hdr->count; i++) { ol = hdr->object[i].length; switch (hdr->object[i].type) { case MSG_SEG_OBJECTPATH: getSerializedObjectPath((CMPIObjectPath *) hdr->object[i].data, - ((char *) buf) + l); - buf->object[i].data = (void *) l; - l += ol; + ((char *) outHdr) + len); + outHdr->object[i].data = (void *) len; + len += ol; break; case MSG_SEG_INSTANCE: getSerializedInstance((CMPIInstance *) hdr->object[i].data, - ((char *) buf) + l); - buf->object[i].data = (void *) l; - l += ol; + ((char *) outHdr) + len); + outHdr->object[i].data = (void *) len; + len += ol; break; case MSG_SEG_CHARS: - memcpy(((char *) buf) + l, hdr->object[i].data, ol); - buf->object[i].data = (void *) l; - buf->object[i].length = PADDED_LEN(ol); - l += buf->object[i].length; + memcpy(((char *) outHdr) + len, hdr->object[i].data, ol); + outHdr->object[i].data = (void *) len; + outHdr->object[i].length = PADDED_LEN(ol); + len += outHdr->object[i].length; break; case MSG_SEG_CONSTCLASS: getSerializedConstClass((CMPIConstClass *) hdr->object[i].data, - ((char *) buf) + l); - buf->object[i].data = (void *) l; - l += ol; + ((char *) outHdr) + len); + outHdr->object[i].data = (void *) len; + len += ol; break; case MSG_SEG_ARGS: getSerializedArgs((CMPIArgs *) hdr->object[i].data, - ((char *) buf) + l); - buf->object[i].data = (void *) l; - l += ol; + ((char *) outHdr) + len); + outHdr->object[i].data = (void *) len; + len += ol; break; + #ifdef HAVE_QUALREP case MSG_SEG_QUALIFIER: getSerializedQualifier((CMPIQualifierDecl *) hdr->object[i].data, - ((char *) buf) + l); - buf->object[i].data = (void *) l; - l += ol; + ((char *) outHdr) + len); + outHdr->object[i].data = (void *) len; + len += ol; break; #endif default: - mlogf(M_ERROR, M_SHOW, "--- bad sendResponse request %d\n", - hdr->object[i].type); - _SFCB_ABORT(); + mlogf(M_ERROR,M_SHOW,"--- bad sendResponse request %d\n", hdr->object[i].type); + abort(); } } - _SFCB_TRACE(1, ("--- Sending result to %d-%lu", - requestor, getInode(requestor))); + *out = outHdr; + return len; +} + +static int sendResponse(int requestor, BinResponseHdr * hdr) +{ + _SFCB_ENTER(TRACE_PROVIDERDRV, "sendResponse"); + int dmy=-1; + BinResponseHdr* buf = (void*)&dmy; + long l = makeSafeResponse(hdr, &buf); + + _SFCB_TRACE(1, ("--- Sending result %p to %d-%lu size %lu", + buf, requestor,getInode(requestor), l)); spSendResult(&requestor, &dmy, buf, l); free(buf); diff --git a/sfcb.cfg.pre.in b/sfcb.cfg.pre.in index be7922a..bd587df 100644 --- a/sfcb.cfg.pre.in +++ b/sfcb.cfg.pre.in @@ -278,6 +278,25 @@ sslCiphers: ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH ## 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 hooks/post-receive -- SFCB - Small Footprint CIM Broker |