-use ms for timeout, not us
[oweals/gnunet.git] / src / fs / gnunet-service-fs_mesh_client.c
index 0487be5fe13859ecb06509b3a6f3d5047db308aa..d315098578551331374678b5f8fe459f4129bf24 100644 (file)
@@ -216,16 +216,17 @@ reset_mesh (struct MeshHandle *mh)
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Resetting mesh tunnel to %s\n",
              GNUNET_i2s (&mh->target));
-  GNUNET_mesh_handle_destroy (mh->tunnel);
+  GNUNET_MESH_tunnel_destroy (mh->tunnel);
   GNUNET_CONTAINER_multihashmap_iterate (mh->waiting_map,
                                         &move_to_pending,
                                         mh);
-  mh->tunnel = GNUNET_mesh_handle_create (mesh_handle,
+  mh->tunnel = GNUNET_MESH_tunnel_create (mesh_handle,
                                          mh,
                                          &mh->target,
                                          GNUNET_APPLICATION_TYPE_FS_BLOCK_TRANSFER,
-                                         GNUNET_YES,
+                                         GNUNET_NO,
                                          GNUNET_YES);
+  transmit_pending (mh);
 }
 
 
@@ -240,7 +241,7 @@ mesh_timeout (void *cls,
              const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   struct MeshHandle *mh = cls;
-  struct GNUNET_Mesh_Handle *tun;
+  struct GNUNET_MESH_Tunnel *tun;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Timeout on mesh tunnel to %s\n",
@@ -248,7 +249,7 @@ mesh_timeout (void *cls,
   mh->timeout_task = GNUNET_SCHEDULER_NO_TASK;
   tun = mh->tunnel;
   mh->tunnel = NULL;
-  GNUNET_mesh_handle_destroy (tun);
+  GNUNET_MESH_tunnel_destroy (tun);
 }
 
 
@@ -309,7 +310,7 @@ transmit_sqm (void *cls,
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                "Mesh tunnel to %s failed during transmission attempt, rebuilding\n",
                GNUNET_i2s (&mh->target));
-    reset_mesh (mh);
+    reset_mesh_async (mh);
     return 0;
   }
   sr = mh->pending_head;
@@ -351,6 +352,8 @@ transmit_sqm (void *cls,
 static void
 transmit_pending (struct MeshHandle *mh)
 {
+  if (NULL == mh->tunnel)
+    return;
   if (NULL != mh->wh)
     return;
   mh->wh = GNUNET_MESH_notify_transmit_ready (mh->tunnel, GNUNET_YES /* allow cork */,
@@ -433,7 +436,7 @@ handle_reply (void *cls,
  */
 static int
 reply_cb (void *cls,
-         struct GNUNET_Mesh_Handle *tunnel,
+         struct GNUNET_MESH_Tunnel *tunnel,
          void **tunnel_ctx,
           const struct GNUNET_MessageHeader *message)
 {
@@ -521,7 +524,7 @@ get_mesh (const struct GNUNET_PeerIdentity *target)
                                                 mh);
   mh->waiting_map = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_YES);
   mh->target = *target;
-  mh->tunnel = GNUNET_mesh_handle_create (mesh_handle,
+  mh->tunnel = GNUNET_MESH_tunnel_create (mesh_handle,
                                          mh,
                                          &mh->target,
                                          GNUNET_APPLICATION_TYPE_FS_BLOCK_TRANSFER,
@@ -642,7 +645,7 @@ free_waiting_entry (void *cls,
  */
 static void
 cleaner_cb (void *cls,
-           const struct GNUNET_Mesh_Handle *tunnel,
+           const struct GNUNET_MESH_Tunnel *tunnel,
            void *tunnel_ctx)
 {
   struct MeshHandle *mh = tunnel_ctx;
@@ -709,7 +712,7 @@ release_meshs (void *cls,
               void *value)
 {
   struct MeshHandle *mh = value;
-  struct GNUNET_Mesh_Handle *tun;
+  struct GNUNET_MESH_Tunnel *tun;
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Timeout on mesh tunnel to %s\n",
@@ -717,7 +720,7 @@ release_meshs (void *cls,
   tun = mh->tunnel;
   mh->tunnel = NULL;
   if (NULL != tun)
-    GNUNET_mesh_handle_destroy (tun);
+    GNUNET_MESH_tunnel_destroy (tun);
   return GNUNET_YES;
 }