aboutsummaryrefslogtreecommitdiff
path: root/src/scalarproduct/scalarproduct_api.c
diff options
context:
space:
mode:
authorChristian Fuchs <christian.fuchs@cfuchs.net>2013-09-11 15:55:47 +0000
committerChristian Fuchs <christian.fuchs@cfuchs.net>2013-09-11 15:55:47 +0000
commit361fb8f1f3f57d0fb47fa923fe8c813f5d0bb86e (patch)
tree5b485812cd2eac7d51e4a05d2bf006dd6b2ee873 /src/scalarproduct/scalarproduct_api.c
parentbc4854ff5e7e320cee78dd73363757dcf09d18fa (diff)
downloadgnunet-361fb8f1f3f57d0fb47fa923fe8c813f5d0bb86e.tar.gz
gnunet-361fb8f1f3f57d0fb47fa923fe8c813f5d0bb86e.zip
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
Diffstat (limited to 'src/scalarproduct/scalarproduct_api.c')
-rw-r--r--src/scalarproduct/scalarproduct_api.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/src/scalarproduct/scalarproduct_api.c b/src/scalarproduct/scalarproduct_api.c
index 91f1992f9..89cb4db17 100644
--- a/src/scalarproduct/scalarproduct_api.c
+++ b/src/scalarproduct/scalarproduct_api.c
@@ -39,6 +39,13 @@
39 **************************************************************/ 39 **************************************************************/
40 40
41/** 41/**
42 * the abstraction function for our internal callback
43 */
44typedef void (*GNUNET_SCALARPRODUCT_ResponseMessageHandler) (void *cls,
45 const struct GNUNET_MessageHeader *msg,
46 enum GNUNET_SCALARPRODUCT_ResponseStatus status);
47
48/**
42 * Entry in the request queue per client 49 * Entry in the request queue per client
43 */ 50 */
44struct GNUNET_SCALARPRODUCT_ComputationHandle 51struct GNUNET_SCALARPRODUCT_ComputationHandle
@@ -90,15 +97,15 @@ struct GNUNET_SCALARPRODUCT_ComputationHandle
90 97
91 union 98 union
92 { 99 {
93 /** 100 /**
94 * Function to call after transmission of the request. 101 * Function to call after transmission of the request.
95 */ 102 */
96 GNUNET_SCALARPRODUCT_ContinuationWithStatus cont_status; 103 GNUNET_SCALARPRODUCT_ContinuationWithStatus cont_status;
97 104
98 /** 105 /**
99 * Function to call after transmission of the request. 106 * Function to call after transmission of the request.
100 */ 107 */
101 GNUNET_SCALARPRODUCT_DatumProcessor cont_datum; 108 GNUNET_SCALARPRODUCT_DatumProcessor cont_datum;
102 }; 109 };
103 110
104 /** 111 /**
@@ -173,8 +180,7 @@ process_result_message (void *cls,
173 gcry_mpi_t result = NULL; 180 gcry_mpi_t result = NULL;
174 gcry_error_t rc; 181 gcry_error_t rc;
175 182
176 if (GNUNET_SCALARPRODUCT_Status_Success == status 183 if (GNUNET_SCALARPRODUCT_Status_Success == status)
177 && qe->cont_datum != NULL)
178 { 184 {
179 size_t product_len = ntohl (message->product_length); 185 size_t product_len = ntohl (message->product_length);
180 result = gcry_mpi_new (0); 186 result = gcry_mpi_new (0);
@@ -239,7 +245,7 @@ receive_cb (void *cls, const struct GNUNET_MessageHeader *msg)
239 245
240 status = GNUNET_SCALARPRODUCT_Status_Success; 246 status = GNUNET_SCALARPRODUCT_Status_Success;
241 } 247 }
242 248
243 if (qe->cont_datum != NULL) 249 if (qe->cont_datum != NULL)
244 qe->response_proc (qe, msg, status); 250 qe->response_proc (qe, msg, status);
245 251
@@ -272,6 +278,7 @@ transmit_request (void *cls, size_t size,
272 // notify caller about the error, done here. 278 // notify caller about the error, done here.
273 if (qe->cont_datum != NULL) 279 if (qe->cont_datum != NULL)
274 qe->response_proc (qe, NULL, GNUNET_SCALARPRODUCT_Status_Failure); 280 qe->response_proc (qe, NULL, GNUNET_SCALARPRODUCT_Status_Failure);
281
275 GNUNET_SCALARPRODUCT_cancel (cls); 282 GNUNET_SCALARPRODUCT_cancel (cls);
276 return 0; 283 return 0;
277 } 284 }
@@ -322,10 +329,6 @@ GNUNET_SCALARPRODUCT_response (const struct GNUNET_CONFIGURATION_Handle *cfg,
322 uint16_t size; 329 uint16_t size;
323 uint64_t i; 330 uint64_t i;
324 331
325 GNUNET_assert (key);
326 GNUNET_assert (elements);
327 GNUNET_assert (cont);
328 GNUNET_assert (element_count > 1);
329 GNUNET_assert (GNUNET_SERVER_MAX_MESSAGE_SIZE >= sizeof (struct GNUNET_SCALARPRODUCT_client_request) 332 GNUNET_assert (GNUNET_SERVER_MAX_MESSAGE_SIZE >= sizeof (struct GNUNET_SCALARPRODUCT_client_request)
330 +element_count * sizeof (int32_t)); 333 +element_count * sizeof (int32_t));
331 h = GNUNET_new (struct GNUNET_SCALARPRODUCT_ComputationHandle); 334 h = GNUNET_new (struct GNUNET_SCALARPRODUCT_ComputationHandle);
@@ -459,7 +462,7 @@ GNUNET_SCALARPRODUCT_request (const struct GNUNET_CONFIGURATION_Handle *cfg,
459 // copy each element over to the message 462 // copy each element over to the message
460 for (i = 0; i < element_count; i++) 463 for (i = 0; i < element_count; i++)
461 vector[i] = htonl (elements[i]); 464 vector[i] = htonl (elements[i]);
462 465
463 memcpy (&msg->peer, peer, sizeof (struct GNUNET_PeerIdentity)); 466 memcpy (&msg->peer, peer, sizeof (struct GNUNET_PeerIdentity));
464 memcpy (&msg->key, key, sizeof (struct GNUNET_HashCode)); 467 memcpy (&msg->key, key, sizeof (struct GNUNET_HashCode));
465 memcpy (&vector[element_count], mask, mask_bytes); 468 memcpy (&vector[element_count], mask, mask_bytes);