aboutsummaryrefslogtreecommitdiff
path: root/src/scalarproduct/gnunet-service-scalarproduct_alice.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-12-07 22:54:20 +0000
committerChristian Grothoff <christian@grothoff.org>2014-12-07 22:54:20 +0000
commit840ea5278ccb38427c76c6c14682664c643150f9 (patch)
tree7d26fd458b794bc971857710914740dffd9505cb /src/scalarproduct/gnunet-service-scalarproduct_alice.c
parent629a4960f97c50422770c1267aeddb175b8b89a7 (diff)
downloadgnunet-840ea5278ccb38427c76c6c14682664c643150f9.tar.gz
gnunet-840ea5278ccb38427c76c6c14682664c643150f9.zip
-style, actually call GNUNET_CADET_receive_done to receive more messages
Diffstat (limited to 'src/scalarproduct/gnunet-service-scalarproduct_alice.c')
-rw-r--r--src/scalarproduct/gnunet-service-scalarproduct_alice.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/scalarproduct/gnunet-service-scalarproduct_alice.c b/src/scalarproduct/gnunet-service-scalarproduct_alice.c
index ce796aa05..b797a378d 100644
--- a/src/scalarproduct/gnunet-service-scalarproduct_alice.c
+++ b/src/scalarproduct/gnunet-service-scalarproduct_alice.c
@@ -167,11 +167,12 @@ struct AliceServiceSession
167 uint32_t transferred_element_count; 167 uint32_t transferred_element_count;
168 168
169 /** 169 /**
170 * Is this session active (#GNUNET_YES), Concluded (#GNUNET_NO), or 170 * State of this session. In
171 * had an error (#GNUNET_SYSERR). 171 * #GNUNET_SCALARPRODUCT_STATUS_ACTIVE while operation is
172 * FIXME: replace with proper enum for status codes! 172 * ongoing, afterwards in #GNUNET_SCALARPRODUCT_STATUS_SUCCESS or
173 * #GNUNET_SCALARPRODUCT_STATUS_FAILURE.
173 */ 174 */
174 int32_t active; 175 enum GNUNET_SCALARPRODUCT_ResponseStatus status;
175 176
176 /** 177 /**
177 * Flag to prevent recursive calls to #destroy_service_session() from 178 * Flag to prevent recursive calls to #destroy_service_session() from
@@ -326,12 +327,12 @@ prepare_client_end_notification (struct AliceServiceSession *session)
326 327
327 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 328 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
328 "Sending session-end notification with status %d to client for session %s\n", 329 "Sending session-end notification with status %d to client for session %s\n",
329 session->active, 330 session->status,
330 GNUNET_h2s (&session->session_id)); 331 GNUNET_h2s (&session->session_id));
331 e = GNUNET_MQ_msg (msg, 332 e = GNUNET_MQ_msg (msg,
332 GNUNET_MESSAGE_TYPE_SCALARPRODUCT_RESULT); 333 GNUNET_MESSAGE_TYPE_SCALARPRODUCT_RESULT);
333 msg->product_length = htonl (0); 334 msg->product_length = htonl (0);
334 msg->status = htonl (session->active); 335 msg->status = htonl (session->status);
335 GNUNET_MQ_send (session->client_mq, 336 GNUNET_MQ_send (session->client_mq,
336 e); 337 e);
337} 338}
@@ -439,11 +440,16 @@ cb_channel_destruction (void *cls,
439 "Peer disconnected, terminating session %s with peer %s\n", 440 "Peer disconnected, terminating session %s with peer %s\n",
440 GNUNET_h2s (&s->session_id), 441 GNUNET_h2s (&s->session_id),
441 GNUNET_i2s (&s->peer)); 442 GNUNET_i2s (&s->peer));
443 if (NULL != s->cadet_mq)
444 {
445 GNUNET_MQ_destroy (s->cadet_mq);
446 s->cadet_mq = NULL;
447 }
442 s->channel = NULL; 448 s->channel = NULL;
443 if (GNUNET_YES == s->active) 449 if (GNUNET_SCALARPRODUCT_STATUS_ACTIVE == s->status)
444 { 450 {
445 /* We didn't get an answer yet, fail with error */ 451 /* We didn't get an answer yet, fail with error */
446 s->active = GNUNET_SYSERR; 452 s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE;
447 prepare_client_end_notification (s); 453 prepare_client_end_notification (s);
448 } 454 }
449} 455}
@@ -685,6 +691,7 @@ handle_bobs_cryptodata_multipart (void *cls,
685 sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); 691 sizeof (struct GNUNET_CRYPTO_PaillierCiphertext));
686 } 692 }
687 s->transferred_element_count += contained; 693 s->transferred_element_count += contained;
694 GNUNET_CADET_receive_done (s->channel);
688 if (s->transferred_element_count != s->used_element_count) 695 if (s->transferred_element_count != s->used_element_count)
689 return GNUNET_OK; 696 return GNUNET_OK;
690 697
@@ -775,6 +782,7 @@ handle_bobs_cryptodata_message (void *cls,
775 sizeof (struct GNUNET_CRYPTO_PaillierCiphertext)); 782 sizeof (struct GNUNET_CRYPTO_PaillierCiphertext));
776 } 783 }
777 s->transferred_element_count = contained; 784 s->transferred_element_count = contained;
785 GNUNET_CADET_receive_done (s->channel);
778 786
779 if (s->transferred_element_count != s->used_element_count) 787 if (s->transferred_element_count != s->used_element_count)
780 { 788 {
@@ -964,7 +972,7 @@ cb_intersection_element_removed (void *cls,
964 } 972 }
965 s->intersection_op = NULL; 973 s->intersection_op = NULL;
966 s->intersection_set = NULL; 974 s->intersection_set = NULL;
967 s->active = GNUNET_SYSERR; 975 s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE;
968 prepare_client_end_notification (s); 976 prepare_client_end_notification (s);
969 return; 977 return;
970 default: 978 default:
@@ -1012,7 +1020,7 @@ cb_intersection_request_alice (void *cls,
1012 if (NULL == s->intersection_op) 1020 if (NULL == s->intersection_op)
1013 { 1021 {
1014 GNUNET_break (0); 1022 GNUNET_break (0);
1015 s->active = GNUNET_SYSERR; 1023 s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE;
1016 prepare_client_end_notification (s); 1024 prepare_client_end_notification (s);
1017 return; 1025 return;
1018 } 1026 }
@@ -1020,7 +1028,7 @@ cb_intersection_request_alice (void *cls,
1020 GNUNET_SET_commit (s->intersection_op, 1028 GNUNET_SET_commit (s->intersection_op,
1021 s->intersection_set)) 1029 s->intersection_set))
1022 { 1030 {
1023 s->active = GNUNET_SYSERR; 1031 s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE;
1024 prepare_client_end_notification (s); 1032 prepare_client_end_notification (s);
1025 return; 1033 return;
1026 } 1034 }
@@ -1051,7 +1059,7 @@ client_request_complete_alice (struct AliceServiceSession *s)
1051 GNUNET_CADET_OPTION_RELIABLE); 1059 GNUNET_CADET_OPTION_RELIABLE);
1052 if (NULL == s->channel) 1060 if (NULL == s->channel)
1053 { 1061 {
1054 s->active = GNUNET_SYSERR; 1062 s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE;
1055 prepare_client_end_notification (s); 1063 prepare_client_end_notification (s);
1056 return; 1064 return;
1057 } 1065 }
@@ -1064,7 +1072,7 @@ client_request_complete_alice (struct AliceServiceSession *s)
1064 s); 1072 s);
1065 if (NULL == s->intersection_listen) 1073 if (NULL == s->intersection_listen)
1066 { 1074 {
1067 s->active = GNUNET_SYSERR; 1075 s->status = GNUNET_SCALARPRODUCT_STATUS_FAILURE;
1068 GNUNET_CADET_channel_destroy (s->channel); 1076 GNUNET_CADET_channel_destroy (s->channel);
1069 s->channel = NULL; 1077 s->channel = NULL;
1070 prepare_client_end_notification (s); 1078 prepare_client_end_notification (s);
@@ -1227,7 +1235,7 @@ GSS_handle_alice_client_message (void *cls,
1227 1235
1228 s = GNUNET_new (struct AliceServiceSession); 1236 s = GNUNET_new (struct AliceServiceSession);
1229 s->peer = msg->peer; 1237 s->peer = msg->peer;
1230 s->active = GNUNET_YES; 1238 s->status = GNUNET_SCALARPRODUCT_STATUS_ACTIVE;
1231 s->client = client; 1239 s->client = client;
1232 s->client_mq = GNUNET_MQ_queue_for_server_client (client); 1240 s->client_mq = GNUNET_MQ_queue_for_server_client (client);
1233 s->total = total_count; 1241 s->total = total_count;