[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r34737 - in gnunet/src: include transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r34737 - in gnunet/src: include transport |
Date: |
Sat, 20 Dec 2014 14:52:02 +0100 |
Author: grothoff
Date: 2014-12-20 14:52:02 +0100 (Sat, 20 Dec 2014)
New Revision: 34737
Modified:
gnunet/src/include/gnunet_server_lib.h
gnunet/src/transport/gnunet-service-transport_clients.c
gnunet/src/transport/transport.h
Log:
-eliminate duplicate all_zeros globals, eliminated dead 'latency' field in
SendOKMessage
Modified: gnunet/src/include/gnunet_server_lib.h
===================================================================
--- gnunet/src/include/gnunet_server_lib.h 2014-12-20 13:24:45 UTC (rev
34736)
+++ gnunet/src/include/gnunet_server_lib.h 2014-12-20 13:52:02 UTC (rev
34737)
@@ -78,10 +78,10 @@
* @param client identification of the client
* @param message the actual message
*/
-typedef void (*GNUNET_SERVER_MessageCallback) (void *cls,
- struct GNUNET_SERVER_Client
*client,
- const struct
GNUNET_MessageHeader
- *message);
+typedef void
+(*GNUNET_SERVER_MessageCallback) (void *cls,
+ struct GNUNET_SERVER_Client *client,
+ const struct GNUNET_MessageHeader *message);
/**
Modified: gnunet/src/transport/gnunet-service-transport_clients.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_clients.c 2014-12-20
13:24:45 UTC (rev 34736)
+++ gnunet/src/transport/gnunet-service-transport_clients.c 2014-12-20
13:52:02 UTC (rev 34737)
@@ -233,9 +233,15 @@
*/
static struct GNUNET_SERVER_Client *sync_client;
+/**
+ * Peer identity that is all zeros, used as a way to indicate
+ * "all peers". Used for comparissons.
+ */
+static struct GNUNET_PeerIdentity all_zeros;
+
/**
- * Find the internal handle associated with the given client handle
+ * Find the internal handle associated with the given client handle.
*
* @param client server's client handle to look up
* @return internal client handle
@@ -243,17 +249,13 @@
static struct TransportClient *
lookup_client (struct GNUNET_SERVER_Client *client)
{
- struct TransportClient *tc;
-
- for (tc = clients_head; NULL != tc; tc = tc->next)
- if (tc->client == client)
- return tc;
- return NULL;
+ return GNUNET_SERVER_client_get_user_context (client,
+ struct TransportClient);
}
/**
- * Create the internal handle for the given server client handle
+ * Create the internal handle for the given server client handle.
*
* @param client server's client handle to create our internal handle for
* @return fresh internal client handle
@@ -266,6 +268,10 @@
GNUNET_assert (NULL == lookup_client (client));
tc = GNUNET_new (struct TransportClient);
tc->client = client;
+ GNUNET_SERVER_client_set_user_context (client, tc);
+ GNUNET_CONTAINER_DLL_insert (clients_head,
+ clients_tail,
+ tc);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Client %p connected\n",
tc);
@@ -275,7 +281,7 @@
/**
* Find the handle to the monitoring client associated with the given
- * client handle
+ * client handle.
*
* @param head the head of the client queue to look in
* @param client server's client handle to look up
@@ -308,7 +314,6 @@
const struct GNUNET_PeerIdentity *peer)
{
struct MonitoringClient *mc;
- static struct GNUNET_PeerIdentity all_zeros;
GNUNET_assert (NULL ==
lookup_monitoring_client (peer_monitoring_clients_head,
@@ -320,15 +325,17 @@
peer_monitoring_clients_tail,
mc);
GNUNET_SERVER_client_mark_monitor (client);
- GNUNET_SERVER_notification_context_add (peer_nc, client);
-
- if (0 != memcmp (peer, &all_zeros, sizeof (struct GNUNET_PeerIdentity)))
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ GNUNET_SERVER_notification_context_add (peer_nc,
+ client);
+ if (0 != memcmp (peer,
+ &all_zeros,
+ sizeof (struct GNUNET_PeerIdentity)))
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Client %p started monitoring of the peer `%s'\n",
mc,
GNUNET_i2s (peer));
else
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Client %p started monitoring all peers\n",
mc);
return mc;
@@ -349,7 +356,6 @@
struct GNUNET_PeerIdentity *peer)
{
struct MonitoringClient *mc;
- static struct GNUNET_PeerIdentity all_zeros;
GNUNET_assert (NULL ==
lookup_monitoring_client (val_monitoring_clients_head,
@@ -365,19 +371,19 @@
if (0 != memcmp (peer,
&all_zeros,
sizeof (struct GNUNET_PeerIdentity)))
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Client %p started monitoring of the peer `%s'\n",
mc, GNUNET_i2s (peer));
else
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Client %p started monitoring all peers\n", mc);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Client %p started monitoring all peers\n", mc);
return mc;
}
/**
* Function called to notify a client about the socket being ready to
- * queue more data. "buf" will be NULL and "size" zero if the socket
+ * queue more data. @a buf will be NULL and @a size zero if the socket
* was closed for writing in the meantime.
*
* @param cls closure
@@ -414,7 +420,8 @@
break;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Transmitting message of type %u to client %p.\n",
- ntohs (msg->type), tc);
+ ntohs (msg->type),
+ tc);
GNUNET_CONTAINER_DLL_remove (tc->message_queue_head,
tc->message_queue_tail,
q);
@@ -456,8 +463,8 @@
GNUNET_break (0);
return;
}
-
- if ((tc->message_count >= MAX_PENDING) && (GNUNET_YES == may_drop))
+ if ( (tc->message_count >= MAX_PENDING) &&
+ (GNUNET_YES == may_drop) )
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_("Dropping message of type %u and size %u, have %u/%u
messages pending\n"),
@@ -476,7 +483,8 @@
q = GNUNET_malloc (sizeof (struct ClientMessageQueueEntry) + msize);
memcpy (&q[1], msg, msize);
GNUNET_CONTAINER_DLL_insert_tail (tc->message_queue_head,
- tc->message_queue_tail, q);
+ tc->message_queue_tail,
+ q);
tc->message_count++;
if (NULL != tc->th)
return;
@@ -492,7 +500,7 @@
* Called whenever a client is disconnected. Frees our
* resources associated with that client.
*
- * @param cls closure
+ * @param cls closure, NULL
* @param client identification of the client
*/
static void
@@ -503,11 +511,11 @@
struct MonitoringClient *mc;
struct ClientMessageQueueEntry *mqe;
- if (client == NULL)
+ if (NULL == client)
return;
mc = lookup_monitoring_client (peer_monitoring_clients_head,
client);
- if (mc != NULL)
+ if (NULL != mc)
{
GNUNET_CONTAINER_DLL_remove (peer_monitoring_clients_head,
peer_monitoring_clients_tail,
@@ -516,7 +524,7 @@
}
mc = lookup_monitoring_client (val_monitoring_clients_head,
client);
- if (mc != NULL)
+ if (NULL != mc)
{
GNUNET_CONTAINER_DLL_remove (val_monitoring_clients_head,
val_monitoring_clients_tail,
@@ -524,7 +532,7 @@
GNUNET_free (mc);
}
tc = lookup_client (client);
- if (tc == NULL)
+ if (NULL == tc)
return;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
"Client %p disconnected, cleaning up.\n", tc);
@@ -536,7 +544,8 @@
GNUNET_free (mqe);
}
GNUNET_CONTAINER_DLL_remove (clients_head, clients_tail, tc);
- if (tc->th != NULL)
+ GNUNET_SERVER_client_set_user_context (client, NULL);
+ if (NULL != tc->th)
{
GNUNET_SERVER_notify_transmit_ready_cancel (tc->th);
tc->th = NULL;
@@ -634,9 +643,10 @@
}
tc = setup_client (client);
tc->send_payload = (0 != (2 & options));
- unicast (tc, GST_hello_get (), GNUNET_NO);
+ unicast (tc,
+ GST_hello_get (),
+ GNUNET_NO);
GST_neighbours_iterate (¬ify_client_about_neighbour, tc);
- GNUNET_CONTAINER_DLL_insert (clients_head, clients_tail, tc);
GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
@@ -684,7 +694,8 @@
* @param bytes_on_wire bytes sent on wire
*/
static void
-handle_send_transmit_continuation (void *cls, int success,
+handle_send_transmit_continuation (void *cls,
+ int success,
size_t bytes_payload,
size_t bytes_on_wire)
{
@@ -692,17 +703,17 @@
struct SendOkMessage send_ok_msg;
if (GNUNET_OK == success)
- GST_neighbours_notify_payload_sent (&stcc->target, bytes_payload);
-
+ GST_neighbours_notify_payload_sent (&stcc->target,
+ bytes_payload);
send_ok_msg.header.size = htons (sizeof (send_ok_msg));
send_ok_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK);
send_ok_msg.bytes_msg = htonl (bytes_payload);
send_ok_msg.bytes_physical = htonl (bytes_on_wire);
send_ok_msg.success = htonl (success);
- send_ok_msg.latency =
- GNUNET_TIME_relative_hton (GNUNET_TIME_UNIT_FOREVER_REL);
send_ok_msg.peer = stcc->target;
- GST_clients_unicast (stcc->client, &send_ok_msg.header, GNUNET_NO);
+ GST_clients_unicast (stcc->client,
+ &send_ok_msg.header,
+ GNUNET_NO);
GNUNET_SERVER_client_drop (stcc->client);
GNUNET_free (stcc);
}
@@ -1254,14 +1265,14 @@
struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
- static struct GNUNET_PeerIdentity all_zeros;
struct GNUNET_SERVER_TransmitContext *tc;
const struct PeerMonitorMessage *msg;
struct IterationContext pc;
msg = (const struct PeerMonitorMessage *) message;
if ( (GNUNET_YES != ntohl (msg->one_shot)) &&
- (NULL != lookup_monitoring_client (peer_monitoring_clients_head,
client)) )
+ (NULL != lookup_monitoring_client (peer_monitoring_clients_head,
+ client)) )
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
"ServerClient %p tried to start monitoring twice\n",
@@ -1316,7 +1327,6 @@
struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
- static struct GNUNET_PeerIdentity all_zeros;
struct GNUNET_SERVER_TransmitContext *tc;
struct PeerMonitorMessage *msg;
struct IterationContext pc;
@@ -1582,8 +1592,9 @@
for (tc = clients_head; NULL != tc; tc = tc->next)
{
- if ((GNUNET_YES == may_drop) && (GNUNET_YES != tc->send_payload))
- continue; /* skip, this client does not care about
payload */
+ if ( (GNUNET_YES == may_drop) &&
+ (GNUNET_YES != tc->send_payload) )
+ continue; /* skip, this client does not care about payload */
unicast (tc, msg, may_drop);
}
}
@@ -1624,7 +1635,6 @@
enum GNUNET_TRANSPORT_PeerState state,
struct GNUNET_TIME_Absolute
state_timeout)
{
- static struct GNUNET_PeerIdentity all_zeros;
struct PeerIterateResponseMessage *msg;
struct MonitoringClient *mc;
@@ -1668,7 +1678,6 @@
{
struct ValidationIterateResponseMessage *msg;
struct MonitoringClient *mc;
- static struct GNUNET_PeerIdentity all_zeros;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending information about for validation entry for peer `%s'
using address `%s'\n",
Modified: gnunet/src/transport/transport.h
===================================================================
--- gnunet/src/transport/transport.h 2014-12-20 13:24:45 UTC (rev 34736)
+++ gnunet/src/transport/transport.h 2014-12-20 13:52:02 UTC (rev 34737)
@@ -265,11 +265,6 @@
uint32_t bytes_physical GNUNET_PACKED;
/**
- * Latency estimate.
- */
- struct GNUNET_TIME_RelativeNBO latency;
-
- /**
* Which peer can send more now?
*/
struct GNUNET_PeerIdentity peer;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r34737 - in gnunet/src: include transport,
gnunet <=