* @param window_changes Function called when the transmit window size changes.
* @param disconnects Function called when a channel is disconnected.
* @param handlers Callbacks for messages we care about, NULL-terminated.
- * @return Port handle.
+ * @return Port handle, NULL if port is in use
*/
struct GNUNET_CADET_Port *
GNUNET_CADET_open_port (struct GNUNET_CADET_Handle *h,
p = GNUNET_new (struct GNUNET_CADET_Port);
p->cadet = h;
p->id = *port;
+ if (GNUNET_OK !=
+ GNUNET_CONTAINER_multihashmap_put (h->ports,
+ &p->id,
+ p,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
+ {
+ GNUNET_free (p);
+ return NULL;
+ }
p->connects = connects;
p->cls = connects_cls;
p->window_changes = window_changes;
p->disconnects = disconnects;
p->handlers = GNUNET_MQ_copy_handlers (handlers);
- GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_multihashmap_put (h->ports,
- &p->id,
- p,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
env = GNUNET_MQ_msg (msg,
GNUNET_MESSAGE_TYPE_CADET_LOCAL_PORT_OPEN);
NULL,
&inbound_end,
cadet_handlers);
+ if (NULL == line->port)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _("Could not open line, port %s already in use!\n"),
+ GNUNET_h2s (&msg->line_port));
+ GNUNET_SERVICE_client_drop (line->client);
+ return;
+ }
GNUNET_SERVICE_client_continue (line->client);
}
* Can be NULL.
* @param disconnects Function called when a channel is disconnected.
* @param handlers Callbacks for messages we care about, NULL-terminated.
- * @return Port handle.
+ * @return Port handle, NULL if port is in use
*/
struct GNUNET_CADET_Port *
GNUNET_CADET_open_port (struct GNUNET_CADET_Handle *h,
* @return #GNUNET_SYSERR on error, #GNUNET_OK on success
*/
int
-GNUNET_DISK_file_size (const char *filename, uint64_t *size,
+GNUNET_DISK_file_size (const char *filename,
+ uint64_t *size,
int include_symbolic_links,
int single_file_mode);