#include "conn_queue.h"
#include "smtpsink-int.h"
+
/* struct conn_pool should be private */
static struct conn_pool {
pthread_mutex_t cpmtx;
static pthread_cond_t lc;
static pthread_mutex_t lmtx;
-static int nl=0;
+static int nl=0, lready = 0;
static void *
listener_loop(void *data)
* before all queues are initialized.
*/
if (pthread_mutex_lock(&lmtx)) assert(0);
- if (pthread_cond_wait(&lc, &lmtx)) assert(0);
+ if (!lready)
+ if (pthread_cond_wait(&lc, &lmtx)) assert(0);
pthread_mutex_unlock(&lmtx);
while (1) {
void
start_listeners(void)
{
- int i;
- for (i = 0; i < nl; i++) {
- pthread_cond_signal(&lc);
- }
+ if (pthread_mutex_lock(&lmtx)) assert(0);
+ lready = 1;
+ pthread_mutex_unlock(&lmtx);
+ pthread_cond_broadcast(&lc);
}