aboutsummaryrefslogtreecommitdiff
path: root/src/zonemaster/gnunet-service-zonemaster.c
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2022-10-21 08:56:06 +0900
committerMartin Schanzenbach <schanzen@gnunet.org>2022-10-21 08:56:06 +0900
commit34c3a6c5ae3a7ce2b4ec8b2f13ee934cb7816f5a (patch)
treec660e0a7d617f73bea1d704dcda2014393543e4d /src/zonemaster/gnunet-service-zonemaster.c
parente2942b640a1d92cba8e074438a77504fba27ecc3 (diff)
downloadgnunet-34c3a6c5ae3a7ce2b4ec8b2f13ee934cb7816f5a.tar.gz
gnunet-34c3a6c5ae3a7ce2b4ec8b2f13ee934cb7816f5a.zip
-fix gns tests with slower(?) zonemaster
Diffstat (limited to 'src/zonemaster/gnunet-service-zonemaster.c')
-rw-r--r--src/zonemaster/gnunet-service-zonemaster.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/zonemaster/gnunet-service-zonemaster.c b/src/zonemaster/gnunet-service-zonemaster.c
index 48c27380b..029abe208 100644
--- a/src/zonemaster/gnunet-service-zonemaster.c
+++ b/src/zonemaster/gnunet-service-zonemaster.c
@@ -100,7 +100,7 @@
100/** 100/**
101 * Our workers 101 * Our workers
102 */ 102 */
103static pthread_t *worker; 103static pthread_t * worker;
104 104
105/** 105/**
106 * Lock for the open jobs queue. 106 * Lock for the open jobs queue.
@@ -113,6 +113,11 @@ static pthread_mutex_t jobs_lock;
113static pthread_mutex_t results_lock; 113static pthread_mutex_t results_lock;
114 114
115/** 115/**
116 * Wait condition on new jobs
117 */
118static pthread_cond_t empty_jobs;
119
120/**
116 * For threads to know we are shutting down 121 * For threads to know we are shutting down
117 */ 122 */
118static int in_shutdown = GNUNET_NO; 123static int in_shutdown = GNUNET_NO;
@@ -855,6 +860,7 @@ perform_dht_put (const struct GNUNET_IDENTITY_PrivateKey *key,
855 job->expire_pub = expire_pub; 860 job->expire_pub = expire_pub;
856 GNUNET_CONTAINER_DLL_insert (jobs_head, jobs_tail, job); 861 GNUNET_CONTAINER_DLL_insert (jobs_head, jobs_tail, job);
857 GNUNET_assert (0 == pthread_mutex_unlock (&jobs_lock)); 862 GNUNET_assert (0 == pthread_mutex_unlock (&jobs_lock));
863 pthread_cond_signal (&empty_jobs);
858 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 864 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
859 "Storing %u record(s) for label `%s' in DHT with expiration `%s'\n", 865 "Storing %u record(s) for label `%s' in DHT with expiration `%s'\n",
860 rd_public_count, 866 rd_public_count,
@@ -1208,6 +1214,7 @@ perform_dht_put_monitor (const struct GNUNET_IDENTITY_PrivateKey *key,
1208 job->expire_pub = expire_pub; 1214 job->expire_pub = expire_pub;
1209 GNUNET_CONTAINER_DLL_insert (jobs_head, jobs_tail, job); 1215 GNUNET_CONTAINER_DLL_insert (jobs_head, jobs_tail, job);
1210 GNUNET_assert (0 == pthread_mutex_unlock (&jobs_lock)); 1216 GNUNET_assert (0 == pthread_mutex_unlock (&jobs_lock));
1217 pthread_cond_signal (&empty_jobs);
1211} 1218}
1212 1219
1213 1220
@@ -1297,13 +1304,12 @@ sign_worker (void *cls)
1297 while (GNUNET_YES != in_shutdown) 1304 while (GNUNET_YES != in_shutdown)
1298 { 1305 {
1299 GNUNET_assert (0 == pthread_mutex_lock (&jobs_lock)); 1306 GNUNET_assert (0 == pthread_mutex_lock (&jobs_lock));
1300 if (NULL != jobs_head) 1307 while (NULL == jobs_head)
1301 { 1308 pthread_cond_wait (&empty_jobs, &jobs_lock);
1302 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1309 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1303 "Taking on Job for %s\n", jobs_head->label); 1310 "Taking on Job for %s\n", jobs_head->label);
1304 job = jobs_head; 1311 job = jobs_head;
1305 GNUNET_CONTAINER_DLL_remove (jobs_head, jobs_tail, job); 1312 GNUNET_CONTAINER_DLL_remove (jobs_head, jobs_tail, job);
1306 }
1307 GNUNET_assert (0 == pthread_mutex_unlock (&jobs_lock)); 1313 GNUNET_assert (0 == pthread_mutex_unlock (&jobs_lock));
1308 if (NULL != job) 1314 if (NULL != job)
1309 { 1315 {
@@ -1318,10 +1324,6 @@ sign_worker (void *cls)
1318 "Done, notifying main thread through pipe!\n"); 1324 "Done, notifying main thread through pipe!\n");
1319 GNUNET_DISK_file_write (fh, "!", 1); 1325 GNUNET_DISK_file_write (fh, "!", 1);
1320 } 1326 }
1321 else
1322 {
1323 sleep (1);
1324 }
1325 } 1327 }
1326 return NULL; 1328 return NULL;
1327} 1329}