gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r34026 - in gnunet/src: multicast psyc social


From: gnunet
Subject: [GNUnet-SVN] r34026 - in gnunet/src: multicast psyc social
Date: Thu, 24 Jul 2014 09:59:21 +0200

Author: tg
Date: 2014-07-24 09:59:21 +0200 (Thu, 24 Jul 2014)
New Revision: 34026

Modified:
   gnunet/src/multicast/multicast_api.c
   gnunet/src/psyc/gnunet-service-psyc.c
   gnunet/src/social/gnunet-service-social.c
   gnunet/src/social/social_api.c
   gnunet/src/social/test_social.c
Log:
social: guest_talk test; multicast: fix member_to_origin_resume()

Modified: gnunet/src/multicast/multicast_api.c
===================================================================
--- gnunet/src/multicast/multicast_api.c        2014-07-24 06:00:09 UTC (rev 
34025)
+++ gnunet/src/multicast/multicast_api.c        2014-07-24 07:59:21 UTC (rev 
34026)
@@ -980,7 +980,7 @@
 void
 GNUNET_MULTICAST_member_to_origin_resume (struct 
GNUNET_MULTICAST_MemberTransmitHandle *th)
 {
-
+  member_to_origin (th->member);
 }
 
 

Modified: gnunet/src/psyc/gnunet-service-psyc.c
===================================================================
--- gnunet/src/psyc/gnunet-service-psyc.c       2014-07-24 06:00:09 UTC (rev 
34025)
+++ gnunet/src/psyc/gnunet-service-psyc.c       2014-07-24 07:59:21 UTC (rev 
34026)
@@ -102,6 +102,12 @@
    */
   uint8_t state;
 
+  /**
+   * Whether a message ACK has already been sent to the client.
+   * #GNUNET_YES or #GNUNET_NO
+   */
+  uint8_t ack_sent;
+
   /* Followed by message */
 };
 
@@ -396,7 +402,7 @@
 };
 
 
-static inline void
+static void
 transmit_message (struct Channel *chn);
 
 
@@ -1689,7 +1695,8 @@
   memcpy (data, &tmit_msg[1], *data_size);
 
   int ret = (MSG_STATE_END < chn->tmit_state) ? GNUNET_NO : GNUNET_YES;
-  if (NULL != tmit_msg->client)
+
+  if (NULL != tmit_msg->client && GNUNET_NO == tmit_msg->ack_sent)
     send_message_ack (chn, tmit_msg->client);
 
   GNUNET_CONTAINER_DLL_remove (chn->tmit_head, chn->tmit_tail, tmit_msg);
@@ -1781,7 +1788,7 @@
 }
 
 
-static inline void
+static void
 transmit_message (struct Channel *chn)
 {
   chn->is_master
@@ -1849,7 +1856,7 @@
  * @param first_ptype  First message part type in @a data.
  * @param last_ptype   Last message part type in @a data.
  */
-static void
+static struct TransmitMessage *
 queue_message (struct Channel *chn,
                struct GNUNET_SERVER_Client *client,
                size_t data_size,
@@ -1872,6 +1879,7 @@
                             first_ptype, last_ptype)
     : slave_queue_message ((struct Slave *) chn, tmit_msg,
                            first_ptype, last_ptype);
+  return tmit_msg;
 }
 
 
@@ -1951,6 +1959,7 @@
   queue_message (chn, client, size - sizeof (*msg), &msg[1],
                  first_ptype, last_ptype);
   transmit_message (chn);
+  /* FIXME: send a few ACKs even before transmit_notify is called */
 
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
 };

