#define DEBUG_CHAT_SERVICE GNUNET_EXTRA_LOGGING
#define MAX_TRANSMIT_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
#define EXPECTED_NEIGHBOUR_COUNT 16
-#define QUEUE_SIZE 16
#define MAX_ANONYMOUS_MSG_LIST_LENGTH 16
GNUNET_CONTAINER_multihashmap_create (EXPECTED_NEIGHBOUR_COUNT);
GNUNET_SERVER_add_handlers (server, handlers);
core =
- GNUNET_CORE_connect (cfg, QUEUE_SIZE, NULL, &core_init,
+ GNUNET_CORE_connect (cfg, NULL, &core_init,
&peer_connect_handler, &peer_disconnect_handler,
NULL, GNUNET_NO, NULL, GNUNET_NO, p2p_handlers);
GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL);
* 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
*/
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,
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;
/**
* 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?
* @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,
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);
}
(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);
}
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);
}
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);
}
"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 =
{
/* 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);
}
(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);
}
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);
}
¤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);
}
bucket_size = (unsigned int) temp_config_num;
atsAPI = GNUNET_ATS_performance_init (GDS_cfg, NULL, NULL);
coreAPI =
- GNUNET_CORE_connect (GDS_cfg, 1, NULL, &core_init, &handle_core_connect,
+ GNUNET_CORE_connect (GDS_cfg, NULL, &core_init, &handle_core_connect,
&handle_core_disconnect, NULL, GNUNET_NO, NULL,
GNUNET_NO, core_handlers);
if (coreAPI == NULL)
GNUNET_CONTAINER_multihashmap_create (max_table_size * 3);
GNUNET_SERVER_add_handlers (server, plugin_handlers);
- coreAPI = GNUNET_CORE_connect (cfg, 1, NULL, /* FIXME: anything we want to pass around? */
+ coreAPI = GNUNET_CORE_connect (cfg, NULL, /* FIXME: anything we want to pass around? */
&core_init, &handle_core_connect,
&handle_core_disconnect, NULL, GNUNET_NO, NULL,
GNUNET_NO, core_handlers);
* Connect to the receiving peer
*/
pos->peer2handle =
- GNUNET_CORE_connect (pos->peer2->cfg, 1, pos, &init_notify_peer2,
+ GNUNET_CORE_connect (pos->peer2->cfg, pos, &init_notify_peer2,
&connect_notify_peer2, NULL, NULL, GNUNET_YES,
NULL, GNUNET_YES, handlers);
}
* Connect to the sending peer
*/
pos->peer1handle =
- GNUNET_CORE_connect (pos->peer1->cfg, 1, pos, &init_notify_peer1,
+ GNUNET_CORE_connect (pos->peer1->cfg, pos, &init_notify_peer1,
&connect_notify_peer1, NULL, NULL, GNUNET_NO, NULL,
GNUNET_NO, no_handlers);
new_peer = GNUNET_malloc (sizeof (struct PeerContext));
new_peer->peer_handle =
- GNUNET_CORE_connect (cfg, 1, d, NULL, &all_connect_handler, NULL, NULL,
+ GNUNET_CORE_connect (cfg, d, NULL, &all_connect_handler, NULL, NULL,
GNUNET_NO, NULL, GNUNET_NO, no_handlers);
new_peer->daemon = d;
new_peer->next = all_peers;
};
GSF_core =
- GNUNET_CORE_connect (GSF_cfg, 1, NULL, &peer_init_handler,
+ GNUNET_CORE_connect (GSF_cfg, NULL, &peer_init_handler,
&peer_connect_handler, &GSF_peer_disconnect_handler_,
NULL, GNUNET_NO, NULL, GNUNET_NO, p2p_handlers);
if (NULL == GSF_core)
stats = GNUNET_STATISTICS_create ("hostlist", cfg);
core =
- GNUNET_CORE_connect (cfg, 1, NULL, &core_init, &connect_handler,
+ GNUNET_CORE_connect (cfg, NULL, &core_init, &connect_handler,
&disconnect_handler, NULL, GNUNET_NO, NULL,
GNUNET_NO,
learning ? learn_handlers : no_learn_handlers);
GNUNET_free (filename);
}
p->core =
- GNUNET_CORE_connect (p->cfg, 1, NULL, NULL, NULL, NULL, NULL, GNUNET_NO,
+ GNUNET_CORE_connect (p->cfg, NULL, NULL, NULL, NULL, NULL, GNUNET_NO,
NULL, GNUNET_NO, learn_handlers);
GNUNET_assert (NULL != p->core);
p->stats = GNUNET_STATISTICS_create ("hostlist", p->cfg);
/**
* Version number of GNUnet-core API.
*/
-#define GNUNET_CORE_VERSION 0x00000000
+#define GNUNET_CORE_VERSION 0x00000001
/**
* (or fail) asynchronously. This function primarily causes the given
* callback notification functions to be invoked whenever the
* specified event happens. The maximum number of queued
- * notifications (queue length) is per client but the queue is shared
+ * notifications (queue length) is per client; the queue is shared
* across all types of notifications. So a slow client that registers
* for 'outbound_notify' also risks missing 'inbound_notify' messages.
* Certain events (such as connect/disconnect notifications) are not
* subject to queue size limitations.
*
* @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
*/
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,
/**
* 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?
* @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;
- * will be called with NULL on timeout or if the overall queue
- * for this peer is larger than queue_size and this is currently
- * the message with the lowest priority; will also be called
- * with 'NULL' buf if the peer disconnects; since the disconnect
- * signal will be emmitted even later, clients MUST cancel
+ * will be called with NULL on timeout; clients MUST cancel
* all pending transmission requests DURING the disconnect
- * handler (unless they ensure that 'notify' never calls
- * 'GNUNET_CORE_notify_transmit_ready').
+ * 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,
&transport_notify_disconnect_cb);
GNUNET_assert (th != NULL);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Connected to transport service\n");
- ch = GNUNET_CORE_connect (cfg, 1, NULL,
+ ch = GNUNET_CORE_connect (cfg, NULL,
&core_init_cb,
&core_connect_cb,
&core_disconnect_cb,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "starting to run\n");
server_handle = server;
core_handle = GNUNET_CORE_connect (c, /* Main configuration */
- CORE_QUEUE_SIZE, /* queue size */
NULL, /* Closure passed to MESH functions */
&core_init, /* Call core_init once connected */
&core_connect, /* Handle connects */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "starting to run\n");
server_handle = server;
core_handle = GNUNET_CORE_connect (c, /* Main configuration */
- 1, /* queue size */
NULL, /* Closure passed to MESH functions */
&core_init, /* Call core_init once connected */
&core_connect, /* Handle connects */
nc = GNUNET_SERVER_notification_context_create (server, 1);
/* Connect to core service and register core handlers */
coreAPI = GNUNET_CORE_connect (cfg, /* Main configuration */
- 1, NULL, /* Closure passed to functions */
+ NULL, /* Closure passed to functions */
&core_init, /* Call core_init once connected */
&handle_core_connect, /* Handle connects */
&handle_core_disconnect, /* Handle disconnects */
* Connect to the receiving peer
*/
pos->peer2handle =
- GNUNET_CORE_connect (pos->peer2->cfg, 1, pos, &init_notify_peer2, NULL,
+ GNUNET_CORE_connect (pos->peer2->cfg, pos, &init_notify_peer2, NULL,
NULL, NULL, NULL, GNUNET_YES, NULL, GNUNET_YES,
handlers);
* Connect to the sending peer
*/
pos->peer1handle =
- GNUNET_CORE_connect (pos->peer1->cfg, 1, pos, &init_notify_peer1,
+ GNUNET_CORE_connect (pos->peer1->cfg, pos, &init_notify_peer1,
&connect_notify_peers, NULL, NULL, NULL, GNUNET_NO,
NULL, GNUNET_NO, no_handlers);
* Connect to the receiving peer
*/
pos->peer2handle =
- GNUNET_CORE_connect (pos->peer2->cfg, 1, pos, &init_notify_peer2, NULL,
+ GNUNET_CORE_connect (pos->peer2->cfg, pos, &init_notify_peer2, NULL,
NULL, NULL, GNUNET_YES, NULL, GNUNET_YES, handlers);
}
* Connect to the sending peer
*/
pos->peer1handle =
- GNUNET_CORE_connect (pos->peer1->cfg, 1, pos, &init_notify_peer1,
+ GNUNET_CORE_connect (pos->peer1->cfg, pos, &init_notify_peer1,
&connect_notify_peers, NULL, NULL, GNUNET_NO, NULL,
GNUNET_NO, no_handlers);
GNUNET_assert (ctx->d1core == NULL);
ctx->d1core_ready = GNUNET_NO;
ctx->d1core =
- GNUNET_CORE_connect (ctx->d1->cfg, 1, ctx, &core_init_notify,
+ GNUNET_CORE_connect (ctx->d1->cfg, ctx, &core_init_notify,
&connect_notify, NULL, NULL, GNUNET_NO, NULL,
GNUNET_NO, no_handlers);
if (ctx->d1core == NULL)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Peers are NOT connected, connecting to core!\n");
ctx->d1core =
- GNUNET_CORE_connect (ctx->d1->cfg, 1, ctx, &core_init_notify,
+ GNUNET_CORE_connect (ctx->d1->cfg, ctx, &core_init_notify,
&connect_notify, NULL, NULL, GNUNET_NO, NULL,
GNUNET_NO, no_handlers);
}
blacklist = GNUNET_TRANSPORT_blacklist (cfg, &blacklist_check, NULL);
transport = GNUNET_TRANSPORT_connect (cfg, NULL, NULL, NULL, NULL, NULL);
handle =
- GNUNET_CORE_connect (cfg, 1, NULL, &core_init, &connect_notify,
+ GNUNET_CORE_connect (cfg, NULL, &core_init, &connect_notify,
&disconnect_notify, NULL, GNUNET_NO, NULL, GNUNET_NO,
handlers);
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &cleaning_task,