slot->a = a; slot->b = b; slot->c = c;
if (( slot->state == rs_idle ) || ( slot->state == rs_zombie ))  { slot->state = 1; workToDo = 0; slot->a = a; slot->b = b; slot->c = c; slot->startFunc = startFunc; slot->prThread = PR_CreateThread(PR_USER_THREAD, thread_wrapper, slot, PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0); if (slot->prThread == NULL) { printf("selfserv: Failed to launch thread!\n"); slot->state = rs_idle; return SECFailure; }
launch_thread(    startFn    *startFunc,    PRFileDesc *a,    PRFileDesc *b,    int         c){    perThread * slot;    int         i;    if (!threadStartQ) {	threadLock = PR_NewLock();	threadStartQ = PR_NewCondVar(threadLock);	threadEndQ   = PR_NewCondVar(threadLock);    }    PR_Lock(threadLock);    while (numRunning >= MAX_THREADS) {    	PR_WaitCondVar(threadStartQ, PR_INTERVAL_NO_TIMEOUT);    }    for (i = 0; i < numUsed; ++i) {	slot = threads + i;    	if (slot->running == rs_idle) 	    break;    }    if (i >= numUsed) {	if (i >= MAX_THREADS) {	    /* something's really wrong here. */	    PORT_Assert(i < MAX_THREADS);	    PR_Unlock(threadLock);	    return SECFailure;	}	++numUsed;	PORT_Assert(numUsed == i + 1);	slot = threads + i;    }    slot->a = a;    slot->b = b;    slot->c = c;    slot->startFunc = startFunc;    slot->prThread      = PR_CreateThread(PR_USER_THREAD,                                      thread_wrapper, slot,				      PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,				      PR_JOINABLE_THREAD, 0);    if (slot->prThread == NULL) {	PR_Unlock(threadLock);	printf("selfserv: Failed to launch thread!\n");	return SECFailure;    }     slot->inUse   = 1;    slot->running = 1;    ++numRunning;    PR_Unlock(threadLock);    PRINTF("selfserv: Launched thread in slot %d \n", i);    FLUSH;    return SECSuccess;}