aboutsummaryrefslogtreecommitdiff
path: root/src/scalarproduct
diff options
context:
space:
mode:
authorChristian Fuchs <christian.fuchs@cfuchs.net>2014-06-08 21:05:40 +0000
committerChristian Fuchs <christian.fuchs@cfuchs.net>2014-06-08 21:05:40 +0000
commite703948983a444cf4204913602aac2191d72dc8b (patch)
treed8e2499be6f9bc060fd4ccf7e612534663659807 /src/scalarproduct
parenta860f03c736a43edf67bd9166eccbae2a553991d (diff)
downloadgnunet-e703948983a444cf4204913602aac2191d72dc8b.tar.gz
gnunet-e703948983a444cf4204913602aac2191d72dc8b.zip
- more scalarproduct bugfixing
- added some more useful debug output to scalarproduct
Diffstat (limited to 'src/scalarproduct')
-rw-r--r--src/scalarproduct/gnunet-service-scalarproduct.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/scalarproduct/gnunet-service-scalarproduct.c b/src/scalarproduct/gnunet-service-scalarproduct.c
index f983cdc42..fd9980060 100644
--- a/src/scalarproduct/gnunet-service-scalarproduct.c
+++ b/src/scalarproduct/gnunet-service-scalarproduct.c
@@ -1174,7 +1174,7 @@ cb_insert_element_sorted (void *cls,
1174 e->val = gcry_mpi_new (0); 1174 e->val = gcry_mpi_new (0);
1175 val = (int64_t) GNUNET_ntohll (e->elem->value); 1175 val = (int64_t) GNUNET_ntohll (e->elem->value);
1176 if (0 > val) 1176 if (0 > val)
1177 gcry_mpi_sub_ui (e->val, e->val, - val); 1177 gcry_mpi_sub_ui (e->val, e->val, -val);
1178 else 1178 else
1179 gcry_mpi_add_ui (e->val, e->val, val); 1179 gcry_mpi_add_ui (e->val, e->val, val);
1180 1180
@@ -1185,9 +1185,9 @@ cb_insert_element_sorted (void *cls,
1185 GNUNET_CONTAINER_DLL_insert (s->a_head, s->a_tail, e); 1185 GNUNET_CONTAINER_DLL_insert (s->a_head, s->a_tail, e);
1186 return GNUNET_YES; 1186 return GNUNET_YES;
1187 } 1187 }
1188 // insert as last element with the highest key 1188 else if (0 > GNUNET_CRYPTO_hash_cmp (&s->a_tail->elem->key, &e->elem->key))
1189 if (0 >= GNUNET_CRYPTO_hash_cmp (&s->a_tail->elem->key, &e->elem->key))
1190 { 1189 {
1190 // insert as last element with the highest key
1191 GNUNET_CONTAINER_DLL_insert_tail (s->a_head, s->a_tail, e); 1191 GNUNET_CONTAINER_DLL_insert_tail (s->a_head, s->a_tail, e);
1192 return GNUNET_YES; 1192 return GNUNET_YES;
1193 } 1193 }
@@ -1234,24 +1234,24 @@ cb_intersection_element_removed (void *cls,
1234 GNUNET_CONTAINER_multihashmap_remove (s->intersected_elements, 1234 GNUNET_CONTAINER_multihashmap_remove (s->intersected_elements,
1235 element->data, 1235 element->data,
1236 se); 1236 se);
1237 s->used_element_count--; 1237 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);
1238 return; 1238 return;
1239 1239
1240 case GNUNET_SET_STATUS_DONE: 1240 case GNUNET_SET_STATUS_DONE:
1241 s->intersection_op = NULL; 1241 s->intersection_op = NULL;
1242 s->intersection_set = NULL; 1242 s->intersection_set = NULL;
1243 1243
1244 s->used_element_count = GNUNET_CONTAINER_multihashmap_iterate (s->intersected_elements,
1245 &cb_insert_element_sorted,
1246 s);
1247 LOG (GNUNET_ERROR_TYPE_DEBUG, "%s: Finished intersection, %d items remain\n", s->role == ALICE ? "ALICE" : "BOB", s->used_element_count);
1244 if (2 > s->used_element_count) 1248 if (2 > s->used_element_count)
1245 { 1249 {
1246 // failed! do not leak information about our single remaining element! 1250 // failed! do not leak information about our single remaining element!
1247 // continue after the loop 1251 // continue after the loop
1248 break; 1252 break;
1249 } 1253 }
1250 1254
1251 GNUNET_CONTAINER_multihashmap_iterate (s->intersected_elements,
1252 &cb_insert_element_sorted,
1253 s);
1254
1255 s->sorted_elements = GNUNET_malloc (s->used_element_count * sizeof (gcry_mpi_t)); 1255 s->sorted_elements = GNUNET_malloc (s->used_element_count * sizeof (gcry_mpi_t));
1256 for (i = 0; NULL != s->a_head; i++) 1256 for (i = 0; NULL != s->a_head; i++)
1257 { 1257 {
@@ -1275,6 +1275,7 @@ cb_intersection_element_removed (void *cls,
1275 } 1275 }
1276 break; 1276 break;
1277 default: 1277 default:
1278 LOG (GNUNET_ERROR_TYPE_DEBUG, "%s: OOOPS %d", s->role == ALICE ? "ALICE" : "BOB", status);
1278 if (NULL != s->intersection_listen) 1279 if (NULL != s->intersection_listen)
1279 { 1280 {
1280 GNUNET_SET_listen_cancel (s->intersection_listen); 1281 GNUNET_SET_listen_cancel (s->intersection_listen);
@@ -1282,15 +1283,15 @@ cb_intersection_element_removed (void *cls,
1282 } 1283 }
1283 1284
1284 // the op failed and has already been invalidated by the set service 1285 // the op failed and has already been invalidated by the set service
1285 s->intersection_op = NULL;
1286 s->intersection_set = NULL;
1287 break; 1286 break;
1288 } 1287 }
1289 1288
1289 s->intersection_op = NULL;
1290 s->intersection_set = NULL;
1291
1290 //failed if we go here 1292 //failed if we go here
1291 GNUNET_break_op (0); 1293 GNUNET_break_op (0);
1292 1294
1293
1294 // and notify our client-session that we could not complete the session 1295 // and notify our client-session that we could not complete the session
1295 if (ALICE == s->role) { 1296 if (ALICE == s->role) {
1296 s->active = GNUNET_SYSERR; 1297 s->active = GNUNET_SYSERR;