implement cork option, fix testcases
authorChristian Grothoff <christian@grothoff.org>
Fri, 11 Mar 2011 12:57:57 +0000 (12:57 +0000)
committerChristian Grothoff <christian@grothoff.org>
Fri, 11 Mar 2011 12:57:57 +0000 (12:57 +0000)
src/core/core.h
src/core/core_api.c
src/core/gnunet-service-core.c
src/core/test_core_api.c
src/core/test_core_api_reliability.c
src/core/test_core_api_send_to_self.c
src/core/test_core_quota_compliance.c

index acac7c4074548056fceb301c69cded9e584cd223..fff4c3fa8234fd2aaa907747d9225d2cfa52d8ce 100644 (file)
@@ -430,6 +430,16 @@ struct SendMessage
    */
   struct GNUNET_PeerIdentity peer;
 
+  /**
+   * GNUNET_YES if corking is allowed, GNUNET_NO if not.
+   */
+  uint32_t cork GNUNET_PACKED;
+
+  /**
+   * Always 0.
+   */
+  uint64_t reserved GNUNET_PACKED;
+
 };
 
 
index a0f72090da8021abe1c0c988e30d4ede4e99c634..15e8add7e687ee5e1f7bda824c9deef6b71fdbd3 100644 (file)
@@ -346,6 +346,11 @@ struct GNUNET_CORE_TransmitHandle
    */
   uint16_t smr_id;
 
+  /**
+   * Is corking allowed?
+   */
+  int cork;
+
 };
 
 
@@ -707,6 +712,8 @@ transmit_message (void *cls,
       sm->priority = htonl (th->priority);
       sm->deadline = GNUNET_TIME_absolute_hton (th->timeout);
       sm->peer = pr->peer;
+      sm->cork = htonl ((uint32_t) th->cork);
+      sm->reserved = htonl (0);
       ret = th->get_message (th->get_message_cls,
                             size - sizeof (struct SendMessage),
                             &sm[1]);
@@ -1532,6 +1539,7 @@ GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle,
   th->timeout = GNUNET_TIME_relative_to_absolute (maxdelay);
   th->priority = priority;
   th->msize = notify_size;
+  th->cork = cork;
   /* bound queue size */
   if (pr->queue_size == handle->queue_size)
     {
index 6be71242fce80ebfd82f23f47c01bf7c85d00a73..298b5e27717c15fb2b13f683080641a6cafb1b76 100644 (file)
@@ -2886,10 +2886,13 @@ handle_client_send (void *cls,
              GNUNET_i2s (&sm->peer),
              (unsigned int) msize);
 #endif  
+  GNUNET_break (0 == ntohl (sm->reserved));
   e = GNUNET_malloc (sizeof (struct MessageEntry) + msize);
   e->deadline = GNUNET_TIME_absolute_ntoh (sm->deadline);
   e->priority = ntohl (sm->priority);
   e->size = msize;
+  if (GNUNET_YES != (int) ntohl (sm->cork))
+    e->got_slack = GNUNET_YES;
   memcpy (&e[1], &sm[1], msize);
 
   /* insert, keep list sorted by deadline */
index cdc5517c362d3ca46d573a6938ea839ce2856f5f..38aaf63b175afdb1944448fa8e20d73d47d4ede1 100644 (file)
@@ -138,6 +138,7 @@ connect_notify (void *cls,
                  "Asking core (1) for transmission to peer `%4s'\n",
                  GNUNET_i2s (&p2.id));
       if (NULL == GNUNET_CORE_notify_transmit_ready (p1.ch,
+                                                    GNUNET_YES,
                                                     0,
                                                     GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 45),
                                                     &p2.id,
index b7f2a813917b3ccf376d0c6bc2cbf4f8253adc56..f21691691103322a461918dab0e020725e2db67f 100644 (file)
@@ -167,6 +167,7 @@ transmit_ready (void *cls, size_t size, void *buf)
       if (p1.ch != NULL)
        GNUNET_break (NULL != 
                      GNUNET_CORE_notify_transmit_ready (p1.ch,
+                                                        GNUNET_NO,
                                                         0,
                                                         FAST_TIMEOUT,
                                                         &p2.id,
@@ -244,6 +245,7 @@ connect_notify (void *cls,
       start_time = GNUNET_TIME_absolute_get ();
       GNUNET_break (NULL != 
                    GNUNET_CORE_notify_transmit_ready (p1.ch,
+                                                      GNUNET_NO,
                                                       0,
                                                       TIMEOUT,
                                                       &p2.id,
@@ -356,6 +358,7 @@ process_mtype (void *cls,
       if (n == tr_n)
        GNUNET_break (NULL != 
                      GNUNET_CORE_notify_transmit_ready (p1.ch,
+                                                        GNUNET_NO,
                                                         0,
                                                         FAST_TIMEOUT,
                                                         &p2.id,
index 55137dcc9e1e01dca74ad5f7eb12b1d86293c876..b287ecf05c9b19d7320e4b2bd2e1c254e2fedcf1 100644 (file)
@@ -141,6 +141,7 @@ connect_cb (void *cls, const struct GNUNET_PeerIdentity *peer,
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                  "Connected to myself; sending message!\n");
       GNUNET_CORE_notify_transmit_ready (core,
+                                        GNUNET_YES,
                                         0, GNUNET_TIME_UNIT_FOREVER_REL,
                                         peer,
                                         sizeof (struct GNUNET_MessageHeader),
index 6a67b8606af891c6b6ed21286bd8801207686a5d..d3b49d880cf676e7c11876a6dfb5cc7f1be928e7 100644 (file)
@@ -319,6 +319,7 @@ transmit_ready (void *cls, size_t size, void *buf)
           (p1.connect_status == 1) )
        GNUNET_break (NULL !=
                      GNUNET_CORE_notify_transmit_ready (p1.ch,
+                                                        GNUNET_NO,
                                                         0,
                                                         FAST_TIMEOUT,
                                                         &p2.id,
@@ -395,11 +396,12 @@ connect_notify (void *cls,
       measure_task = GNUNET_SCHEDULER_add_delayed(MEASUREMENT_LENGTH, &measurement_stop, NULL);
 
       GNUNET_break (NULL != GNUNET_CORE_notify_transmit_ready (p1.ch,
-                                                      0,
-                                                      TIMEOUT,
-                                                      &p2.id,
-                                                      MESSAGESIZE,
-                                                      &transmit_ready, &p1));
+                                                              GNUNET_NO,
+                                                              0,
+                                                              TIMEOUT,
+                                                              &p2.id,
+                                                              MESSAGESIZE,
+                                                              &transmit_ready, &p1));
     }
 }
 
@@ -503,6 +505,7 @@ process_mtype (void *cls,
   if (running == GNUNET_YES)
        GNUNET_break (NULL !=
                      GNUNET_CORE_notify_transmit_ready (p1.ch,
+                                                        GNUNET_NO,
                                                         0,
                                                         FAST_TIMEOUT,
                                                         &p2.id,