gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r23743 - in gnunet/src: include testbed


From: gnunet
Subject: [GNUnet-SVN] r23743 - in gnunet/src: include testbed
Date: Mon, 10 Sep 2012 22:33:02 +0200

Author: harsha
Date: 2012-09-10 22:33:02 +0200 (Mon, 10 Sep 2012)
New Revision: 23743

Modified:
   gnunet/src/include/gnunet_testbed_service.h
   gnunet/src/testbed/testbed_api.c
   gnunet/src/testbed/testbed_api_peers.c
Log:
cleanup when operations fail

Modified: gnunet/src/include/gnunet_testbed_service.h
===================================================================
--- gnunet/src/include/gnunet_testbed_service.h 2012-09-10 19:19:17 UTC (rev 
23742)
+++ gnunet/src/include/gnunet_testbed_service.h 2012-09-10 20:33:02 UTC (rev 
23743)
@@ -736,9 +736,10 @@
 
 
 /**
- * Request information about a peer. The controller callback will be called 
with
- * event type GNUNET_TESTBED_ET_OPERATION_FINISHED when result for this
- * operation is available
+ * Request information about a peer. The controller callback will not be called
+ * with event type GNUNET_TESTBED_ET_OPERATION_FINISHED when result for this
+ * operation is available. Instead, the GNUNET_TESTBED_PeerInfoCallback() will
+ * be called.
  *
  * @param peer peer to request information about
  * @param pit desired information

Modified: gnunet/src/testbed/testbed_api.c
===================================================================
--- gnunet/src/testbed/testbed_api.c    2012-09-10 19:19:17 UTC (rev 23742)
+++ gnunet/src/testbed/testbed_api.c    2012-09-10 20:33:02 UTC (rev 23743)
@@ -626,10 +626,9 @@
                       *msg)
 {
   struct OperationContext *opc;
-  char *emsg;
+  const char *emsg;
   uint64_t op_id;
   struct GNUNET_TESTBED_EventInformation event;
-  uint16_t msize;
 
   op_id = GNUNET_ntohll (msg->operation_id);
   if (NULL == (opc = find_opc (c, op_id)))
@@ -637,6 +636,7 @@
     LOG_DEBUG ("Operation not found\n");
     return GNUNET_YES;
   }
+  GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc);
   if (OP_FORWARDED == opc->type)
   {
     struct ForwardedOperationData *fo_data;
@@ -644,27 +644,23 @@
     fo_data = opc->data;
     if (NULL != fo_data->cc)
       fo_data->cc (fo_data->cc_cls, (const struct GNUNET_MessageHeader *) msg);
-    GNUNET_CONTAINER_DLL_remove (c->ocq_head, c->ocq_tail, opc);
     GNUNET_free (fo_data);
     GNUNET_free (opc);
     return GNUNET_YES;
   }
-  GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc);
   opc->state = OPC_STATE_FINISHED;
-  switch (opc->type)
+  emsg = GNUNET_TESTBED_parse_error_string_ (msg);
+  if (NULL == emsg)
+    emsg = "Unknown error";
+  if (OP_PEER_INFO == opc->type)
   {
-    /* FIXME: Cleanup the data pointer depending on the type of opc */
-  default:
-    GNUNET_break (0);
+    struct PeerInfoData *data;
+    data = opc->data;
+    if (NULL != data->cb)
+      data->cb (data->cb_cls, opc->op, NULL, emsg);
+    GNUNET_free (data);
+    return GNUNET_YES;  /* We do not call controller callback for peer info */
   }
-  msize = ntohs (msg->header.size);
-  emsg = NULL;
-  if (msize > sizeof (struct GNUNET_TESTBED_OperationFailureEventMessage))
-  {
-    msize -= sizeof (struct GNUNET_TESTBED_OperationFailureEventMessage);
-    emsg = (char *) &msg[1];
-    GNUNET_assert ('\0' == emsg[msize - 1]);
-  }
   if ((0 != (GNUNET_TESTBED_ET_OPERATION_FINISHED & c->event_mask)) &&
       (NULL != c->cc))
   {
@@ -675,6 +671,48 @@
     event.details.operation_finished.generic = NULL;
     c->cc (c->cc_cls, &event);
   }
+  switch (opc->type)
+  {
+  case OP_PEER_CREATE:
+    {
+      struct PeerCreateData *data;      
+      data = opc->data;
+      GNUNET_free (data->peer);
+      if (NULL != data->cb)
+        data->cb (data->cls, NULL, emsg);
+      GNUNET_free (data);      
+    }
+    break;
+  case OP_PEER_START:
+  case OP_PEER_STOP:
+    {
+      struct PeerEventData *data;
+      data = opc->data;
+      if (NULL != data->pcc)
+        data->pcc (data->pcc_cls, emsg);
+      GNUNET_free (data);
+    }
+    break;
+  case OP_PEER_DESTROY:
+    break;
+  case OP_PEER_INFO:
+    GNUNET_assert (0);
+  case OP_OVERLAY_CONNECT:
+    {
+      struct OverlayConnectData *data;
+      data = opc->data;
+      if (NULL != data->cb)
+        data->cb (data->cb_cls, opc->op, emsg);
+      GNUNET_free (data);
+    }
+    break;
+  case OP_FORWARDED:
+    GNUNET_assert (0);
+  case OP_LINK_CONTROLLERS:     /* No secondary callback */
+    break;
+  default:
+    GNUNET_break (0);
+  }  
   return GNUNET_YES;
 }
 
@@ -1760,7 +1798,7 @@
 
 
 /**
- * Checks the integrity of the OpeationFailureEventMessage and if good returns
+ * Checks the integrity of the OperationFailureEventMessage and if good returns
  * the error message it contains.
  *
  * @param msg the OperationFailureEventMessage
@@ -1775,7 +1813,7 @@
   const char *emsg;
   
   msize = ntohs (msg->header.size);
-  if (sizeof (struct GNUNET_TESTBED_OperationFailureEventMessage) == msize)
+  if (sizeof (struct GNUNET_TESTBED_OperationFailureEventMessage) >= msize)
     return NULL;
   msize -= sizeof (struct GNUNET_TESTBED_OperationFailureEventMessage);
   emsg = (const char *) &msg[1];

Modified: gnunet/src/testbed/testbed_api_peers.c
===================================================================
--- gnunet/src/testbed/testbed_api_peers.c      2012-09-10 19:19:17 UTC (rev 
23742)
+++ gnunet/src/testbed/testbed_api_peers.c      2012-09-10 20:33:02 UTC (rev 
23743)
@@ -562,9 +562,10 @@
 
 
 /**
- * Request information about a peer. The controller callback will be called 
with
- * event type GNUNET_TESTBED_ET_OPERATION_FINISHED when result for this
- * operation is available
+ * Request information about a peer. The controller callback will not be called
+ * with event type GNUNET_TESTBED_ET_OPERATION_FINISHED when result for this
+ * operation is available. Instead, the GNUNET_TESTBED_PeerInfoCallback() will
+ * be called.
  *
  * @param peer peer to request information about
  * @param pit desired information




reply via email to

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