diff options
author | grothoff <grothoff@140774ce-b5e7-0310-ab8b-a85725594a96> | 2012-06-09 14:53:44 +0000 |
---|---|---|
committer | grothoff <grothoff@140774ce-b5e7-0310-ab8b-a85725594a96> | 2012-06-09 14:53:44 +0000 |
commit | 29b0ccdefe35bd9d5ea8856328ef288030a65594 (patch) | |
tree | adb1da7611b0afd6ff0fa094a6f6bc7ebabd174e /src/core | |
parent | 3acc63504fe636a6e61b1b2ab36548ac5bf90d04 (diff) |
-simplifying core API (#2400)
git-svn-id: https://gnunet.org/svn/gnunet@21816 140774ce-b5e7-0310-ab8b-a85725594a96
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/core_api.c | 22 | ||||
-rw-r--r-- | src/core/test_core_api.c | 4 | ||||
-rw-r--r-- | src/core/test_core_api_reliability.c | 4 | ||||
-rw-r--r-- | src/core/test_core_api_send_to_self.c | 2 | ||||
-rw-r--r-- | src/core/test_core_api_start_only.c | 4 | ||||
-rw-r--r-- | src/core/test_core_quota_compliance.c | 4 |
6 files changed, 23 insertions, 17 deletions
diff --git a/src/core/core_api.c b/src/core/core_api.c index 526dc9fffd..2b6407b6e8 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c @@ -1158,7 +1158,6 @@ reconnect (struct GNUNET_CORE_Handle *h) * complete (or fail) asynchronously. * * @param cfg configuration to use - * @param queue_size size of the per-peer message queue * @param cls closure for the various callbacks that follow (including handlers in the handlers array) * @param init callback to call once we have successfully * connected to the core service @@ -1178,7 +1177,7 @@ reconnect (struct GNUNET_CORE_Handle *h) */ struct GNUNET_CORE_Handle * GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, - unsigned int queue_size, void *cls, + void *cls, GNUNET_CORE_StartupCallback init, GNUNET_CORE_ConnectEventHandler connects, GNUNET_CORE_DisconnectEventHandler disconnects, @@ -1192,7 +1191,7 @@ GNUNET_CORE_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, h = GNUNET_malloc (sizeof (struct GNUNET_CORE_Handle)); h->cfg = cfg; - h->queue_size = queue_size; + h->queue_size = 1; // FIXME: remove entirely... h->cls = cls; h->init = init; h->connects = connects; @@ -1285,9 +1284,13 @@ run_request_next_transmission (void *cls, /** * Ask the core to call "notify" once it is ready to transmit the - * given number of bytes to the specified "target". Must only be + * given number of bytes to the specified "target". Must only be * called after a connection to the respective peer has been - * established (and the client has been informed about this). + * established (and the client has been informed about this). You may + * have one request of this type pending for each connected peer at + * any time. If a peer disconnects, the application MUST call + * "GNUNET_CORE_notify_transmit_ready_cancel" on the respective + * transmission request, if one such request is pending. * * @param handle connection to core service * @param cork is corking allowed for this transmission? @@ -1295,11 +1298,14 @@ run_request_next_transmission (void *cls, * @param maxdelay how long can the message wait? * @param target who should receive the message, never NULL (can be this peer's identity for loopback) * @param notify_size how many bytes of buffer space does notify want? - * @param notify function to call when buffer space is available + * @param notify function to call when buffer space is available; + * will be called with NULL on timeout; clients MUST cancel + * all pending transmission requests DURING the disconnect + * handler * @param notify_cls closure for notify * @return non-NULL if the notify callback was queued, - * NULL if we can not even queue the request (insufficient - * memory); if NULL is returned, "notify" will NOT be called. + * NULL if we can not even queue the request (request already pending); + * if NULL is returned, "notify" will NOT be called. */ struct GNUNET_CORE_TransmitHandle * GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle, int cork, diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c index 37d1669834..d1591328fc 100644 --- a/src/core/test_core_api.c +++ b/src/core/test_core_api.c @@ -299,7 +299,7 @@ init_notify (void *cls, struct GNUNET_CORE_Handle *server, OKPP; /* connect p2 */ p2.ch = - GNUNET_CORE_connect (p2.cfg, 1, &p2, &init_notify, &connect_notify, + GNUNET_CORE_connect (p2.cfg, &p2, &init_notify, &connect_notify, &disconnect_notify, &inbound_notify, GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); } @@ -346,7 +346,7 @@ run (void *cls, char *const *args, const char *cfgfile, (GNUNET_TIME_UNIT_SECONDS, 300), &terminate_task_error, NULL); p1.ch = - GNUNET_CORE_connect (p1.cfg, 1, &p1, &init_notify, &connect_notify, + GNUNET_CORE_connect (p1.cfg, &p1, &init_notify, &connect_notify, &disconnect_notify, &inbound_notify, GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); } diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c index e18d8c4fd2..682424f89b 100644 --- a/src/core/test_core_api_reliability.c +++ b/src/core/test_core_api_reliability.c @@ -384,7 +384,7 @@ init_notify (void *cls, struct GNUNET_CORE_Handle *server, GNUNET_assert (ok == 2); OKPP; /* connect p2 */ - GNUNET_CORE_connect (p2.cfg, 1, &p2, &init_notify, &connect_notify, + GNUNET_CORE_connect (p2.cfg, &p2, &init_notify, &connect_notify, &disconnect_notify, &inbound_notify, GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); } @@ -450,7 +450,7 @@ run (void *cls, char *const *args, const char *cfgfile, setup_peer (&p2, "test_core_api_peer2.conf"); err_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &terminate_task_error, NULL); - GNUNET_CORE_connect (p1.cfg, 1, &p1, &init_notify, &connect_notify, + GNUNET_CORE_connect (p1.cfg, &p1, &init_notify, &connect_notify, &disconnect_notify, &inbound_notify, GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); } diff --git a/src/core/test_core_api_send_to_self.c b/src/core/test_core_api_send_to_self.c index b1340dcfb7..3827cdb77b 100644 --- a/src/core/test_core_api_send_to_self.c +++ b/src/core/test_core_api_send_to_self.c @@ -182,7 +182,7 @@ run (void *cls, char *const *args, const char *cfgfile, "test_core_api_peer1.conf")); core = - GNUNET_CORE_connect (core_cfg, 42, NULL, &init, &connect_cb, NULL, NULL, + GNUNET_CORE_connect (core_cfg, NULL, &init, &connect_cb, NULL, NULL, 0, NULL, 0, handlers); die_task = diff --git a/src/core/test_core_api_start_only.c b/src/core/test_core_api_start_only.c index 8c8132043d..308814b219 100644 --- a/src/core/test_core_api_start_only.c +++ b/src/core/test_core_api_start_only.c @@ -129,7 +129,7 @@ init_notify (void *cls, struct GNUNET_CORE_Handle *server, { /* connect p2 */ p2.ch = - GNUNET_CORE_connect (p2.cfg, 1, &p2, &init_notify, &connect_notify, + GNUNET_CORE_connect (p2.cfg, &p2, &init_notify, &connect_notify, &disconnect_notify, &inbound_notify, GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); } @@ -191,7 +191,7 @@ run (void *cls, char *const *args, const char *cfgfile, (GNUNET_TIME_UNIT_MINUTES, TIMEOUT), &timeout_task, NULL); p1.ch = - GNUNET_CORE_connect (p1.cfg, 1, &p1, &init_notify, &connect_notify, + GNUNET_CORE_connect (p1.cfg, &p1, &init_notify, &connect_notify, &disconnect_notify, &inbound_notify, GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); } diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c index df602b37f4..bee8c02b45 100644 --- a/src/core/test_core_quota_compliance.c +++ b/src/core/test_core_quota_compliance.c @@ -527,7 +527,7 @@ init_notify (void *cls, struct GNUNET_CORE_Handle *server, OKPP; /* connect p2 */ p2.ch = - GNUNET_CORE_connect (p2.cfg, 1, &p2, &init_notify, &connect_notify, + GNUNET_CORE_connect (p2.cfg, &p2, &init_notify, &connect_notify, &disconnect_notify, &inbound_notify, GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); } @@ -629,7 +629,7 @@ run (void *cls, char *const *args, const char *cfgfile, ¤t_quota_p2_out)); p1.ch = - GNUNET_CORE_connect (p1.cfg, 1, &p1, &init_notify, &connect_notify, + GNUNET_CORE_connect (p1.cfg, &p1, &init_notify, &connect_notify, &disconnect_notify, &inbound_notify, GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); } |