Index: sblim-sfcb-1.4.8/msgqueue.c
===================================================================
--- sblim-sfcb-1.4.8.orig/msgqueue.c
+++ sblim-sfcb-1.4.8/msgqueue.c
@@ -220,6 +220,7 @@ spGetMsg(int *s, int *from, void *data,
   _SFCB_TRACE(1, ("--- Receiving from %d length %d", *s, length));
 
   memset(ccmsg, 0, sizeof(ccmsg));
+  memset(&iov, 0, sizeof(iov));
 
   msg.msg_name = 0;
   msg.msg_namelen = 0;
@@ -499,6 +500,7 @@ spSendReq(int *to, int *from, void *data
   struct iovec    iov[2];
   _SFCB_ENTER(TRACE_MSGQUEUE, "spSendReq");
 
+  memset(iov, 0, sizeof(iov));
   if (size) {
     n = 2;
     iov[1].iov_base = data;
@@ -520,6 +522,7 @@ spSendResult(int *to, int *from, void *d
   struct iovec    iov[2];
   _SFCB_ENTER(TRACE_MSGQUEUE, "spSendResult");
 
+  memset(iov, 0, sizeof(iov));
   if (size) {
     n = 2;
     iov[1].iov_base = data;
@@ -540,6 +543,7 @@ spSendResult2(int *to, int *from,
   struct iovec    iov[4];
   _SFCB_ENTER(TRACE_MSGQUEUE, "spSendResult2");
 
+  memset(iov, 0, sizeof(iov));
   iov[1].iov_base = d1;
   iov[1].iov_len = s1;
 
@@ -587,6 +591,7 @@ spSendCtl(int *to, int *from, short code
   char            ccmsg[CMSG_SPACE(sizeof(*from))];
   struct cmsghdr *cmsg;
 
+  memset(iov, 0, sizeof(iov));
   memset(ccmsg, 0, sizeof(ccmsg));
   memset(&spMsg, 0, sizeof(spMsg));
   spMsg.returnS = abs(*from);
Index: sblim-sfcb-1.4.8/providerDrv.c
===================================================================
--- sblim-sfcb-1.4.8.orig/providerDrv.c
+++ sblim-sfcb-1.4.8/providerDrv.c
@@ -336,6 +336,7 @@ testStartedProc(int pid, int *left)
   if (classProvInfoPtr->pid != 0)
     (*left)++;
 
+  fprintf(stderr, "# of providers left: %d\n", *left);
   return stopped;
 }
 
@@ -343,25 +344,21 @@ int
 stopNextProc()
 {
   ProviderProcess *pp = provProc;
-  int             i,
-                  done = 0,
-      t;
+  int pid, i;
 
-  for (i = provProcMax - 1; i; i--) {
-    if ((pp + i)->pid) {
-      kill((pp + i)->pid, SIGUSR1);
-      return (pp + i)->pid;
+  for (i = provProcMax - 1; i >= 0; i--) {
+    pid = pp[i].pid;
+    if (pid > 0) {
+      kill(pid, SIGUSR1);
+      return pid;
     }
   }
 
-  if (done == 0) {
     if (classProvInfoPtr && classProvInfoPtr->pid) {
-      t = classProvInfoPtr->pid;
-      kill(classProvInfoPtr->pid, SIGUSR1);
-      done = 1;
-      return t;
+      pid = classProvInfoPtr->pid;
+      kill(pid, SIGUSR1);
+      return pid;
     }
-  }
 
   return 0;
 }
Index: sblim-sfcb-1.4.8/sfcBroker.c
===================================================================
--- sblim-sfcb-1.4.8.orig/sfcBroker.c
+++ sblim-sfcb-1.4.8/sfcBroker.c
@@ -233,16 +233,15 @@ stopBroker(void *p)
 
   stopLocalConnectServer();
 
-  for (;;) {
-
-    if (adaptersStopped == 0) {
+  for (;!adaptersStopped || !providersStopped;) {
+    if (!adaptersStopped) {
       pthread_mutex_lock(&sdMtx);
       waitTime.tv_sec = time(NULL) + sigChldWaitTime;
       waitTime.tv_nsec = 0;
       if (sa == 0)
         fprintf(stderr, "--- Stopping adapters\n");
       sa++;
-      if (stopNextAdapter()) {
+      if (stopNextAdapter() != 0) {
         pthread_cond_timedwait(&sdCnd, &sdMtx, &waitTime);
       } else {
         /*
@@ -254,14 +253,14 @@ stopBroker(void *p)
       pthread_mutex_unlock(&sdMtx);
     }
 
-    if (adaptersStopped) {
+    if (adaptersStopped && !providersStopped) {
       pthread_mutex_lock(&sdMtx);
       waitTime.tv_sec = time(NULL) + sigChldWaitTime;
       waitTime.tv_nsec = 0;
       if (sp == 0)
         fprintf(stderr, "--- Stopping providers\n");
       sp++;
-      if (stopNextProc()) {
+      if (stopNextProc() != 0) {
         pthread_cond_timedwait(&sdCnd, &sdMtx, &waitTime);
       }
       else {
@@ -269,8 +268,6 @@ stopBroker(void *p)
       }
       pthread_mutex_unlock(&sdMtx);
     }
-    if (providersStopped)
-      break;
   }
 
   mlogf(M_NOTICE,M_QUIET,"--- %s V" sfcHttpDaemonVersion " stopped - %d\n", name, currentProc);
@@ -386,7 +383,7 @@ handleSigChld(int __attribute__ ((unused
       break;
     } else {
       // mlogf(M_INFO,M_SHOW,"sigchild %d\n",pid);
-      if (testStartedAdapter(pid, &left)) {
+      if (!adaptersStopped && testStartedAdapter(pid, &left)) {
         if (left == 0) {
           fprintf(stderr, "--- Adapters stopped\n");
           adaptersStopped = 1;
@@ -395,7 +392,7 @@ handleSigChld(int __attribute__ ((unused
         pthread_attr_init(&tattr);
         pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);
         pthread_create(&t, &tattr, (void *(*)(void *)) signalBroker, NULL);
-      } else if (testStartedProc(pid, &left)) {
+      } else if (!providersStopped && testStartedProc(pid, &left)) {
         if (left == 0) {
           fprintf(stderr, "--- Providers stopped\n");
           providersStopped = 1;
