diff options
author | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-09-16 12:13:13 +0000 |
---|---|---|
committer | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-09-16 12:13:13 +0000 |
commit | 2ce422dff5c4290f307c77c8b62d695e64a9f751 (patch) | |
tree | 6a14b3d68fed9289d90cad31b8116210e535b1a5 /src/scalarproduct | |
parent | f790bd20460f2d9937915f0d2268035f910c296a (diff) | |
download | gnunet-2ce422dff5c4290f307c77c8b62d695e64a9f751.tar.gz gnunet-2ce422dff5c4290f307c77c8b62d695e64a9f751.zip |
SP-client now reads the result from the correct offset (msg vs. message...)
upon shutdown, the server-API no longer crashes the SP-service by calling the client-disconnect handler with a &client == NULL
Diffstat (limited to 'src/scalarproduct')
-rw-r--r-- | src/scalarproduct/gnunet-service-scalarproduct.c | 17 | ||||
-rw-r--r-- | src/scalarproduct/scalarproduct_api.c | 2 |
2 files changed, 12 insertions, 7 deletions
diff --git a/src/scalarproduct/gnunet-service-scalarproduct.c b/src/scalarproduct/gnunet-service-scalarproduct.c index 349470333..7eac76c20 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct.c +++ b/src/scalarproduct/gnunet-service-scalarproduct.c | |||
@@ -682,6 +682,8 @@ handle_client_disconnect (void *cls, | |||
682 | { | 682 | { |
683 | struct ServiceSession *session; | 683 | struct ServiceSession *session; |
684 | 684 | ||
685 | if (client == NULL) | ||
686 | return; | ||
685 | session = GNUNET_SERVER_client_get_user_context (client, struct ServiceSession); | 687 | session = GNUNET_SERVER_client_get_user_context (client, struct ServiceSession); |
686 | if (NULL == session) | 688 | if (NULL == session) |
687 | return; | 689 | return; |
@@ -740,9 +742,9 @@ prepare_client_end_notification (void * cls, | |||
740 | memcpy (&msg->key, &session->key, sizeof (struct GNUNET_HashCode)); | 742 | memcpy (&msg->key, &session->key, sizeof (struct GNUNET_HashCode)); |
741 | memcpy (&msg->peer, &session->peer, sizeof ( struct GNUNET_PeerIdentity)); | 743 | memcpy (&msg->peer, &session->peer, sizeof ( struct GNUNET_PeerIdentity)); |
742 | msg->header.size = htons (sizeof (struct GNUNET_SCALARPRODUCT_client_response)); | 744 | msg->header.size = htons (sizeof (struct GNUNET_SCALARPRODUCT_client_response)); |
743 | // 0 size and the first char in the product is 0, which should never be zero if encoding is used. | 745 | // signal error if not signalized, positive result-range field but zero length. |
744 | msg->product_length = htonl (0); | 746 | msg->product_length = htonl (0); |
745 | msg->range = 1; | 747 | msg->range = (session->state == FINALIZED)? 0 : -1; |
746 | 748 | ||
747 | session->msg = &msg->header; | 749 | session->msg = &msg->header; |
748 | 750 | ||
@@ -883,7 +885,6 @@ prepare_service_response (gcry_mpi_t * r, | |||
883 | msg_length, | 885 | msg_length, |
884 | &do_send_message, | 886 | &do_send_message, |
885 | request); | 887 | request); |
886 | // we don't care if it could be send or not. either way, the session is over for us. | ||
887 | request->state = FINALIZED; | 888 | request->state = FINALIZED; |
888 | } | 889 | } |
889 | else | 890 | else |
@@ -893,7 +894,7 @@ prepare_service_response (gcry_mpi_t * r, | |||
893 | if ( NULL == request->service_transmit_handle) | 894 | if ( NULL == request->service_transmit_handle) |
894 | { | 895 | { |
895 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Could not send service-response message via mesh!)\n")); | 896 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ ("Could not send service-response message via mesh!)\n")); |
896 | 897 | ||
897 | response->client_notification_task = | 898 | response->client_notification_task = |
898 | GNUNET_SCHEDULER_add_now (&prepare_client_end_notification, | 899 | GNUNET_SCHEDULER_add_now (&prepare_client_end_notification, |
899 | response); | 900 | response); |
@@ -1493,7 +1494,6 @@ tunnel_destruction_handler (void *cls, | |||
1493 | } | 1494 | } |
1494 | } | 1495 | } |
1495 | else { //(BOB == session->role) service session | 1496 | else { //(BOB == session->role) service session |
1496 | |||
1497 | // remove the session, unless it has already been dequeued, but somehow still active | 1497 | // remove the session, unless it has already been dequeued, but somehow still active |
1498 | // this could bug without the IF in case the queue is empty and the service session was the only one know to the service | 1498 | // this could bug without the IF in case the queue is empty and the service session was the only one know to the service |
1499 | // scenario: disconnect before alice can send her message to bob. | 1499 | // scenario: disconnect before alice can send her message to bob. |
@@ -1515,6 +1515,7 @@ tunnel_destruction_handler (void *cls, | |||
1515 | // or if it was a responder, no point in adding more statefulness | 1515 | // or if it was a responder, no point in adding more statefulness |
1516 | if (client_session && (!do_shutdown)) | 1516 | if (client_session && (!do_shutdown)) |
1517 | { | 1517 | { |
1518 | client_session->state = FINALIZED; | ||
1518 | client_session->client_notification_task = | 1519 | client_session->client_notification_task = |
1519 | GNUNET_SCHEDULER_add_now (&prepare_client_end_notification, | 1520 | GNUNET_SCHEDULER_add_now (&prepare_client_end_notification, |
1520 | client_session); | 1521 | client_session); |
@@ -1657,7 +1658,7 @@ prepare_client_response (void *cls, | |||
1657 | 1658 | ||
1658 | // get representation as string | 1659 | // get representation as string |
1659 | if (range | 1660 | if (range |
1660 | && (0 != (rc = gcry_mpi_aprint (GCRYMPI_FMT_USG, | 1661 | && (0 != (rc = gcry_mpi_aprint (GCRYMPI_FMT_STD, |
1661 | &product_exported, | 1662 | &product_exported, |
1662 | &product_length, | 1663 | &product_length, |
1663 | value)))){ | 1664 | value)))){ |
@@ -2054,6 +2055,10 @@ shutdown_task (void *cls, | |||
2054 | GNUNET_SCHEDULER_cancel (session->service_request_task); | 2055 | GNUNET_SCHEDULER_cancel (session->service_request_task); |
2055 | session->service_request_task = GNUNET_SCHEDULER_NO_TASK; | 2056 | session->service_request_task = GNUNET_SCHEDULER_NO_TASK; |
2056 | } | 2057 | } |
2058 | if (NULL != session->client){ | ||
2059 | GNUNET_SERVER_client_disconnect(session->client); | ||
2060 | session->client = NULL; | ||
2061 | } | ||
2057 | } | 2062 | } |
2058 | for (session = from_service_head; NULL != session; session = session->next) | 2063 | for (session = from_service_head; NULL != session; session = session->next) |
2059 | 2064 | ||
diff --git a/src/scalarproduct/scalarproduct_api.c b/src/scalarproduct/scalarproduct_api.c index eed7c315b..fc470eb20 100644 --- a/src/scalarproduct/scalarproduct_api.c +++ b/src/scalarproduct/scalarproduct_api.c | |||
@@ -190,7 +190,7 @@ process_result_message (void *cls, | |||
190 | gcry_mpi_t num; | 190 | gcry_mpi_t num; |
191 | size_t read = 0; | 191 | size_t read = 0; |
192 | 192 | ||
193 | if (0 != (rc = gcry_mpi_scan (&num, GCRYMPI_FMT_USG, &msg[1], product_len, &read))) | 193 | if (0 != (rc = gcry_mpi_scan (&num, GCRYMPI_FMT_STD, &message[1], product_len, &read))) |
194 | { | 194 | { |
195 | LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_scan", rc); | 195 | LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_scan", rc); |
196 | gcry_mpi_release (result); | 196 | gcry_mpi_release (result); |