From: Christian Grothoff Date: Fri, 25 Mar 2011 11:02:34 +0000 (+0000) Subject: fix X-Git-Tag: initial-import-from-subversion-38251~18908 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=d0b14419851f070e0e6d2ab646e6fc0f4baa08c8;p=oweals%2Fgnunet.git fix --- diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c index 9ff96ba36..783bd4024 100644 --- a/src/fs/gnunet-service-fs_cp.c +++ b/src/fs/gnunet-service-fs_cp.c @@ -560,6 +560,7 @@ copy_reply (void *cls, * have liked an answer to the request * @param pr handle to the original pending request * @param expiration when does 'data' expire? + * @param type type of the block * @param data response data, NULL on request expiration * @param data_len number of bytes in data */ @@ -567,6 +568,7 @@ static void handle_p2p_reply (void *cls, struct GSF_PendingRequest *pr, struct GNUNET_TIME_Absolute expiration, + enum GNUNET_BLOCK_Type type, const void *data, size_t data_len) { @@ -588,6 +590,13 @@ handle_p2p_reply (void *cls, pr)); return; } + GNUNET_break (type != GNUNET_BLOCK_TYPE_ANY); + if ( (prd->type != type) && + (prd->type != GNUNET_BLOCK_TYPE_ANY) ) + { + GNUNET_break (0); + return; + } #if DEBUG_FS GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmitting result for query `%s'\n", @@ -606,7 +615,7 @@ handle_p2p_reply (void *cls, pm = GNUNET_malloc (sizeof (msize)); pm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_PUT); pm->header.size = htons (msize); - pm->type = htonl (prd->type); + pm->type = htonl (type); pm->expiration = GNUNET_TIME_absolute_hton (expiration); memcpy (&pm[1], data, data_len); (void) GSF_peer_transmit_ (cp, GNUNET_NO, diff --git a/src/fs/gnunet-service-fs_lc.c b/src/fs/gnunet-service-fs_lc.c index 5ceb7c2a5..3908b8a55 100644 --- a/src/fs/gnunet-service-fs_lc.c +++ b/src/fs/gnunet-service-fs_lc.c @@ -189,7 +189,8 @@ GSF_local_client_lookup_ (struct GNUNET_SERVER_Client *client) * * @param cls user-specified closure * @param pr handle to the original pending request - * @param expiration when does 'data' expire? + * @param expiration when does 'data' expire? + * @param type type of the block * @param data response data, NULL on request expiration * @param data_len number of bytes in data */ @@ -197,6 +198,7 @@ static void client_response_handler (void *cls, struct GSF_PendingRequest *pr, struct GNUNET_TIME_Absolute expiration, + enum GNUNET_BLOCK_Type type, const void *data, size_t data_len) { @@ -212,18 +214,25 @@ client_response_handler (void *cls, GNUNET_break (0); return; } + prd = GSF_pending_request_get_data_ (pr); + GNUNET_break (type != GNUNET_BLOCK_TYPE_ANY); + if ( (prd->type != type) && + (prd->type != GNUNET_BLOCK_TYPE_ANY) ) + { + GNUNET_break (0); + return; + } GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# replies received for local clients"), 1, GNUNET_NO); - prd = GSF_pending_request_get_data_ (pr); GNUNET_assert (pr == cr->pr); lc = cr->lc; msize = sizeof (struct PutMessage) + data_len; pm = GNUNET_malloc (msize); pm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_PUT); pm->header.size = htons (msize); - pm->type = htonl (prd->type); + pm->type = htonl (type); pm->expiration = GNUNET_TIME_absolute_hton (expiration); memcpy (&pm[1], data, data_len); GSF_local_client_transmit_ (lc, &pm->header); diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c index 13de31c7c..8a14c4c00 100644 --- a/src/fs/gnunet-service-fs_pr.c +++ b/src/fs/gnunet-service-fs_pr.c @@ -333,6 +333,7 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options, dpr->rh (dpr->rh_cls, dpr, GNUNET_TIME_UNIT_FOREVER_ABS, + GNUNET_BLOCK_TYPE_ANY, NULL, 0); GSF_pending_request_cancel_ (dpr); } @@ -692,6 +693,7 @@ process_reply (void *cls, pr->rh (pr->rh_cls, pr, prq->expiration, + prq->type, prq->data, prq->size); return GNUNET_YES; case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE: @@ -749,6 +751,7 @@ process_reply (void *cls, pr->rh (pr->rh_cls, pr, prq->expiration, + prq->type, prq->data, prq->size); return GNUNET_YES; } diff --git a/src/fs/gnunet-service-fs_pr.h b/src/fs/gnunet-service-fs_pr.h index ea464e578..b546fc1ab 100644 --- a/src/fs/gnunet-service-fs_pr.h +++ b/src/fs/gnunet-service-fs_pr.h @@ -160,12 +160,14 @@ struct GSF_PendingRequestData * @param cls user-specified closure * @param pr handle to the original pending request * @param expiration when does 'data' expire? + * @param type type of the block * @param data response data, NULL on request expiration * @param data_len number of bytes in data */ typedef void (*GSF_PendingRequestReplyHandler)(void *cls, struct GSF_PendingRequest *pr, struct GNUNET_TIME_Absolute expiration, + enum GNUNET_BLOCK_Type type, const void *data, size_t data_len);