gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r34547 - gnunet/src/core


From: gnunet
Subject: [GNUnet-SVN] r34547 - gnunet/src/core
Date: Sat, 13 Dec 2014 21:37:51 +0100

Author: grothoff
Date: 2014-12-13 21:37:51 +0100 (Sat, 13 Dec 2014)
New Revision: 34547

Modified:
   gnunet/src/core/gnunet-service-core.h
   gnunet/src/core/gnunet-service-core_clients.c
   gnunet/src/core/gnunet-service-core_clients.h
   gnunet/src/core/gnunet-service-core_kx.c
   gnunet/src/core/gnunet-service-core_neighbours.c
   gnunet/src/core/gnunet-service-core_neighbours.h
   gnunet/src/core/gnunet-service-core_sessions.c
Log:
-style fixes

Modified: gnunet/src/core/gnunet-service-core.h
===================================================================
--- gnunet/src/core/gnunet-service-core.h       2014-12-13 20:19:26 UTC (rev 
34546)
+++ gnunet/src/core/gnunet-service-core.h       2014-12-13 20:37:51 UTC (rev 
34547)
@@ -57,14 +57,14 @@
   struct GSC_ClientActiveRequest *prev;
 
   /**
-   * Which peer is the message going to be for?
+   * Handle to the client.
    */
-  struct GNUNET_PeerIdentity target;
+  struct GSC_Client *client_handle;
 
   /**
-   * Handle to the client.
+   * Which peer is the message going to be for?
    */
-  struct GSC_Client *client_handle;
+  struct GNUNET_PeerIdentity target;
 
   /**
    * By what time would the client want to see this message out?

Modified: gnunet/src/core/gnunet-service-core_clients.c
===================================================================
--- gnunet/src/core/gnunet-service-core_clients.c       2014-12-13 20:19:26 UTC 
(rev 34546)
+++ gnunet/src/core/gnunet-service-core_clients.c       2014-12-13 20:37:51 UTC 
(rev 34547)
@@ -255,10 +255,10 @@
 
 
 /**
- * Handle CORE_INIT request.
+ * Handle #GNUNET_MESSAGE_TYPE_CORE_INIT request.
  *
  * @param cls unused
- * @param client new client that sent INIT
+ * @param client new client that sent #GNUNET_MESSAGE_TYPE_CORE_INIT
  * @param message the `struct InitMessage` (presumably)
  */
 static void
@@ -325,10 +325,10 @@
 
 
 /**
- * Handle CORE_SEND_REQUEST message.
+ * Handle #GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST message.
  *
  * @param cls unused
- * @param client new client that sent CORE_SEND_REQUEST
+ * @param client new client that sent a #GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST
  * @param message the `struct SendMessageRequest` (presumably)
  */
 static void
@@ -343,23 +343,26 @@
 
   req = (const struct SendMessageRequest *) message;
   c = find_client (client);
-  if (c == NULL)
+  if (NULL == c)
   {
     /* client did not send INIT first! */
     GNUNET_break (0);
-    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+    GNUNET_SERVER_receive_done (client,
+                                GNUNET_SYSERR);
     return;
   }
-  if (c->requests == NULL)
-    c->requests = GNUNET_CONTAINER_multipeermap_create (16, GNUNET_NO);
+  if (NULL == c->requests)
+    c->requests = GNUNET_CONTAINER_multipeermap_create (16,
+                                                        GNUNET_NO);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Client asked for transmission to `%s'\n",
               GNUNET_i2s (&req->peer));
   is_loopback =
       (0 ==
-       memcmp (&req->peer, &GSC_my_identity,
+       memcmp (&req->peer,
+               &GSC_my_identity,
                sizeof (struct GNUNET_PeerIdentity)));
-  if ((!is_loopback) &&
+  if ((! is_loopback) &&
       (GNUNET_YES !=
        GNUNET_CONTAINER_multipeermap_contains (c->connectmap,
                                                &req->peer)))
@@ -371,11 +374,13 @@
                               gettext_noop
                               ("# send requests dropped (disconnected)"), 1,
                               GNUNET_NO);
-    GNUNET_SERVER_receive_done (client, GNUNET_OK);
+    GNUNET_SERVER_receive_done (client,
+                                GNUNET_OK);
     return;
   }
 
-  car = GNUNET_CONTAINER_multipeermap_get (c->requests, &req->peer);
+  car = GNUNET_CONTAINER_multipeermap_get (c->requests,
+                                           &req->peer);
   if (NULL == car)
   {
     /* create new entry */
@@ -389,6 +394,8 @@
   }
   else
   {
+    /* dequeue and recycle memory from pending request, there can only
+       be at most one per client and peer */
     GSC_SESSIONS_dequeue_request (car);
   }
   car->target = req->peer;
@@ -817,7 +824,8 @@
     return; /* no client cares about this message notification */
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Core service passes message from `%4s' of type %u to client.\n",
-              GNUNET_i2s (sender), (unsigned int) ntohs (msg->type));
+              GNUNET_i2s (sender),
+              (unsigned int) ntohs (msg->type));
   GSC_SESSIONS_add_to_typemap (sender, ntohs (msg->type));
   ntm = (struct NotifyTrafficMessage *) buf;
   ntm->header.size = htons (size);
