From: Christian Grothoff Date: Sun, 6 May 2012 11:53:15 +0000 (+0000) Subject: -fixing #2302 X-Git-Tag: initial-import-from-subversion-38251~13656 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=5b4628337a35dac0fd34e51042b21db70dd39dee;p=oweals%2Fgnunet.git -fixing #2302 --- diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index cadb4d6c6..98844f830 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c @@ -775,10 +775,6 @@ clients_handle_address_to_string (void *cls, return; } GNUNET_SERVER_disable_receive_done_warning (client); - if ((NULL == address) || (0 == address_len)) - { - GNUNET_break_op (0); - } papi->address_pretty_printer (papi->cls, plugin_name, address, address_len, numeric, rtimeout, &transmit_address_to_client, tc); diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c index 6ef273c45..ee23189a8 100644 --- a/src/transport/gnunet-transport.c +++ b/src/transport/gnunet-transport.c @@ -454,7 +454,8 @@ struct ResolutionContext int printed; }; -void + +static void process_string (void *cls, const char *address) { struct ResolutionContext *rc = cls; diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index 4f9279495..de616173e 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c @@ -212,6 +212,12 @@ http_plugin_address_pretty_printer (void *cls, const char *type, sbs = sizeof (struct sockaddr_in); port = ntohs (a4->u4_port); } + else if (0 == addrlen) + { + asc (asc_cls, ""); + asc (asc_cls, NULL); + return; + } else { /* invalid address */ diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index ec4bbfc5e..0c1b8a056 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c @@ -1507,11 +1507,15 @@ tcp_plugin_address_pretty_printer (void *cls, const char *type, sb = &a4; sbs = sizeof (a4); } + else if (0 == addrlen) + { + asc (asc_cls, ""); + asc (asc_cls, NULL); + return; + } else { /* invalid address */ - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "tcp", - "Invalid address to string request: plugin `%s', address length: %u bytes\n"); GNUNET_break_op (0); asc (asc_cls, NULL); return; diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index 9e28f00d4..ec6e52236 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c @@ -514,6 +514,12 @@ udp_plugin_address_pretty_printer (void *cls, const char *type, sb = &a4; sbs = sizeof (a4); } + else if (0 == addrlen) + { + asc (asc_cls, ""); + asc (asc_cls, NULL); + return; + } else { /* invalid address */ diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c index 1f39f1d40..a858b9a2d 100644 --- a/src/transport/plugin_transport_unix.c +++ b/src/transport/plugin_transport_unix.c @@ -185,12 +185,7 @@ struct Plugin */ struct GNUNET_TRANSPORT_PluginEnvironment *env; - /* - * Session of peers with whom we are currently connected - */ - struct PeerSession *sessions; - - /* + /** * Sessions */ struct GNUNET_CONTAINER_MultiHashMap *session_map; @@ -243,9 +238,11 @@ struct Plugin unsigned int bytes_in_queue; }; + static void unix_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); + static void reschedule_select (struct Plugin * plugin) { @@ -320,6 +317,7 @@ get_session_delete_it (void *cls, const GNUNET_HashCode * key, void *value) return GNUNET_YES; } + /** * Disconnect from a remote node. Clean up session if we have one for this peer * @@ -327,7 +325,7 @@ get_session_delete_it (void *cls, const GNUNET_HashCode * key, void *value) * @param target the peeridentity of the peer to disconnect * @return GNUNET_OK on success, GNUNET_SYSERR if the operation failed */ -void +static void unix_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) { struct Plugin *plugin = cls; @@ -379,23 +377,6 @@ unix_transport_server_stop (void *cls) } -struct PeerSession * -find_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *peer) -{ - struct PeerSession *pos; - - pos = plugin->sessions; - while (pos != NULL) - { - if (memcmp (&pos->target, peer, sizeof (struct GNUNET_PeerIdentity)) == 0) - return pos; - pos = pos->next; - } - - return pos; -} - - /** * Actually send out the message, assume we've got the address and * send_handle squared away! @@ -563,6 +544,7 @@ struct gsi_ctx struct Session *res; }; + static int get_session_it (void *cls, const GNUNET_HashCode * key, void *value) { @@ -824,6 +806,7 @@ unix_plugin_select_read (struct Plugin * plugin) } } + static void unix_plugin_select_write (struct Plugin * plugin) { @@ -891,14 +874,14 @@ unix_plugin_select_write (struct Plugin * plugin) } -/* - * @param cls the plugin handle - * @param tc the scheduling context (for rescheduling this function again) - * + +/** * We have been notified that our writeset has something to read. We don't * know which socket needs to be read, so we have to check each one * Then reschedule this function to be called again once more is available. * + * @param cls the plugin handle + * @param tc the scheduling context (for rescheduling this function again) */ static void unix_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) @@ -929,12 +912,13 @@ unix_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) reschedule_select (plugin); } + /** * Create a slew of UNIX sockets. If possible, use IPv6 and IPv4. * * @param cls closure for server start, should be a struct Plugin * * @return number of sockets created or GNUNET_SYSERR on error -*/ + */ static int unix_transport_server_start (void *cls) { @@ -1041,16 +1025,19 @@ unix_plugin_address_pretty_printer (void *cls, const char *type, GNUNET_TRANSPORT_AddressStringCallback asc, void *asc_cls) { - if ((addr != NULL) && (addrlen > 0)) + if ((NULL != addr) && (addrlen > 0)) + { asc (asc_cls, (const char *) addr); + } else { GNUNET_break (0); - asc (asc_cls, "Invalid UNIX address"); + asc (asc_cls, ""); } - + asc (asc_cls, NULL); } + /** * Function called to convert a string address to * a binary address. @@ -1063,11 +1050,11 @@ unix_plugin_address_pretty_printer (void *cls, const char *type, * @param added length of created address * @return GNUNET_OK on success, GNUNET_SYSERR on failure */ -int +static int unix_string_to_address (void *cls, const char *addr, uint16_t addrlen, void **buf, size_t *added) { - if ((NULL == addr) || (addrlen == 0)) + if ((NULL == addr) || (0 == addrlen)) { GNUNET_break (0); return GNUNET_SYSERR; @@ -1091,8 +1078,6 @@ unix_string_to_address (void *cls, const char *addr, uint16_t addrlen, } - - /** * Function called for a quick conversion of the binary address to * a numeric address. Note that the caller must not free the @@ -1109,10 +1094,10 @@ unix_address_to_string (void *cls, const void *addr, size_t addrlen) { if ((addr != NULL) && (addrlen > 0)) return (const char *) addr; - else - return NULL; + return NULL; } + /** * Notify transport service about address * diff --git a/src/transport/transport_api_address_to_string.c b/src/transport/transport_api_address_to_string.c index 237c0b657..152e573cd 100644 --- a/src/transport/transport_api_address_to_string.c +++ b/src/transport/transport_api_address_to_string.c @@ -141,9 +141,8 @@ GNUNET_TRANSPORT_address_to_string (const struct GNUNET_CONFIGURATION_Handle GNUNET_break (0); return NULL; } - client = GNUNET_CLIENT_connect ("transport", cfg); - if (client == NULL) + if (NULL == client) return NULL; msg = GNUNET_malloc (len); msg->header.size = htons (len);