| 
														
															@@ -25,7 +25,7 @@ struct threadpool_s { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   unsigned generation; 
														 | 
														
														 | 
														
															   unsigned generation; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															   /** Function that should be run for updates on each thread. */ 
														 | 
														
														 | 
														
															   /** Function that should be run for updates on each thread. */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  int (*update_fn)(void *, void *); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  workqueue_reply_t (*update_fn)(void *, void *); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   /** Function to free update arguments if they can't be run. */ 
														 | 
														
														 | 
														
															   /** Function to free update arguments if they can't be run. */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   void (*free_update_arg_fn)(void *); 
														 | 
														
														 | 
														
															   void (*free_update_arg_fn)(void *); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   /** Array of n_threads update arguments. */ 
														 | 
														
														 | 
														
															   /** Array of n_threads update arguments. */ 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -56,7 +56,7 @@ struct workqueue_entry_s { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   /** True iff this entry is waiting for a worker to start processing it. */ 
														 | 
														
														 | 
														
															   /** True iff this entry is waiting for a worker to start processing it. */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   uint8_t pending; 
														 | 
														
														 | 
														
															   uint8_t pending; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   /** Function to run in the worker thread. */ 
														 | 
														
														 | 
														
															   /** Function to run in the worker thread. */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  int (*fn)(void *state, void *arg); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  workqueue_reply_t (*fn)(void *state, void *arg); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   /** Function to run while processing the reply queue. */ 
														 | 
														
														 | 
														
															   /** Function to run while processing the reply queue. */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   void (*reply_fn)(void *arg); 
														 | 
														
														 | 
														
															   void (*reply_fn)(void *arg); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   /** Argument for the above functions. */ 
														 | 
														
														 | 
														
															   /** Argument for the above functions. */ 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -96,7 +96,7 @@ static void queue_reply(replyqueue_t *queue, workqueue_entry_t *work); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  * <b>fn</b> in the worker thread, and <b>reply_fn</b> in the main 
														 | 
														
														 | 
														
															  * <b>fn</b> in the worker thread, and <b>reply_fn</b> in the main 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  * thread. See threadpool_queue_work() for full documentation. */ 
														 | 
														
														 | 
														
															  * thread. See threadpool_queue_work() for full documentation. */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 static workqueue_entry_t * 
														 | 
														
														 | 
														
															 static workqueue_entry_t * 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-workqueue_entry_new(int (*fn)(void*, void*), 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+workqueue_entry_new(workqueue_reply_t (*fn)(void*, void*), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                     void (*reply_fn)(void*), 
														 | 
														
														 | 
														
															                     void (*reply_fn)(void*), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                     void *arg) 
														 | 
														
														 | 
														
															                     void *arg) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 { 
														 | 
														
														 | 
														
															 { 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -172,7 +172,7 @@ worker_thread_main(void *thread_) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   workerthread_t *thread = thread_; 
														 | 
														
														 | 
														
															   workerthread_t *thread = thread_; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   threadpool_t *pool = thread->in_pool; 
														 | 
														
														 | 
														
															   threadpool_t *pool = thread->in_pool; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   workqueue_entry_t *work; 
														 | 
														
														 | 
														
															   workqueue_entry_t *work; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  int result; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  workqueue_reply_t result; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															   tor_mutex_acquire(&pool->lock); 
														 | 
														
														 | 
														
															   tor_mutex_acquire(&pool->lock); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   while (1) { 
														 | 
														
														 | 
														
															   while (1) { 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -182,13 +182,14 @@ worker_thread_main(void *thread_) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       if (thread->in_pool->generation != thread->generation) { 
														 | 
														
														 | 
														
															       if (thread->in_pool->generation != thread->generation) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         void *arg = thread->in_pool->update_args[thread->index]; 
														 | 
														
														 | 
														
															         void *arg = thread->in_pool->update_args[thread->index]; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         thread->in_pool->update_args[thread->index] = NULL; 
														 | 
														
														 | 
														
															         thread->in_pool->update_args[thread->index] = NULL; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        int (*update_fn)(void*,void*) = thread->in_pool->update_fn; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        workqueue_reply_t (*update_fn)(void*,void*) = 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            thread->in_pool->update_fn; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         thread->generation = thread->in_pool->generation; 
														 | 
														
														 | 
														
															         thread->generation = thread->in_pool->generation; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         tor_mutex_release(&pool->lock); 
														 | 
														
														 | 
														
															         tor_mutex_release(&pool->lock); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        int r = update_fn(thread->state, arg); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        workqueue_reply_t r = update_fn(thread->state, arg); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        if (r < 0) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        if (r != WQ_RPL_REPLY) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															           return; 
														 | 
														
														 | 
														
															           return; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -208,7 +209,7 @@ worker_thread_main(void *thread_) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       queue_reply(thread->reply_queue, work); 
														 | 
														
														 | 
														
															       queue_reply(thread->reply_queue, work); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															       /* We may need to exit the thread. */ 
														 | 
														
														 | 
														
															       /* We may need to exit the thread. */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      if (result >= WQ_RPL_ERROR) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      if (result != WQ_RPL_REPLY) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         return; 
														 | 
														
														 | 
														
															         return; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       } 
														 | 
														
														 | 
														
															       } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															       tor_mutex_acquire(&pool->lock); 
														 | 
														
														 | 
														
															       tor_mutex_acquire(&pool->lock); 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -281,7 +282,7 @@ workerthread_new(void *state, threadpool_t *pool, replyqueue_t *replyqueue) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  */ 
														 | 
														
														 | 
														
															  */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 workqueue_entry_t * 
														 | 
														
														 | 
														
															 workqueue_entry_t * 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 threadpool_queue_work(threadpool_t *pool, 
														 | 
														
														 | 
														
															 threadpool_queue_work(threadpool_t *pool, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                      int (*fn)(void *, void *), 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                      workqueue_reply_t (*fn)(void *, void *), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                       void (*reply_fn)(void *), 
														 | 
														
														 | 
														
															                       void (*reply_fn)(void *), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                       void *arg) 
														 | 
														
														 | 
														
															                       void *arg) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 { 
														 | 
														
														 | 
														
															 { 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -318,7 +319,7 @@ threadpool_queue_work(threadpool_t *pool, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 int 
														 | 
														
														 | 
														
															 int 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 threadpool_queue_update(threadpool_t *pool, 
														 | 
														
														 | 
														
															 threadpool_queue_update(threadpool_t *pool, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                          void *(*dup_fn)(void *), 
														 | 
														
														 | 
														
															                          void *(*dup_fn)(void *), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                         int (*fn)(void *, void *), 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                         workqueue_reply_t (*fn)(void *, void *), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                          void (*free_fn)(void *), 
														 | 
														
														 | 
														
															                          void (*free_fn)(void *), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															                          void *arg) 
														 | 
														
														 | 
														
															                          void *arg) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 { 
														 | 
														
														 | 
														
															 { 
														 |