src/server/util/thrpool.c

changeset 408
56edda8701e0
parent 358
f3b490a2150c
equal deleted inserted replaced
407:78af44222463 408:56edda8701e0
55 int threadpool_start(threadpool_t *pool) { 55 int threadpool_start(threadpool_t *pool) {
56 /* create pool threads */ 56 /* create pool threads */
57 for(int i=0;i<pool->min_threads;i++) { 57 for(int i=0;i<pool->min_threads;i++) {
58 pthread_t t; 58 pthread_t t;
59 if (pthread_create(&t, NULL, threadpool_func, pool) != 0) { 59 if (pthread_create(&t, NULL, threadpool_func, pool) != 0) {
60 perror("Error: threadpool_start: pthread_create"); 60 log_ereport(LOG_FAILURE, "threadpool_start: pthread_create failed: %s", strerror(errno));
61 return 1; 61 return 1;
62 } 62 }
63 } 63 }
64 return 0; 64 return 0;
65 } 65 }
133 //} 133 //}
134 134
135 if(create_thread) { 135 if(create_thread) {
136 pthread_t t; 136 pthread_t t;
137 if (pthread_create(&t, NULL, threadpool_func, pool) != 0) { 137 if (pthread_create(&t, NULL, threadpool_func, pool) != 0) {
138 perror("Error: threadpool_run: pthread_create"); 138 log_ereport(LOG_FAILURE, "threadpool_run: pthread_create failed: %s", strerror(errno));
139 } 139 }
140 } 140 }
141 if(destroy_thread) { 141 if(destroy_thread) {
142 threadpool_enqueue_job(pool, &kill_job); 142 threadpool_enqueue_job(pool, &kill_job);
143 pthread_cond_signal(&pool->available); 143 pthread_cond_signal(&pool->available);

mercurial