@@ -826,8 +834,13 @@
   else
     ntm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND);
   ntm->peer = *sender;
-  memcpy (&ntm[1], msg, msize);
-  send_to_all_clients (sender, &ntm->header, GNUNET_YES, options,
+  memcpy (&ntm[1],
+          msg,
+          msize);
+  send_to_all_clients (sender,
+                       &ntm->header,
+                       GNUNET_YES,
+                       options,
                        ntohs (msg->type));
 }
 

Modified: gnunet/src/core/gnunet-service-core_clients.h
===================================================================
--- gnunet/src/core/gnunet-service-core_clients.h       2014-12-13 20:19:26 UTC 
(rev 34546)
+++ gnunet/src/core/gnunet-service-core_clients.h       2014-12-13 20:37:51 UTC 
(rev 34547)
@@ -57,8 +57,7 @@
  */
 void
 GSC_CLIENTS_notify_client_about_neighbour (struct GSC_Client *client,
-                                           const struct GNUNET_PeerIdentity
-                                           *neighbour,
+                                           const struct GNUNET_PeerIdentity 
*neighbour,
                                            const struct GSC_TypeMap *tmap_old,
                                            const struct GSC_TypeMap *tmap_new);
 
@@ -73,8 +72,7 @@
  * @param tmap_new updated type map for the neighbour, NULL for disconnect
  */
 void
-GSC_CLIENTS_notify_clients_about_neighbour (const struct GNUNET_PeerIdentity
-                                            *neighbour,
+GSC_CLIENTS_notify_clients_about_neighbour (const struct GNUNET_PeerIdentity 
*neighbour,
                                             const struct GSC_TypeMap *tmap_old,
                                             const struct GSC_TypeMap 
*tmap_new);
 

Modified: gnunet/src/core/gnunet-service-core_kx.c
===================================================================
--- gnunet/src/core/gnunet-service-core_kx.c    2014-12-13 20:19:26 UTC (rev 
34546)
+++ gnunet/src/core/gnunet-service-core_kx.c    2014-12-13 20:37:51 UTC (rev 
34547)
@@ -773,7 +773,8 @@
 static void
 send_ping (struct GSC_KeyExchangeInfo *kx)
 {
-  GSC_NEIGHBOURS_transmit (&kx->peer, &kx->ping.header,
+  GSC_NEIGHBOURS_transmit (&kx->peer,
+                           &kx->ping.header,
                            MIN_PING_FREQUENCY);
 }
 
@@ -1048,7 +1049,8 @@
                                              (void *) &tp));
   GNUNET_STATISTICS_update (GSC_stats, gettext_noop ("# PONG messages 
created"),
                             1, GNUNET_NO);
-  GSC_NEIGHBOURS_transmit (&kx->peer, &tp.header,
+  GSC_NEIGHBOURS_transmit (&kx->peer,
+                           &tp.header,
                            GNUNET_TIME_UNIT_FOREVER_REL /* FIXME: timeout */ );
 }
 
@@ -1086,7 +1088,8 @@
                             gettext_noop ("# keepalive messages sent"), 1,
                             GNUNET_NO);
   setup_fresh_ping (kx);
