[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r34508 - gnunet/src/scalarproduct
From: |
gnunet |
Subject: |
[GNUnet-SVN] r34508 - gnunet/src/scalarproduct |
Date: |
Mon, 8 Dec 2014 01:17:15 +0100 |
Author: grothoff
Date: 2014-12-08 01:17:15 +0100 (Mon, 08 Dec 2014)
New Revision: 34508
Modified:
gnunet/src/scalarproduct/gnunet-scalarproduct.c
gnunet/src/scalarproduct/gnunet-service-scalarproduct_alice.c
gnunet/src/scalarproduct/gnunet-service-scalarproduct_bob.c
Log:
-fix shutdown
Modified: gnunet/src/scalarproduct/gnunet-scalarproduct.c
===================================================================
--- gnunet/src/scalarproduct/gnunet-scalarproduct.c 2014-12-08 00:17:08 UTC
(rev 34507)
+++ gnunet/src/scalarproduct/gnunet-scalarproduct.c 2014-12-08 00:17:15 UTC
(rev 34508)
@@ -137,7 +137,11 @@
if (0 == (rc = gcry_mpi_aprint (GCRYMPI_FMT_HEX, &buf, NULL, result)))
{
ret = 0;
- printf ("%s", buf);
+ fprintf (stdout,
+ "%s%s\n",
+ (0 > gcry_mpi_cmp_ui (result, 0)) ? "-" : "",
+ buf);
+ fflush (stdout);
}
else
LOG_GCRY (GNUNET_ERROR_TYPE_ERROR,
Modified: gnunet/src/scalarproduct/gnunet-service-scalarproduct_alice.c
===================================================================
--- gnunet/src/scalarproduct/gnunet-service-scalarproduct_alice.c
2014-12-08 00:17:08 UTC (rev 34507)
+++ gnunet/src/scalarproduct/gnunet-service-scalarproduct_alice.c
2014-12-08 00:17:15 UTC (rev 34508)
@@ -164,9 +164,15 @@
* Already transferred elements from client to us.
* Less or equal than @e total.
*/
- uint32_t transferred_element_count;
+ uint32_t client_received_element_count;
/**
+ * Already transferred elements from Bob to us.
+ * Less or equal than @e total.
+ */
+ uint32_t cadet_received_element_count;
+
+ /**
* State of this session. In
* #GNUNET_SCALARPRODUCT_STATUS_ACTIVE while operation is
* ongoing, afterwards in #GNUNET_SCALARPRODUCT_STATUS_SUCCESS or
@@ -400,6 +406,7 @@
e = GNUNET_MQ_msg_extra (msg,
product_length,
GNUNET_MESSAGE_TYPE_SCALARPRODUCT_RESULT);
+ msg->status = htonl (GNUNET_SCALARPRODUCT_STATUS_SUCCESS);
msg->range = htonl (range);
msg->product_length = htonl (product_length);
if (NULL != product_exported)
@@ -669,7 +676,7 @@
required_size = sizeof (struct BobCryptodataMultipartMessage)
+ 2 * contained * sizeof (struct GNUNET_CRYPTO_PaillierCiphertext);
if ( (required_size != msg_size) ||
- (s->transferred_element_count + contained > s->used_element_count) )
+ (s->cadet_received_element_count + contained > s->used_element_count) )
{
GNUNET_break (0);
return GNUNET_SYSERR;
@@ -683,16 +690,16 @@
/* Convert each k[][perm] to its MPI_value */
for (i = 0; i < contained; i++)
{
- memcpy (&s->r[s->transferred_element_count + i],
+ memcpy (&s->r[s->cadet_received_element_count + i],
&payload[2 * i],
sizeof (struct GNUNET_CRYPTO_PaillierCiphertext));
- memcpy (&s->r_prime[s->transferred_element_count + i],
+ memcpy (&s->r_prime[s->cadet_received_element_count + i],
&payload[2 * i],
sizeof (struct GNUNET_CRYPTO_PaillierCiphertext));
}
- s->transferred_element_count += contained;
+ s->cadet_received_element_count += contained;
GNUNET_CADET_receive_done (s->channel);
- if (s->transferred_element_count != s->used_element_count)
+ if (s->cadet_received_element_count != s->used_element_count)
return GNUNET_OK;
s->product = compute_scalar_product (s);
@@ -749,14 +756,18 @@
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
- if ( (NULL == s->sorted_elements) ||
- (s->used_element_count != s->transferred_element_count) )
+ if (NULL == s->sorted_elements)
{
/* we're not ready yet, how can Bob be? */
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
-
+ if (s->total != s->client_received_element_count)
+ {
+ /* we're not ready yet, how can Bob be? */
+ GNUNET_break_op (0);
+ return GNUNET_SYSERR;
+ }
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received %u crypto values from Bob\n",
(unsigned int) contained);
@@ -781,10 +792,10 @@
&payload[2 * i + 1],
sizeof (struct GNUNET_CRYPTO_PaillierCiphertext));
}
- s->transferred_element_count = contained;
+ s->cadet_received_element_count = contained;
GNUNET_CADET_receive_done (s->channel);
- if (s->transferred_element_count != s->used_element_count)
+ if (s->cadet_received_element_count != s->used_element_count)
{
/* More to come */
return GNUNET_OK;
@@ -954,7 +965,11 @@
return;
case GNUNET_SET_STATUS_DONE:
s->intersection_op = NULL;
- s->intersection_set = NULL;
+ if (NULL != s->intersection_set)
+ {
+ GNUNET_SET_destroy (s->intersection_set);
+ s->intersection_set = NULL;
+ }
send_alices_cryptodata_message (s);
return;
case GNUNET_SET_STATUS_HALF_DONE:
@@ -971,7 +986,11 @@
s->intersection_listen = NULL;
}
s->intersection_op = NULL;
- s->intersection_set = NULL;
+ if (NULL != s->intersection_set)
+ {
+ GNUNET_SET_destroy (s->intersection_set);
+ s->intersection_set = NULL;
+ }
s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE;
prepare_client_end_notification (s);
return;
@@ -1028,11 +1047,14 @@
GNUNET_SET_commit (s->intersection_op,
s->intersection_set))
{
+ GNUNET_break (0);
s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE;
prepare_client_end_notification (s);
return;
}
+ GNUNET_SET_destroy (s->intersection_set);
s->intersection_set = NULL;
+ GNUNET_SET_listen_cancel (s->intersection_listen);
s->intersection_listen = NULL;
}
@@ -1134,15 +1156,15 @@
if ( (msize != (sizeof (struct ComputationBobCryptodataMultipartMessage) +
contained_count * sizeof (struct
GNUNET_SCALARPRODUCT_Element))) ||
(0 == contained_count) ||
- (s->total == s->transferred_element_count) ||
- (s->total < s->transferred_element_count + contained_count) )
+ (s->total == s->client_received_element_count) ||
+ (s->total < s->client_received_element_count + contained_count) )
{
GNUNET_break_op (0);
GNUNET_SERVER_receive_done (client,
GNUNET_SYSERR);
return;
}
- s->transferred_element_count += contained_count;
+ s->client_received_element_count += contained_count;
elements = (const struct GNUNET_SCALARPRODUCT_Element *) &msg[1];
for (i = 0; i < contained_count; i++)
{
@@ -1172,7 +1194,7 @@
}
GNUNET_SERVER_receive_done (client,
GNUNET_OK);
- if (s->total != s->transferred_element_count)
+ if (s->total != s->client_received_element_count)
{
/* more to come */
return;
@@ -1240,7 +1262,7 @@
s->client = client;
s->client_mq = GNUNET_MQ_queue_for_server_client (client);
s->total = total_count;
- s->transferred_element_count = contained_count;
+ s->client_received_element_count = contained_count;
s->session_id = msg->session_key;
elements = (const struct GNUNET_SCALARPRODUCT_Element *) &msg[1];
s->intersected_elements = GNUNET_CONTAINER_multihashmap_create (s->total,
@@ -1278,7 +1300,7 @@
s);
GNUNET_SERVER_receive_done (client,
GNUNET_OK);
- if (s->total != s->transferred_element_count)
+ if (s->total != s->client_received_element_count)
{
/* wait for multipart msg */
return;
Modified: gnunet/src/scalarproduct/gnunet-service-scalarproduct_bob.c
===================================================================
--- gnunet/src/scalarproduct/gnunet-service-scalarproduct_bob.c 2014-12-08
00:17:08 UTC (rev 34507)
+++ gnunet/src/scalarproduct/gnunet-service-scalarproduct_bob.c 2014-12-08
00:17:15 UTC (rev 34508)
@@ -992,7 +992,7 @@
return;
case GNUNET_SET_STATUS_DONE:
s->intersection_op = NULL;
- s->intersection_set = NULL;
+ GNUNET_break (NULL == s->intersection_set);
GNUNET_CADET_receive_done (s->cadet->channel);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Finished intersection, %d items remain\n",
@@ -1014,7 +1014,11 @@
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Set intersection failed!\n");
s->intersection_op = NULL;
- s->intersection_set = NULL;
+ if (NULL != s->intersection_set)
+ {
+ GNUNET_SET_destroy (s->intersection_set);
+ s->intersection_set = NULL;
+ }
s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE;
prepare_client_end_notification (s);
return;
@@ -1046,8 +1050,17 @@
GNUNET_SET_RESULT_REMOVED,
&cb_intersection_element_removed,
s);
- GNUNET_SET_commit (s->intersection_op,
- s->intersection_set);
+ if (GNUNET_OK !=
+ GNUNET_SET_commit (s->intersection_op,
+ s->intersection_set))
+ {
+ GNUNET_break (0);
+ s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE;
+ prepare_client_end_notification (s);
+ return;
+ }
+ GNUNET_SET_destroy (s->intersection_set);
+ s->intersection_set = NULL;
}
@@ -1138,7 +1151,7 @@
in = GNUNET_new (struct CadetIncomingSession);
in->peer = *initiator;
in->channel = channel;
- // in->cadet_mq = GNUNET_CADET_mq_create (in->channel);
+ in->cadet_mq = GNUNET_CADET_mq_create (in->channel);
return in;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r34508 - gnunet/src/scalarproduct,
gnunet <=