Modified: gnunet/src/social/gnunet-service-social.c
===================================================================
--- gnunet/src/social/gnunet-service-social.c   2014-07-24 06:00:09 UTC (rev 
34025)
+++ gnunet/src/social/gnunet-service-social.c   2014-07-24 07:59:21 UTC (rev 
34026)
@@ -857,11 +857,6 @@
                                struct FragmentTransmitQueue *tmit_frag)
 {
   uint16_t psize = ntohs (tmit_frag->next_part->size);
-  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-              "%p psyc_transmit_queue_next_part: %x + %u - %x = %u < %u\n",
-              plc, tmit_frag->next_part, psize, &tmit_frag[1],
-              (char *) tmit_frag->next_part + psize - ((char *) &tmit_frag[1]),
-              tmit_frag->size);
   if ((char *) tmit_frag->next_part + psize - ((char *) &tmit_frag[1])
       < tmit_frag->size)
   {
@@ -952,11 +947,15 @@
     break;
 
   case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END:
-  case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL:
     *data_size = 0;
     ret = GNUNET_YES;
     break;
 
+  case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL:
+    *data_size = 0;
+    ret = GNUNET_SYSERR;
+    break;
+
   default:
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                 "%p psyc_transmit_notify_data: unexpected message part of type 
%u.\n",
@@ -964,7 +963,7 @@
     ret = GNUNET_SYSERR;
   }
 
-  if (GNUNET_SYSERR == ret)
+  if (GNUNET_SYSERR == ret && GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL != ptype)
   {
     *data_size = 0;
     tmit_msg = psyc_transmit_queue_next_msg (plc, tmit_msg);
@@ -975,7 +974,27 @@
   }
   else
   {
-    psyc_transmit_queue_next_part (plc, tmit_msg, tmit_frag);
+    tmit_frag = psyc_transmit_queue_next_part (plc, tmit_msg, tmit_frag);
+    if (NULL != tmit_frag)
+    {
+      struct GNUNET_MessageHeader *pmsg = tmit_frag->next_part;
+      ptype = ntohs (pmsg->type);
+      switch (ptype)
+      {
+      case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END:
+        ret = GNUNET_YES;
+        break;
+      case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL:
+        ret = GNUNET_SYSERR;
+        break;
+      }
+      switch (ptype)
+      {
+      case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END:
+      case GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL:
+        tmit_frag = psyc_transmit_queue_next_part (plc, tmit_msg, tmit_frag);
+      }
+    }
 
     if (NULL == tmit_msg->frags_head
         && GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END <= ptype)
@@ -1060,12 +1079,6 @@
     *data_size = mod_size;
     memcpy (data, &pmod[1], mod_size);
     ret = GNUNET_NO;
-#if REMOVE // FIXME
-    ret = (mod_size - strnlen ((char *) &pmod[1], mod_size) - 1
-           == *full_value_size)
-      ? GNUNET_YES
-      : GNUNET_NO;
-#endif
     break;
   }
 
@@ -1120,7 +1133,8 @@
   }
   else
   {
-    psyc_transmit_queue_next_part (plc, tmit_msg, tmit_frag);
+    if (GNUNET_YES != ret)
+      psyc_transmit_queue_next_part (plc, tmit_msg, tmit_frag);
 
     if (NULL == tmit_msg->frags_head
         && GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END <= ptype)
@@ -1241,7 +1255,6 @@
 
   uint16_t psize = ntohs (pmsg->size);
   *pmeth = (struct GNUNET_PSYC_MessageMethod *) pmsg;
-
   if (psize < sizeof (**pmeth) + 1 || '\0' != *((char *) *pmeth + psize - 1))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -1253,6 +1266,7 @@
     GNUNET_break (0);
     return GNUNET_SYSERR;
   }
+
   psyc_transmit_queue_next_part (plc, tmit_msg, tmit_frag);
   return GNUNET_OK;
 }

Modified: gnunet/src/social/social_api.c
===================================================================
--- gnunet/src/social/social_api.c      2014-07-24 06:00:09 UTC (rev 34025)
+++ gnunet/src/social/social_api.c      2014-07-24 07:59:21 UTC (rev 34026)
@@ -1458,14 +1458,17 @@
  *         otherwise handle to cancel the request.
  */
 struct GNUNET_SOCIAL_TalkRequest *
