gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r33608 - gnunet/src/scalarproduct
Date: Sun, 8 Jun 2014 23:05:40 +0200

Author: cfuchs
Date: 2014-06-08 23:05:40 +0200 (Sun, 08 Jun 2014)
New Revision: 33608

Modified:
   gnunet/src/scalarproduct/gnunet-service-scalarproduct.c
Log:
- more scalarproduct bugfixing
- added some more useful debug output to scalarproduct

Modified: gnunet/src/scalarproduct/gnunet-service-scalarproduct.c
===================================================================
--- gnunet/src/scalarproduct/gnunet-service-scalarproduct.c     2014-06-08 
18:19:03 UTC (rev 33607)
+++ gnunet/src/scalarproduct/gnunet-service-scalarproduct.c     2014-06-08 
21:05:40 UTC (rev 33608)
@@ -1174,7 +1174,7 @@
   e->val = gcry_mpi_new (0);
   val = (int64_t) GNUNET_ntohll (e->elem->value);
   if (0 > val)
-    gcry_mpi_sub_ui (e->val, e->val, - val);
+    gcry_mpi_sub_ui (e->val, e->val, -val);
   else
     gcry_mpi_add_ui (e->val, e->val, val);
 
@@ -1185,9 +1185,9 @@
     GNUNET_CONTAINER_DLL_insert (s->a_head, s->a_tail, e);
     return GNUNET_YES;
   }
-  // insert as last element with the highest key
-  if (0 >= GNUNET_CRYPTO_hash_cmp (&s->a_tail->elem->key, &e->elem->key))
+  else if (0 > GNUNET_CRYPTO_hash_cmp (&s->a_tail->elem->key, &e->elem->key))
   {
+    // insert as last element with the highest key
     GNUNET_CONTAINER_DLL_insert_tail (s->a_head, s->a_tail, e);
     return GNUNET_YES;
   }
@@ -1234,24 +1234,24 @@
     GNUNET_CONTAINER_multihashmap_remove (s->intersected_elements,
                                           element->data,
                                           se);
-    s->used_element_count--;
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "%s: removed element with key %s value 
%d\n", s->role == ALICE ? "ALICE" : "BOB", GNUNET_h2s(&se->key), se->value);
     return;
 
   case GNUNET_SET_STATUS_DONE:
     s->intersection_op = NULL;
     s->intersection_set = NULL;
 
+    s->used_element_count = GNUNET_CONTAINER_multihashmap_iterate 
(s->intersected_elements,
+                                           &cb_insert_element_sorted,
+                                           s);
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "%s: Finished intersection, %d items 
remain\n", s->role == ALICE ? "ALICE" : "BOB", s->used_element_count);
     if (2 > s->used_element_count)
     {
       // failed! do not leak information about our single remaining element!
       // continue after the loop
       break;
     }
-
-    GNUNET_CONTAINER_multihashmap_iterate (s->intersected_elements,
-                                           &cb_insert_element_sorted,
-                                           s);
-
+    
     s->sorted_elements = GNUNET_malloc (s->used_element_count * sizeof 
(gcry_mpi_t));
     for (i = 0; NULL != s->a_head; i++)
     {
@@ -1275,6 +1275,7 @@
     }
     break;
   default:
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "%s: OOOPS %d", s->role == ALICE ? "ALICE" : 
"BOB", status);
     if (NULL != s->intersection_listen)
     {
       GNUNET_SET_listen_cancel (s->intersection_listen);
@@ -1282,15 +1283,15 @@
     }
     
     // the op failed and has already been invalidated by the set service
-    s->intersection_op = NULL;
-    s->intersection_set = NULL;
     break;
   }
 
+  s->intersection_op = NULL;
+  s->intersection_set = NULL;
+  
   //failed if we go here
   GNUNET_break_op (0);
 
-
   // and notify our client-session that we could not complete the session
   if (ALICE == s->role) {
     s->active = GNUNET_SYSERR;




reply via email to

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