gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r29213 - gnunet/src/scalarproduct


From: gnunet
Subject: [GNUnet-SVN] r29213 - gnunet/src/scalarproduct
Date: Wed, 11 Sep 2013 17:55:47 +0200

Author: cfuchs
Date: 2013-09-11 17:55:47 +0200 (Wed, 11 Sep 2013)
New Revision: 29213

Modified:
   gnunet/src/scalarproduct/gnunet-scalarproduct.c
   gnunet/src/scalarproduct/gnunet-service-scalarproduct.c
   gnunet/src/scalarproduct/scalarproduct_api.c
Log:
removed a couple of extra checks from the SP-api
fixed a silly bug in the SP-client
removed two incorrect frees in the SP-service


Modified: gnunet/src/scalarproduct/gnunet-scalarproduct.c
===================================================================
--- gnunet/src/scalarproduct/gnunet-scalarproduct.c     2013-09-11 15:25:09 UTC 
(rev 29212)
+++ gnunet/src/scalarproduct/gnunet-scalarproduct.c     2013-09-11 15:55:47 UTC 
(rev 29213)
@@ -254,7 +254,7 @@
     // get the length of the current element and replace , with null
     for (end = begin; *end && *end != ','; end++);
 
-    if (1 == sscanf (begin, "%" SCNd32",", &element))
+    if (1 == sscanf (begin, "%" SCNd32",", &elements[element_count]))
     {
       //element in the middle
       element_count++;

Modified: gnunet/src/scalarproduct/gnunet-service-scalarproduct.c
===================================================================
--- gnunet/src/scalarproduct/gnunet-service-scalarproduct.c     2013-09-11 
15:25:09 UTC (rev 29212)
+++ gnunet/src/scalarproduct/gnunet-service-scalarproduct.c     2013-09-11 
15:55:47 UTC (rev 29213)
@@ -681,7 +681,7 @@
                           struct GNUNET_SERVER_Client *client)
 {
   struct ServiceSession *session;
-
+  
   session = GNUNET_SERVER_client_get_user_context (client, struct 
ServiceSession);
   if (NULL == session)
     return;
@@ -1345,11 +1345,10 @@
             session->used_element_count++;
         }
 
-      if ( ! session->used_element_count)
+      if ( 0 == session->used_element_count)
         {
           GNUNET_break_op (0);
           GNUNET_free (session->vector);
-          GNUNET_free (session->a);
           GNUNET_free (session);
           GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
           return;
@@ -1359,7 +1358,6 @@
         {
           GNUNET_break (0);
           GNUNET_free (session->vector);
-          GNUNET_free (session->a);
           GNUNET_free (session);
           GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
           return;
@@ -1379,7 +1377,6 @@
         {
           GNUNET_break (0);
           GNUNET_free (session->vector);
-          GNUNET_free (session->a);
           GNUNET_free (session);
           GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
           return;

Modified: gnunet/src/scalarproduct/scalarproduct_api.c
===================================================================
--- gnunet/src/scalarproduct/scalarproduct_api.c        2013-09-11 15:25:09 UTC 
(rev 29212)
+++ gnunet/src/scalarproduct/scalarproduct_api.c        2013-09-11 15:55:47 UTC 
(rev 29213)
@@ -39,6 +39,13 @@
  **************************************************************/
 
 /**
+ * the abstraction function for our internal callback
+ */
+typedef void (*GNUNET_SCALARPRODUCT_ResponseMessageHandler) (void *cls,
+                                                             const struct 
GNUNET_MessageHeader *msg,
+                                                             enum 
GNUNET_SCALARPRODUCT_ResponseStatus status);
+
+/**
  * Entry in the request queue per client
  */
 struct GNUNET_SCALARPRODUCT_ComputationHandle
@@ -90,15 +97,15 @@
 
   union
   {
-    /**
-     * Function to call after transmission of the request.
-     */
-    GNUNET_SCALARPRODUCT_ContinuationWithStatus cont_status;
+  /**
+   * Function to call after transmission of the request.
+   */
+  GNUNET_SCALARPRODUCT_ContinuationWithStatus cont_status;
 
-    /**
-     * Function to call after transmission of the request.
-     */
-    GNUNET_SCALARPRODUCT_DatumProcessor cont_datum;
+  /**
+   * Function to call after transmission of the request.
+   */
+  GNUNET_SCALARPRODUCT_DatumProcessor cont_datum;
   };
 
   /**
@@ -173,8 +180,7 @@
   gcry_mpi_t result = NULL;
   gcry_error_t rc;
 
-  if (GNUNET_SCALARPRODUCT_Status_Success == status
-      && qe->cont_datum != NULL)
+  if (GNUNET_SCALARPRODUCT_Status_Success == status)
     {
       size_t product_len = ntohl (message->product_length);
       result = gcry_mpi_new (0);
@@ -239,7 +245,7 @@
 
       status = GNUNET_SCALARPRODUCT_Status_Success;
     }
-
+  
   if (qe->cont_datum != NULL)
     qe->response_proc (qe, msg, status);
 
@@ -272,6 +278,7 @@
       // notify caller about the error, done here.
       if (qe->cont_datum != NULL)
         qe->response_proc (qe, NULL, GNUNET_SCALARPRODUCT_Status_Failure);
+      
       GNUNET_SCALARPRODUCT_cancel (cls);
       return 0;
     }
@@ -322,10 +329,6 @@
   uint16_t size;
   uint64_t i;
 
-  GNUNET_assert (key);
-  GNUNET_assert (elements);
-  GNUNET_assert (cont);
-  GNUNET_assert (element_count > 1);
   GNUNET_assert (GNUNET_SERVER_MAX_MESSAGE_SIZE >= sizeof (struct 
GNUNET_SCALARPRODUCT_client_request)
                  +element_count * sizeof (int32_t));
   h = GNUNET_new (struct GNUNET_SCALARPRODUCT_ComputationHandle);
@@ -459,7 +462,7 @@
   // copy each element over to the message
   for (i = 0; i < element_count; i++)
     vector[i] = htonl (elements[i]);
-
+  
   memcpy (&msg->peer, peer, sizeof (struct GNUNET_PeerIdentity));
   memcpy (&msg->key, key, sizeof (struct GNUNET_HashCode));
   memcpy (&vector[element_count], mask, mask_bytes);




reply via email to

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