fix state machine update
authorChristian Grothoff <christian@grothoff.org>
Wed, 17 Feb 2010 22:17:37 +0000 (22:17 +0000)
committerChristian Grothoff <christian@grothoff.org>
Wed, 17 Feb 2010 22:17:37 +0000 (22:17 +0000)
src/transport/gnunet-service-transport.c
src/transport/test_transport_api_tcp_peer1.conf
src/transport/test_transport_api_tcp_peer2.conf
src/transport/transport_api.c

index 8f88311b011458d6d339eb45a385ad0dc1aab819..b89bc8bce0d202f7e5630ec2b6e1ccd5f2e4da45 100644 (file)
@@ -1194,9 +1194,6 @@ try_transmission_to_peer (struct NeighbourList *neighbour)
   /* FIXME: support bi-directional use of TCP */
   if (mq->specific_address == NULL)
     mq->specific_address = find_ready_address(neighbour); 
-  GNUNET_CONTAINER_DLL_remove (neighbour->messages_head,
-                              neighbour->messages_tail,
-                              mq);
   if (mq->specific_address == NULL)
     {
       timeout = GNUNET_TIME_absolute_get_remaining (mq->timeout);
@@ -1210,6 +1207,9 @@ try_transmission_to_peer (struct NeighbourList *neighbour)
 #endif
          if (mq->client != NULL)
            transmit_send_ok (mq->client, neighbour, GNUNET_NO);
+         GNUNET_CONTAINER_DLL_remove (neighbour->messages_head,
+                                      neighbour->messages_tail,
+                                      mq);
          GNUNET_free (mq);
          return;               /* nobody ready */ 
        }
@@ -1229,6 +1229,9 @@ try_transmission_to_peer (struct NeighbourList *neighbour)
 #endif
       return;    
     }
+  GNUNET_CONTAINER_DLL_remove (neighbour->messages_head,
+                              neighbour->messages_tail,
+                              mq);
   if (mq->specific_address->connected == GNUNET_NO)
     mq->specific_address->connect_attempts++;
   rl = mq->specific_address->ready_list;
index 77902fd2073a2dcea0d169ef87c9486283f7f2ed..e854db16af2013169d788dd3b46a4290afe9842e 100644 (file)
@@ -49,7 +49,7 @@ MINIMUM-FRIENDS = 0
 
 [transport]
 PLUGINS = tcp
-#DEBUG = YES
+DEBUG = YES
 #PREFIX = xterm -T transport2 -e gdb --command=cmd --args
 #PREFIX = valgrind --leak-check=full
 ALLOW_SHUTDOWN = YES
index 870a4809ec8c021800b222b7f5b37ca72461faeb..44c6850ce168a68a772a63943ecbc61625c7fe97 100644 (file)
@@ -49,8 +49,8 @@ MINIMUM-FRIENDS = 0
 
 [transport]
 PLUGINS = tcp
-#DEBUG = YES
-PREFIX = 
+DEBUG = YES
+PREFIX = 
 ALLOW_SHUTDOWN = YES
 ACCEPT_FROM6 = ::1;
 ACCEPT_FROM = 127.0.0.1;
index 020253bc72eb3c4984b8ea8e14cb8bf07977cf80..b99e8969b84bb5e248066350e6f72f8494425eff 100644 (file)
@@ -640,6 +640,26 @@ transport_notify_ready (void *cls, size_t size, void *buf)
          ret += (mret + sizeof (struct OutboundMessage));
          size -= (mret + sizeof (struct OutboundMessage));
        }
+      else
+       {
+         switch (n->transmit_stage)
+           {
+           case TS_NEW:
+             GNUNET_break (0);
+             break;
+           case TS_QUEUED:
+             GNUNET_break (0);
+             break;
+           case TS_TRANSMITTED:
+             n->transmit_stage = TS_NEW;
+             break;
+           case TS_TRANSMITTED_QUEUED:
+             GNUNET_break (0);
+             break;
+           default:
+             GNUNET_break (0);
+           }
+       }
     }
   schedule_transmission (h);
 #if DEBUG_TRANSPORT
@@ -1565,9 +1585,15 @@ peer_transmit_timeout (void *cls,
   void *notify_cls;
 
   th->notify_delay_task = GNUNET_SCHEDULER_NO_TASK;
+  n = th->neighbour;
+#if DEBUG_TRANSPORT
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Triggering timeout for request to transmit to `%4s' (%d)\n",
+             GNUNET_i2s (&n->id),
+             n->transmit_stage);
+#endif  
   notify = th->notify;
   notify_cls = th->notify_cls;
-  n = th->neighbour;
   switch (n->transmit_stage)
     {
     case TS_NEW: