diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-08-22 23:59:54 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-08-22 23:59:54 +0200 |
commit | ea901fb4978ee7e9cfd2f74c810f2146bdf9d46b (patch) | |
tree | f2bbad92955ed144bc6afa9a03ece372c20a874a /src/pq/test_pq.c | |
parent | 9ef7f0704fa0458f2e27ba188aec5102dbb780b2 (diff) | |
download | gnunet-ea901fb4978ee7e9cfd2f74c810f2146bdf9d46b.tar.gz gnunet-ea901fb4978ee7e9cfd2f74c810f2146bdf9d46b.zip |
-simplify libgnunetpq to only support single-threaded applications that do use the scheudler (when using event API)
Diffstat (limited to 'src/pq/test_pq.c')
-rw-r--r-- | src/pq/test_pq.c | 64 |
1 files changed, 2 insertions, 62 deletions
diff --git a/src/pq/test_pq.c b/src/pq/test_pq.c index ffbb4d129..90b5c6489 100644 --- a/src/pq/test_pq.c +++ b/src/pq/test_pq.c | |||
@@ -240,63 +240,6 @@ run_queries (struct GNUNET_PQ_Context *db) | |||
240 | } | 240 | } |
241 | 241 | ||
242 | 242 | ||
243 | static void | ||
244 | event_cb (void *cls, | ||
245 | const void *extra, | ||
246 | size_t extra_size) | ||
247 | { | ||
248 | unsigned int *cnt = cls; | ||
249 | |||
250 | GNUNET_assert (5 == extra_size); | ||
251 | GNUNET_assert (0 == memcmp ("world", | ||
252 | extra, | ||
253 | 5)); | ||
254 | (*cnt)++; | ||
255 | } | ||
256 | |||
257 | |||
258 | /** | ||
259 | * Run subscribe/notify tests. | ||
260 | * | ||
261 | * @param db database handle | ||
262 | * @return 0 on success | ||
263 | */ | ||
264 | static int | ||
265 | test_notify (struct GNUNET_PQ_Context *db) | ||
266 | { | ||
267 | struct GNUNET_DB_EventHeaderP e1 = { | ||
268 | .size = htons (sizeof (e1)), | ||
269 | .type = htons (1) | ||
270 | }; | ||
271 | struct GNUNET_DB_EventHeaderP e2 = { | ||
272 | .size = htons (sizeof (e2)), | ||
273 | .type = htons (2) | ||
274 | }; | ||
275 | unsigned int called = 0; | ||
276 | struct GNUNET_DB_EventHandler *eh; | ||
277 | |||
278 | eh = GNUNET_PQ_event_listen (db, | ||
279 | &e1, | ||
280 | &event_cb, | ||
281 | &called); | ||
282 | GNUNET_assert (NULL != eh); | ||
283 | GNUNET_PQ_event_notify (db, | ||
284 | &e2, | ||
285 | "hello", | ||
286 | 5); | ||
287 | GNUNET_PQ_event_do_poll (db); | ||
288 | GNUNET_assert (0 == called); | ||
289 | GNUNET_PQ_event_notify (db, | ||
290 | &e1, | ||
291 | "world", | ||
292 | 5); | ||
293 | GNUNET_PQ_event_do_poll (db); | ||
294 | GNUNET_assert (1 == called); | ||
295 | GNUNET_PQ_event_listen_cancel (eh); | ||
296 | return 0; | ||
297 | } | ||
298 | |||
299 | |||
300 | /** | 243 | /** |
301 | * Task called on shutdown. | 244 | * Task called on shutdown. |
302 | * | 245 | * |
@@ -305,7 +248,6 @@ test_notify (struct GNUNET_PQ_Context *db) | |||
305 | static void | 248 | static void |
306 | event_end (void *cls) | 249 | event_end (void *cls) |
307 | { | 250 | { |
308 | GNUNET_PQ_event_scheduler_stop (db); | ||
309 | GNUNET_PQ_event_listen_cancel (eh); | 251 | GNUNET_PQ_event_listen_cancel (eh); |
310 | eh = NULL; | 252 | eh = NULL; |
311 | if (NULL != tt) | 253 | if (NULL != tt) |
@@ -368,9 +310,9 @@ sched_tests (void *cls) | |||
368 | tt = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | 310 | tt = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
369 | &timeout_cb, | 311 | &timeout_cb, |
370 | NULL); | 312 | NULL); |
371 | GNUNET_PQ_event_scheduler_start (db); | ||
372 | eh = GNUNET_PQ_event_listen (db, | 313 | eh = GNUNET_PQ_event_listen (db, |
373 | &es, | 314 | &es, |
315 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
374 | &event_sched_cb, | 316 | &event_sched_cb, |
375 | NULL); | 317 | NULL); |
376 | GNUNET_PQ_reconnect (db); | 318 | GNUNET_PQ_reconnect (db); |
@@ -404,7 +346,7 @@ main (int argc, | |||
404 | }; | 346 | }; |
405 | 347 | ||
406 | GNUNET_log_setup ("test-pq", | 348 | GNUNET_log_setup ("test-pq", |
407 | "WARNING", | 349 | "INFO", |
408 | NULL); | 350 | NULL); |
409 | db = GNUNET_PQ_connect ("postgres:///gnunetcheck", | 351 | db = GNUNET_PQ_connect ("postgres:///gnunetcheck", |
410 | NULL, | 352 | NULL, |
@@ -433,8 +375,6 @@ main (int argc, | |||
433 | return 1; | 375 | return 1; |
434 | } | 376 | } |
435 | ret = run_queries (db); | 377 | ret = run_queries (db); |
436 | ret |= test_notify (db); | ||
437 | ret |= test_notify (db); | ||
438 | if (0 != ret) | 378 | if (0 != ret) |
439 | { | 379 | { |
440 | GNUNET_break (0); | 380 | GNUNET_break (0); |