ats_ril: - removed some redundantly saved plugin environment attributes
[oweals/gnunet.git] / src / fs / gnunet-service-fs_mesh_server.c
index e8a0ce82058e09bcc95285eedfbf6f4d5c3b1337..e732da990a610e45a9b57845ddf43bca03249d8f 100644 (file)
@@ -19,7 +19,7 @@
 */
 
 /**
- * @file fs/gnunet-service-fs_mesh.c
+ * @file fs/gnunet-service-fs_mesh_server.c
  * @brief non-anonymous file-transfer
  * @author Christian Grothoff
  *
@@ -72,22 +72,22 @@ struct MeshClient
 {
   /**
    * DLL
-   */ 
+   */
   struct MeshClient *next;
 
   /**
    * DLL
-   */ 
+   */
   struct MeshClient *prev;
 
   /**
    * Tunnel for communication.
-   */ 
+   */
   struct GNUNET_MESH_Tunnel *tunnel;
 
   /**
    * Handle for active write operation, or NULL.
-   */ 
+   */
   struct GNUNET_MESH_TransmitHandle *wh;
 
   /**
@@ -99,7 +99,7 @@ struct MeshClient
    * Tail of write queue.
    */
   struct WriteQueueItem *wqi_tail;
-  
+
   /**
    * Current active request to the datastore, if we have one pending.
    */
@@ -117,7 +117,7 @@ struct MeshClient
 
   /**
    * Size of the last write that was initiated.
-   */ 
+   */
   size_t reply_size;
 
 };
@@ -130,12 +130,12 @@ static struct GNUNET_MESH_Handle *listen_tunnel;
 
 /**
  * Head of DLL of mesh clients.
- */ 
+ */
 static struct MeshClient *sc_head;
 
 /**
  * Tail of DLL of mesh clients.
- */ 
+ */
 static struct MeshClient *sc_tail;
 
 /**
@@ -155,7 +155,7 @@ static unsigned long long sc_count_max;
  *
  * @param cls the 'struct MeshClient'
  * @param tc scheduler context
- */ 
+ */
 static void
 timeout_mesh_task (void *cls,
                     const struct GNUNET_SCHEDULER_TaskContext *tc)
@@ -166,6 +166,9 @@ timeout_mesh_task (void *cls,
   sc->timeout_task = GNUNET_SCHEDULER_NO_TASK;
   tun = sc->tunnel;
   sc->tunnel = NULL;
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Timeout for inactive mesh client %p\n",
+             sc);
   GNUNET_MESH_tunnel_destroy (tun);
 }
 
@@ -179,7 +182,7 @@ static void
 refresh_timeout_task (struct MeshClient *sc)
 {
   if (GNUNET_SCHEDULER_NO_TASK != sc->timeout_task)
-    GNUNET_SCHEDULER_cancel (sc->timeout_task); 
+    GNUNET_SCHEDULER_cancel (sc->timeout_task);
   sc->timeout_task = GNUNET_SCHEDULER_add_delayed (IDLE_TIMEOUT,
                                                   &timeout_mesh_task,
                                                   sc);
@@ -195,6 +198,9 @@ static void
 continue_reading (struct MeshClient *sc)
 {
   refresh_timeout_task (sc);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Finished processing mesh request from client %p, ready to receive the next one\n",
+             sc);
   GNUNET_MESH_receive_done (sc->tunnel);
 }
 
@@ -246,8 +252,9 @@ write_continuation (void *cls,
                               sc->wqi_tail,
                               wqi);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Transmitted %u byte reply via mesh\n",
-             (unsigned int) size);
+             "Transmitted %u byte reply via mesh to %p\n",
+             (unsigned int) size,
+             sc);
   GNUNET_STATISTICS_update (GSF_stats,
                            gettext_noop ("# Blocks transferred via mesh"), 1,
                            GNUNET_NO);
@@ -284,7 +291,7 @@ continue_writing (struct MeshClient *sc)
   }
   sc->wh = GNUNET_MESH_notify_transmit_ready (sc->tunnel, GNUNET_NO,
                                              GNUNET_TIME_UNIT_FOREVER_REL,
-                                             wqi->msize,                                     
+                                             wqi->msize,                               
                                              &write_continuation,
                                              sc);
   if (NULL == sc->wh)
@@ -313,7 +320,7 @@ continue_writing (struct MeshClient *sc)
  * @param uid unique identifier for the datum;
  *        maybe 0 if no unique identifier is available
  */
-static void 
+static void
 handle_datastore_reply (void *cls,
                        const struct GNUNET_HashCode *key,
                        size_t size, const void *data,
@@ -355,9 +362,10 @@ handle_datastore_reply (void *cls,
     return;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-             "Starting transmission of %u byte reply for query `%s' via mesh\n",
+             "Starting transmission of %u byte reply for query `%s' via mesh to %p\n",
              (unsigned int) size,
-             GNUNET_h2s (key));
+             GNUNET_h2s (key),
+             sc);
   wqi = GNUNET_malloc (sizeof (struct WriteQueueItem) + msize);
   wqi->msize = msize;
   srm = (struct MeshReplyMessage *) &wqi[1];
@@ -408,7 +416,7 @@ request_cb (void *cls,
                                     0,
                                     &sqm->query,
                                     ntohl (sqm->type),
-                                    0 /* priority */, 
+                                    0 /* priority */,
                                     GSF_datastore_queue_size,
                                     GNUNET_TIME_UNIT_FOREVER_REL,
                                     &handle_datastore_reply, sc);
@@ -473,7 +481,7 @@ accept_cb (void *cls,
  *
  * @param cls NULL
  * @param tunnel tunnel of the disconnecting client
- * @param tunnel_ctx our 'struct MeshClient' 
+ * @param tunnel_ctx our 'struct MeshClient'
  */
 static void
 cleaner_cb (void *cls,
@@ -493,9 +501,9 @@ cleaner_cb (void *cls,
                            gettext_noop ("# mesh connections active"), -1,
                            GNUNET_NO);
   if (GNUNET_SCHEDULER_NO_TASK != sc->terminate_task)
-    GNUNET_SCHEDULER_cancel (sc->terminate_task); 
+    GNUNET_SCHEDULER_cancel (sc->terminate_task);
   if (GNUNET_SCHEDULER_NO_TASK != sc->timeout_task)
-    GNUNET_SCHEDULER_cancel (sc->timeout_task); 
+    GNUNET_SCHEDULER_cancel (sc->timeout_task);
   if (NULL != sc->wh)
     GNUNET_MESH_notify_transmit_ready_cancel (sc->wh);
   if (NULL != sc->qe)
@@ -536,6 +544,9 @@ GSF_mesh_start_server ()
                                             "MAX_MESH_CLIENTS",
                                             &sc_count_max))
     return;
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Initializing mesh FS server with a limit of %llu connections\n",
+             sc_count_max);
   listen_tunnel = GNUNET_MESH_connect (GSF_cfg,
                                       NULL,
                                       &accept_cb,