aboutsummaryrefslogtreecommitdiff
path: root/src/common/workqueue.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-06-19 12:15:55 -0400
committerNick Mathewson <nickm@torproject.org>2016-06-19 12:15:55 -0400
commitb421648da2d3e73e0cfd6fd847c3279f64a332cd (patch)
treeb55afd610297548013d4f1753dec068850135465 /src/common/workqueue.c
parent2c96d95c12a8d8678ec5821d83072afe045755ff (diff)
parent429d15c5291d9d6668457b7070f8c5fc2c6994e1 (diff)
downloadtor-b421648da2d3e73e0cfd6fd847c3279f64a332cd.tar.gz
tor-b421648da2d3e73e0cfd6fd847c3279f64a332cd.zip
Merge remote-tracking branch 'public/thread_coverage'
Diffstat (limited to 'src/common/workqueue.c')
-rw-r--r--src/common/workqueue.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/common/workqueue.c b/src/common/workqueue.c
index 0a38550de0..48c0cca01f 100644
--- a/src/common/workqueue.c
+++ b/src/common/workqueue.c
@@ -262,9 +262,12 @@ workerthread_new(void *state, threadpool_t *pool, replyqueue_t *replyqueue)
thr->in_pool = pool;
if (spawn_func(worker_thread_main, thr) < 0) {
+ //LCOV_EXCL_START
+ tor_assert_nonfatal_unreached();
log_err(LD_GENERAL, "Can't launch worker thread.");
tor_free(thr);
return NULL;
+ //LCOV_EXCL_STOP
}
return thr;
@@ -375,8 +378,8 @@ threadpool_queue_update(threadpool_t *pool,
static int
threadpool_start_threads(threadpool_t *pool, int n)
{
- if (n < 0)
- return -1;
+ if (BUG(n < 0))
+ return -1; // LCOV_EXCL_LINE
if (n > MAX_THREADS)
n = MAX_THREADS;
@@ -391,9 +394,12 @@ threadpool_start_threads(threadpool_t *pool, int n)
workerthread_t *thr = workerthread_new(state, pool, pool->reply_queue);
if (!thr) {
+ //LCOV_EXCL_START
+ tor_assert_nonfatal_unreached();
pool->free_thread_state_fn(state);
tor_mutex_release(&pool->lock);
return -1;
+ //LCOV_EXCL_STOP
}
thr->index = pool->n_threads;
pool->threads[pool->n_threads++] = thr;
@@ -429,10 +435,13 @@ threadpool_new(int n_threads,
pool->reply_queue = replyqueue;
if (threadpool_start_threads(pool, n_threads) < 0) {
+ //LCOV_EXCL_START
+ tor_assert_nonfatal_unreached();
tor_cond_uninit(&pool->condition);
tor_mutex_uninit(&pool->lock);
tor_free(pool);
return NULL;
+ //LCOV_EXCL_STOP
}
return pool;
@@ -456,8 +465,10 @@ replyqueue_new(uint32_t alertsocks_flags)
rq = tor_malloc_zero(sizeof(replyqueue_t));
if (alert_sockets_create(&rq->alert, alertsocks_flags) < 0) {
+ //LCOV_EXCL_START
tor_free(rq);
return NULL;
+ //LCOV_EXCL_STOP
}
tor_mutex_init(&rq->lock);
@@ -486,10 +497,12 @@ void
replyqueue_process(replyqueue_t *queue)
{
if (queue->alert.drain_fn(queue->alert.read_fd) < 0) {
+ //LCOV_EXCL_START
static ratelim_t warn_limit = RATELIM_INIT(7200);
log_fn_ratelim(&warn_limit, LOG_WARN, LD_GENERAL,
"Failure from drain_fd: %s",
tor_socket_strerror(tor_socket_errno(queue->alert.read_fd)));
+ //LCOV_EXCL_STOP
}
tor_mutex_acquire(&queue->lock);