-GNUNET_SOCIAL_guest_talk (struct GNUNET_SOCIAL_Guest *guest,
+GNUNET_SOCIAL_guest_talk (struct GNUNET_SOCIAL_Guest *gst,
                           const char *method_name,
                           const struct GNUNET_ENV_Environment *env,
                           GNUNET_PSYC_TransmitNotifyData notify_data,
                           void *notify_data_cls,
                           enum GNUNET_SOCIAL_TalkFlags flags)
 {
-  return NULL;
+  if (GNUNET_OK ==
+      GNUNET_PSYC_transmit_message (gst->plc.tmit, method_name, env,
+                                    NULL, notify_data, notify_data_cls, 
flags));
+  return (struct GNUNET_SOCIAL_TalkRequest *) gst->plc.tmit;
 }
 
 

Modified: gnunet/src/social/test_social.c
===================================================================
--- gnunet/src/social/test_social.c     2014-07-24 06:00:09 UTC (rev 34025)
+++ gnunet/src/social/test_social.c     2014-07-24 07:59:21 UTC (rev 34026)
@@ -38,7 +38,7 @@
 
 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
 
-#define DEBUG_SERVICE 0
+#define DEBUG_SERVICE 1
 #define DATA2ARG(data) data, sizeof (data)
 
 /**
@@ -110,9 +110,8 @@
   TEST_HOST_ANNOUNCE     = 5,
   TEST_HOST_ANNOUNCE_END = 6,
   TEST_GUEST_TALK        = 7,
-  TEST_GUEST_TALK_END    = 8,
-  TEST_GUEST_LEAVE       = 9,
-  TEST_HOST_LEAVE       = 10,
+  TEST_GUEST_LEAVE       = 8,
+  TEST_HOST_LEAVE        = 9,
 } test;
 
 
@@ -294,6 +293,8 @@
                size_t variable_count,
                struct GNUNET_ENV_Modifier *variables)
 {
+  // FIXME: this function is not called yet
+
   struct GNUNET_CRYPTO_EcdsaPublicKey *
     nym_key = GNUNET_SOCIAL_nym_get_key (nym);
   GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -319,7 +320,7 @@
 
 
 void
-schedule_guest_leave (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+guest_leave()
 {
   test = TEST_GUEST_LEAVE;
   /* FIXME test keep_active */
@@ -396,14 +397,6 @@
     guest_talk ();
     break;
 
-  case TEST_GUEST_TALK:
-    test = TEST_GUEST_TALK_END;
-    break;
-
-  case TEST_GUEST_TALK_END:
-    GNUNET_SCHEDULER_add_now (&schedule_guest_leave, NULL);
-    break;
-
   default:
     GNUNET_assert (0);
   }
@@ -480,13 +473,9 @@
     break;
 
   case TEST_GUEST_TALK:
-    test = TEST_GUEST_TALK_END;
+    guest_leave ();
     break;
 
-  case TEST_GUEST_TALK_END:
-    GNUNET_SCHEDULER_add_now (&schedule_guest_leave, NULL);
-    break;
-
   default:
     GNUNET_assert (0);
   }
@@ -509,10 +498,10 @@
   tmit.data[2] = "testing ten nine eight";
   tmit.data_count = 3;
 
-  tmit.host_ann
-    = GNUNET_SOCIAL_host_announce (hst, "_message_guest", tmit.env,
-                                   &notify_data, &tmit,
-                                   GNUNET_SOCIAL_TALK_NONE);
+  tmit.guest_talk
+    = GNUNET_SOCIAL_guest_talk (gst, "_message_guest", tmit.env,
+                                &notify_data, &tmit,
+                                GNUNET_SOCIAL_TALK_NONE);
 }
 
 void




reply via email to

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