-  GSC_NEIGHBOURS_transmit (&kx->peer, &kx->ping.header,
+  GSC_NEIGHBOURS_transmit (&kx->peer,
+                           &kx->ping.header,
                            kx->set_key_retry_frequency);
   retry =
       GNUNET_TIME_relative_max (GNUNET_TIME_relative_divide (left, 2),
@@ -1277,7 +1280,8 @@
               GNUNET_i2s (&kx->peer),
              kx->status);
   current_ekm.sender_status = htonl ((int32_t) (kx->status));
-  GSC_NEIGHBOURS_transmit (&kx->peer, &current_ekm.header,
+  GSC_NEIGHBOURS_transmit (&kx->peer,
+                           &current_ekm.header,
                            kx->set_key_retry_frequency);
   kx->retry_set_key_task =
       GNUNET_SCHEDULER_add_delayed (kx->set_key_retry_frequency,
@@ -1294,7 +1298,8 @@
  */
 void
 GSC_KX_encrypt_and_transmit (struct GSC_KeyExchangeInfo *kx,
-                             const void *payload, size_t payload_size)
+                             const void *payload,
+                             size_t payload_size)
 {
   size_t used = payload_size + sizeof (struct EncryptedMessage);
   char pbuf[used];              /* plaintext */
@@ -1327,7 +1332,8 @@
                   ph->iv_seed);
   GNUNET_CRYPTO_hmac (&auth_key, &em->sequence_number,
                       used - ENCRYPTED_HEADER_SIZE, &em->hmac);
-  GSC_NEIGHBOURS_transmit (&kx->peer, &em->header,
+  GSC_NEIGHBOURS_transmit (&kx->peer,
+                           &em->header,
                            GNUNET_TIME_UNIT_FOREVER_REL);
 }
 

Modified: gnunet/src/core/gnunet-service-core_neighbours.c
===================================================================
--- gnunet/src/core/gnunet-service-core_neighbours.c    2014-12-13 20:19:26 UTC 
(rev 34546)
+++ gnunet/src/core/gnunet-service-core_neighbours.c    2014-12-13 20:37:51 UTC 
(rev 34547)
@@ -266,10 +266,10 @@
 {
   struct NeighbourMessageEntry *m;
 
-  if (n->th != NULL)
+  if (NULL != n->th)
     return;                     /* request already pending */
   m = n->message_head;
-  if (m == NULL)
+  if (NULL == m)
   {
     /* notify sessions that the queue is empty and more messages
      * could thus be queued now */
@@ -278,25 +278,30 @@
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Asking transport for transmission of %u bytes to `%4s' in next 
%s\n",
-              (unsigned int) m->size, GNUNET_i2s (&n->peer),
-              GNUNET_STRINGS_relative_time_to_string 
(GNUNET_TIME_absolute_get_remaining (m->deadline), GNUNET_NO));
-  n->th =
-      GNUNET_TRANSPORT_notify_transmit_ready (transport, &n->peer, m->size,
-                                              
GNUNET_TIME_absolute_get_remaining
-                                              (m->deadline), &transmit_ready,
+              (unsigned int) m->size,
+              GNUNET_i2s (&n->peer),
+              GNUNET_STRINGS_relative_time_to_string 
(GNUNET_TIME_absolute_get_remaining (m->deadline),
+                                                      GNUNET_NO));
+  n->th
+    = GNUNET_TRANSPORT_notify_transmit_ready (transport,
+                                              &n->peer,
+                                              m->size,
+                                              
GNUNET_TIME_absolute_get_remaining (m->deadline),
+                                              &transmit_ready,
                                               n);
-  if (n->th != NULL)
+  if (NULL != n->th)
     return;
   /* message request too large or duplicate request */
   GNUNET_break (0);
   /* discard encrypted message */
-  GNUNET_CONTAINER_DLL_remove (n->message_head, n->message_tail, m);
+  GNUNET_CONTAINER_DLL_remove (n->message_head,
+                               n->message_tail,
+                               m);
   GNUNET_free (m);
   process_queue (n);
 }
 
 
-
 /**
  * Function called by transport to notify us that
  * a peer connected to us (on the network level).
@@ -310,7 +315,9 @@
 {
   struct Neighbour *n;
 
-  if (0 == memcmp (peer, &GSC_my_identity, sizeof (struct 
GNUNET_PeerIdentity)))
+  if (0 == memcmp (peer,
+                   &GSC_my_identity,
+                   sizeof (struct GNUNET_PeerIdentity)))
   {
     GNUNET_break (0);
     return;
@@ -356,7 +363,7 @@
               "Peer `%4s' disconnected from us; received notification from 
transport.\n",
               GNUNET_i2s (peer));
   n = find_neighbour (peer);
-  if (n == NULL)
+  if (NULL == n)
   {
     GNUNET_break (0);
     return;
@@ -373,7 +380,8 @@
  * @param message the message
  */
 static void
-handle_transport_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
+handle_transport_receive (void *cls,
+                          const struct GNUNET_PeerIdentity *peer,
                           const struct GNUNET_MessageHeader *message)
 {
   struct Neighbour *n;
@@ -414,9 +422,9 @@
     break;
   default:
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                _
-                ("Unsupported message of type %u (%u bytes) received from peer 
`%s'\n"),
-                (unsigned int) type, (unsigned int) ntohs (message->size),
+                _("Unsupported message of type %u (%u bytes) received from 
peer `%s'\n"),
+                (unsigned int) type,
+                (unsigned int) ntohs (message->size),
                 GNUNET_i2s (peer));
     return;
   }
@@ -561,7 +569,8 @@
   }
   if (NULL != neighbours)
   {
-    GNUNET_CONTAINER_multipeermap_iterate (neighbours, &free_neighbour_helper,
+    GNUNET_CONTAINER_multipeermap_iterate (neighbours,
+                                           &free_neighbour_helper,
                                           NULL);
     GNUNET_CONTAINER_multipeermap_destroy (neighbours);
     neighbours = NULL;

Modified: gnunet/src/core/gnunet-service-core_neighbours.h
===================================================================
--- gnunet/src/core/gnunet-service-core_neighbours.h    2014-12-13 20:19:26 UTC 
(rev 34546)
+++ gnunet/src/core/gnunet-service-core_neighbours.h    2014-12-13 20:37:51 UTC 
(rev 34547)
@@ -31,10 +31,10 @@
 /**
  * Transmit the given message to the given target.  Note that a
  * non-control messages should only be transmitted after a
- * 'GSC_SESSION_solicit' call was made (that call is always invoked
+ * #GSC_SESSION_solicit() call was made (that call is always invoked
  * when the message queue is empty).  Outbound quotas and memory
- * bounds will then be enfoced (as GSC_SESSION_solicit is only called
- * if sufficient banwdith is available).
+ * bounds will then be enfoced (as #GSC_SESSION_solicit() is only called
+ * if sufficient bandwidth is available).
  *
  * @param target peer that should receive the message (must be connected)
  * @param msg message to transmit

Modified: gnunet/src/core/gnunet-service-core_sessions.c
===================================================================
--- gnunet/src/core/gnunet-service-core_sessions.c      2014-12-13 20:19:26 UTC 
(rev 34546)
+++ gnunet/src/core/gnunet-service-core_sessions.c      2014-12-13 20:37:51 UTC 
(rev 34547)
@@ -59,9 +59,9 @@
   struct GNUNET_TIME_Absolute deadline;
 
   /**
-   * How long is the message? (number of bytes following the "struct
-   * MessageEntry", but not including the size of "struct
-   * MessageEntry" itself!)
+   * How long is the message? (number of bytes following the `struct
+   * MessageEntry`, but not including the size of `struct
+   * MessageEntry` itself!)
    */
   size_t size;
 
@@ -535,15 +535,16 @@
   {
     pos = nxt;
     nxt = pos->next;
-    if ((pos->deadline.abs_value_us < now.abs_value_us) &&
-        (GNUNET_YES != pos->was_solicited))
+    if ( (pos->deadline.abs_value_us < now.abs_value_us) &&
+         (GNUNET_YES != pos->was_solicited) )
     {
       GNUNET_STATISTICS_update (GSC_stats,
                                 gettext_noop
                                 ("# messages discarded (expired prior to 
transmission)"),
                                 1, GNUNET_NO);
       GNUNET_CONTAINER_DLL_remove (session->active_client_request_head,
-                                   session->active_client_request_tail, pos);
+                                   session->active_client_request_tail,
+                                   pos);
       GSC_CLIENTS_reject_request (pos);
     }
   }
@@ -648,7 +649,8 @@
     GNUNET_assert (pos->size < GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE);
     msize += pos->size;
     maxp = GNUNET_MAX (maxp, pos->priority);
-    min_deadline = GNUNET_TIME_absolute_min (min_deadline, pos->deadline);
+    min_deadline = GNUNET_TIME_absolute_min (min_deadline,
+                                             pos->deadline);
     pos = pos->next;
   }
   if (maxp < GNUNET_CORE_PRIO_CRITICAL_CONTROL)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]