aboutsummaryrefslogtreecommitdiff
path: root/src/scalarproduct/scalarproduct_api.c
diff options
context:
space:
mode:
authorChristian Fuchs <christian.fuchs@cfuchs.net>2013-09-03 12:07:52 +0000
committerChristian Fuchs <christian.fuchs@cfuchs.net>2013-09-03 12:07:52 +0000
commitdc91365855b72f0c97c0a7abc6eac7d479704daf (patch)
treea0242025c976f2c23b64cdd3516a84b6681d4c57 /src/scalarproduct/scalarproduct_api.c
parentd4922969a54f83b3c2d7503a9bda2708700869c8 (diff)
downloadgnunet-dc91365855b72f0c97c0a7abc6eac7d479704daf.tar.gz
gnunet-dc91365855b72f0c97c0a7abc6eac7d479704daf.zip
re-added collective disconnect command to the scalarproduct API
adapted the scalarproduct client to use the new API modified scalarproduct.h to include proper logging for gcrypt errors cancel is now quiet added proper gcry logging to the SP-API
Diffstat (limited to 'src/scalarproduct/scalarproduct_api.c')
-rw-r--r--src/scalarproduct/scalarproduct_api.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/scalarproduct/scalarproduct_api.c b/src/scalarproduct/scalarproduct_api.c
index 633034b31..b3390f349 100644
--- a/src/scalarproduct/scalarproduct_api.c
+++ b/src/scalarproduct/scalarproduct_api.c
@@ -171,6 +171,7 @@ process_result_message (void *cls,
171 const struct GNUNET_SCALARPRODUCT_client_response *message = 171 const struct GNUNET_SCALARPRODUCT_client_response *message =
172 (const struct GNUNET_SCALARPRODUCT_client_response *) msg; 172 (const struct GNUNET_SCALARPRODUCT_client_response *) msg;
173 gcry_mpi_t result = NULL; 173 gcry_mpi_t result = NULL;
174 gcry_error_t rc;
174 175
175 if (GNUNET_SCALARPRODUCT_Status_Success == status 176 if (GNUNET_SCALARPRODUCT_Status_Success == status
176 && qe->cont_datum != NULL) 177 && qe->cont_datum != NULL)
@@ -183,9 +184,9 @@ process_result_message (void *cls,
183 gcry_mpi_t num; 184 gcry_mpi_t num;
184 size_t read = 0; 185 size_t read = 0;
185 186
186 if (0 != gcry_mpi_scan (&num, GCRYMPI_FMT_USG, &msg[1], product_len, &read)) 187 if (0 != (rc = gcry_mpi_scan (&num, GCRYMPI_FMT_USG, &msg[1], product_len, &read)))
187 { 188 {
188 LOG (GNUNET_ERROR_TYPE_ERROR, "Could not convert to mpi to value!\n"); 189 LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_scan", rc);
189 gcry_mpi_release (result); 190 gcry_mpi_release (result);
190 result = NULL; 191 result = NULL;
191 status = GNUNET_SCALARPRODUCT_Status_InvalidResponse; 192 status = GNUNET_SCALARPRODUCT_Status_InvalidResponse;
@@ -497,17 +498,36 @@ GNUNET_SCALARPRODUCT_cancel (struct GNUNET_SCALARPRODUCT_ComputationHandle * h)
497 if (qe == h) 498 if (qe == h)
498 { 499 {
499 GNUNET_CONTAINER_DLL_remove (head, tail, qe); 500 GNUNET_CONTAINER_DLL_remove (head, tail, qe);
500 LOG (GNUNET_ERROR_TYPE_INFO,
501 "Disconnecting from VectorProduct\n");
502 if (NULL == qe->th) 501 if (NULL == qe->th)
503 GNUNET_CLIENT_notify_transmit_ready_cancel (qe->th); 502 GNUNET_CLIENT_notify_transmit_ready_cancel (qe->th);
504 GNUNET_CLIENT_disconnect (h->client); 503 GNUNET_CLIENT_disconnect (qe->client);
505 GNUNET_STATISTICS_destroy (h->stats, GNUNET_YES); 504 GNUNET_STATISTICS_destroy (qe->stats, GNUNET_YES);
506 GNUNET_free (qe->msg); 505 GNUNET_free (qe->msg);
507 GNUNET_free (qe); 506 GNUNET_free (qe);
508 break; 507 break;
509 } 508 }
510 } 509 }
511} 510}
511/**
512 * Cancel ALL our ongoing scalar product computations and collaboration offers.
513 * Closes ALL connections to the service
514 */
515void
516GNUNET_SCALARPRODUCT_disconnect ()
517{
518 struct GNUNET_SCALARPRODUCT_ComputationHandle * qe;
519
520 LOG (GNUNET_ERROR_TYPE_INFO, "Disconnecting from VectorProduct\n");
521 for (qe = head; head != NULL; qe = head)
522 {
523 GNUNET_CONTAINER_DLL_remove (head, tail, qe);
524 if (NULL == qe->th)
525 GNUNET_CLIENT_notify_transmit_ready_cancel (qe->th);
526 GNUNET_CLIENT_disconnect (qe->client);
527 GNUNET_STATISTICS_destroy (qe->stats, GNUNET_YES);
528 GNUNET_free (qe->msg);
529 GNUNET_free (qe);
530 }
531}
512 532
513/* end of ext_api.c */ 533/* end of ext_api.c */