[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r35288 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r35288 - gnunet/src/transport |
Date: |
Sat, 21 Feb 2015 00:01:47 +0100 |
Author: grothoff
Date: 2015-02-21 00:01:47 +0100 (Sat, 21 Feb 2015)
New Revision: 35288
Modified:
gnunet/src/transport/plugin_transport_tcp.c
Log:
trying to fix #3687/3683/3684 by avoiding server's client reference counting
(GNUNET_SERVER_client_keep) which should not be needed in the first place
Modified: gnunet/src/transport/plugin_transport_tcp.c
===================================================================
--- gnunet/src/transport/plugin_transport_tcp.c 2015-02-20 12:46:17 UTC (rev
35287)
+++ gnunet/src/transport/plugin_transport_tcp.c 2015-02-20 23:01:47 UTC (rev
35288)
@@ -754,7 +754,7 @@
address[0] = '\0';
address++;
- if (GNUNET_OK !=
+ if (GNUNET_OK !=
GNUNET_STRINGS_to_address_ip (address,
strlen (address),
&socket_address))
@@ -811,7 +811,8 @@
lookup_session_by_client (struct Plugin *plugin,
struct GNUNET_SERVER_Client *client)
{
- return GNUNET_SERVER_client_get_user_context (client, struct Session);
+ return GNUNET_SERVER_client_get_user_context (client,
+ struct Session);
}
@@ -851,7 +852,7 @@
session))
{
GNUNET_STATISTICS_update (session->plugin->env->stats,
- gettext_noop ("# TCP sessions active"),
+ gettext_noop ("# TCP sessions active"),
-1,
GNUNET_NO);
}
@@ -929,12 +930,11 @@
if (NULL != session->client)
{
GNUNET_SERVER_client_disconnect (session->client);
- GNUNET_SERVER_client_drop (session->client);
session->client = NULL;
}
GNUNET_HELLO_address_free (session->address);
- GNUNET_assert(NULL == session->transmit_handle);
- GNUNET_free(session);
+ GNUNET_assert (NULL == session->transmit_handle);
+ GNUNET_free (session);
return GNUNET_OK;
}
@@ -987,7 +987,7 @@
GNUNET_STRINGS_relative_time_to_string
(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
GNUNET_YES));
/* call session destroy function */
- tcp_plugin_disconnect_session (s->plugin,
+ tcp_plugin_disconnect_session (s->plugin,
s);
}
@@ -1010,6 +1010,7 @@
*
* @param plugin the plugin
* @param address the address to create the session for
+ * @param scope network scope the address is from
* @param client client to use, reference counter must have already been
increased
* @param is_nat this a NAT session, we should wait for a client to
* connect to us from an address, then assign that to
@@ -1019,6 +1020,7 @@
static struct Session *
create_session (struct Plugin *plugin,
const struct GNUNET_HELLO_Address *address,
+ enum GNUNET_ATS_Network_Type scope,
struct GNUNET_SERVER_Client *client,
int is_nat)
{
@@ -1040,7 +1042,12 @@
session->last_activity = GNUNET_TIME_absolute_get ();
session->plugin = plugin;
session->is_nat = is_nat;
- session->client = client;
+ if (NULL != client)
+ {
+ session->client = client;
+ GNUNET_SERVER_client_set_user_context (client,
+ session);
+ }
session->address = GNUNET_HELLO_address_copy (address);
session->target = address->peer;
session->expecting_welcome = GNUNET_YES;
@@ -1111,7 +1118,7 @@
* @return number of bytes written to @a buf
*/
static size_t
-do_transmit (void *cls,
+do_transmit (void *cls,
size_t size,
void *buf)
{
@@ -1503,7 +1510,7 @@
session->receive_delay_task = NULL;
reschedule_session_timeout (session);
- GNUNET_SERVER_receive_done (session->client,
+ GNUNET_SERVER_receive_done (session->client,
GNUNET_OK);
}
@@ -1595,7 +1602,7 @@
si_ctx.result = NULL;
GNUNET_CONTAINER_multipeermap_get_multiple (plugin->sessionmap,
&address->peer,
- &session_lookup_it,
+ &session_lookup_it,
&si_ctx);
if (NULL != si_ctx.result)
{
@@ -1660,7 +1667,7 @@
sbs);
GNUNET_break (net_type != GNUNET_ATS_NET_UNSPECIFIED);
- if ( (is_natd == GNUNET_YES) &&
+ if ( (is_natd == GNUNET_YES) &&
(addrlen == sizeof(struct IPv6TcpAddress)) )
{
/* NAT client only works with IPv4 addresses */
@@ -1674,7 +1681,7 @@
}
if ( (is_natd == GNUNET_YES) &&
- (GNUNET_YES ==
+ (GNUNET_YES ==
GNUNET_CONTAINER_multipeermap_contains (plugin->nat_wait_conns,
&address->peer)))
{
@@ -1692,17 +1699,17 @@
"Found valid IPv4 NAT address (creating session)!\n");
session = create_session (plugin,
address,
+ net_type,
NULL,
GNUNET_YES);
- session->scope = net_type;
session->nat_connection_timeout = GNUNET_SCHEDULER_add_delayed
(NAT_TIMEOUT,
&nat_connect_timeout,
session);
- GNUNET_assert(GNUNET_OK ==
- GNUNET_CONTAINER_multipeermap_put (plugin->nat_wait_conns,
- &session->target,
- session,
-
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CONTAINER_multipeermap_put (plugin->nat_wait_conns,
+ &session->target,
+ session,
+
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Created NAT WAIT connection to `%4s' at `%s'\n",
@@ -1783,15 +1790,14 @@
session = create_session (plugin,
address,
- GNUNET_SERVER_connect_socket (plugin->server, sa),
+ net_type,
+ GNUNET_SERVER_connect_socket (plugin->server,
+ sa),
GNUNET_NO);
- session->scope = net_type;
- GNUNET_SERVER_client_set_user_context (session->client,
- session);
- GNUNET_CONTAINER_multipeermap_put (plugin->sessionmap,
- &session->target,
- session,
-
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+ (void) GNUNET_CONTAINER_multipeermap_put (plugin->sessionmap,
+ &session->target,
+ session,
+
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
/* Send TCP Welcome */
process_pending_messages (session);
@@ -1808,7 +1814,7 @@
* @param key the peer which the session belongs to (unused)
* @param value the `struct Session`
* @return #GNUNET_YES (continue to iterate)
- */
+ */
static int
session_disconnect_it (void *cls,
const struct GNUNET_PeerIdentity *key,
@@ -2018,10 +2024,10 @@
* @return #GNUNET_OK if port is either open_port or adv_port
*/
static int
-check_port (struct Plugin *plugin,
+check_port (struct Plugin *plugin,
uint16_t in_port)
{
- if ( (in_port == plugin->adv_port) ||
+ if ( (in_port == plugin->adv_port) ||
(in_port == plugin->open_port) )
return GNUNET_OK;
return GNUNET_SYSERR;
@@ -2044,7 +2050,7 @@
* and transport, #GNUNET_SYSERR if not
*/
static int
-tcp_plugin_check_address (void *cls,
+tcp_plugin_check_address (void *cls,
const void *addr,
size_t addrlen)
{
@@ -2093,10 +2099,10 @@
GNUNET_break (0);
return GNUNET_SYSERR;
}
- if (GNUNET_OK != check_port (plugin,
+ if (GNUNET_OK != check_port (plugin,
ntohs (v6->t6_port)))
return GNUNET_SYSERR;
- if (GNUNET_OK !=
+ if (GNUNET_OK !=
GNUNET_NAT_test_address (plugin->nat,
&v6->ipv6_addr,
sizeof(struct in6_addr)))
@@ -2172,13 +2178,13 @@
session->nat_connection_timeout = NULL;
}
- if (GNUNET_OK !=
- GNUNET_SERVER_client_get_address (client,
+ if (GNUNET_OK !=
+ GNUNET_SERVER_client_get_address (client,
&vaddr,
&alen))
{
GNUNET_break(0);
- GNUNET_SERVER_receive_done (client,
+ GNUNET_SERVER_receive_done (client,
GNUNET_SYSERR);
tcp_plugin_disconnect_session (plugin,
session);
@@ -2186,13 +2192,13 @@
}
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multipeermap_remove (plugin->nat_wait_conns,
-
&tcp_nat_probe->clientIdentity,
+
&tcp_nat_probe->clientIdentity,
session));
GNUNET_SERVER_client_set_user_context (client,
session);
(void) GNUNET_CONTAINER_multipeermap_put (plugin->sessionmap,
&session->target,
- session,
+ session,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
session->last_activity = GNUNET_TIME_absolute_get ();
LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -2236,14 +2242,13 @@
}
GNUNET_free (vaddr);
GNUNET_break (NULL == session->client);
- GNUNET_SERVER_client_keep (client);
session->client = client;
GNUNET_STATISTICS_update (plugin->env->stats,
gettext_noop ("# TCP sessions active"),
- 1,
+ 1,
GNUNET_NO);
process_pending_messages (session);
- GNUNET_SERVER_receive_done (client,
+ GNUNET_SERVER_receive_done (client,
GNUNET_OK);
}
@@ -2316,7 +2321,6 @@
}
else
{
- GNUNET_SERVER_client_keep (client);
if (GNUNET_OK ==
GNUNET_SERVER_client_get_address (client, &vaddr, &alen))
{
@@ -2354,13 +2358,12 @@
}
session = create_session (plugin,
address,
+ plugin->env->get_address_type
(plugin->env->cls,
+ vaddr,
+ alen),
client,
GNUNET_NO);
GNUNET_HELLO_address_free (address);
- session->scope
- = plugin->env->get_address_type (plugin->env->cls,
- vaddr,
- alen);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Creating new%s session %p for peer `%s' client %p\n",
GNUNET_HELLO_address_check_option (session->address,
@@ -2372,11 +2375,10 @@
session->address->address_length),
client);
GNUNET_free (vaddr);
- GNUNET_SERVER_client_set_user_context (session->client, session);
- GNUNET_CONTAINER_multipeermap_put (plugin->sessionmap,
- &session->target,
- session,
-
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+ (void) GNUNET_CONTAINER_multipeermap_put (plugin->sessionmap,
+ &session->target,
+ session,
+
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
/* Notify transport and ATS about new session */
plugin->env->session_start (plugin->env->cls,
session->address,
@@ -2407,7 +2409,7 @@
process_pending_messages (session);
GNUNET_SERVER_client_set_timeout (client,
- GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
+ GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
@@ -2585,7 +2587,7 @@
gettext_noop ("# network-level TCP disconnect
events"),
1,
GNUNET_NO);
- tcp_plugin_disconnect_session (plugin,
+ tcp_plugin_disconnect_session (plugin,
session);
}
@@ -2618,8 +2620,8 @@
return 0;
}
GNUNET_assert(size >= sizeof(tcp_probe_ctx->message));
- memcpy (buf,
- &tcp_probe_ctx->message,
+ memcpy (buf,
+ &tcp_probe_ctx->message,
sizeof(tcp_probe_ctx->message));
GNUNET_SERVER_connect_socket (tcp_probe_ctx->plugin->server,
tcp_probe_ctx->sock);
@@ -2651,7 +2653,7 @@
* We have received an ICMP response, ostensibly from a peer
* that wants to connect to us! Send a message to establish a connection.
*/
- sock = GNUNET_CONNECTION_create_from_sockaddr (AF_INET,
+ sock = GNUNET_CONNECTION_create_from_sockaddr (AF_INET,
addr,
addrlen);
if (NULL == sock)
@@ -2976,9 +2978,9 @@
}
plugin->server
= GNUNET_SERVER_create_with_sockets (NULL,
- plugin,
+ plugin,
NULL,
- idle_timeout,
+ idle_timeout,
GNUNET_YES);
}
plugin->handlers = GNUNET_malloc (sizeof (my_handlers));
@@ -3067,7 +3069,7 @@
cur);
GNUNET_RESOLVER_request_cancel (cur->resolver_handle);
cur->asc (cur->asc_cls,
- NULL,
+ NULL,
GNUNET_OK);
GNUNET_free (cur);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r35288 - gnunet/src/transport,
gnunet <=