From: Christian Grothoff Date: Mon, 1 Feb 2010 13:55:28 +0000 (+0000) Subject: fixes X-Git-Tag: initial-import-from-subversion-38251~22822 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=8f30685560bfd084d681aa3a9470002479bcff80;p=oweals%2Fgnunet.git fixes --- diff --git a/src/fs/fs.h b/src/fs/fs.h index d19f27b6f..1997d353c 100644 --- a/src/fs/fs.h +++ b/src/fs/fs.h @@ -1299,35 +1299,6 @@ struct SearchMessage }; -/** - * Response from FS service with a result for a previous FS search. - * Note that queries for DBLOCKS and IBLOCKS that have received a - * single response are considered done. - */ -struct ContentMessage -{ - - /** - * Message type will be - * GNUNET_MESSAGE_TYPE_FS_CONTENT. - */ - struct GNUNET_MessageHeader header; - - /** - * Type of the content that was found, - * should never be 0. - */ - uint32_t type GNUNET_PACKED; - - /** - * When will this result expire? - */ - struct GNUNET_TIME_AbsoluteNBO expiration; - - /* followed by the actual block of data */ - -}; - /** * Only the (mandatory) query is included. */ @@ -1417,7 +1388,10 @@ struct GetMessage /** - * Message sent between peers providing FS-content. + * Response from FS service with a result for a previous FS search. + * Note that queries for DBLOCKS and IBLOCKS that have received a + * single response are considered done. This message is transmitted + * between peers as well as between the service and a client. */ struct PutMessage { @@ -1428,14 +1402,14 @@ struct PutMessage struct GNUNET_MessageHeader header; /** - * Type of the block (in big endian). + * Type of the block (in big endian). Should never be zero. */ uint32_t type GNUNET_PACKED; /** * When does this result expire? */ - struct GNUNET_TIME_RelativeNBO expiration; + struct GNUNET_TIME_AbsoluteNBO expiration; /* this is followed by the actual encrypted content */ diff --git a/src/fs/fs_download.c b/src/fs/fs_download.c index b0e981b80..78ab5c814 100644 --- a/src/fs/fs_download.c +++ b/src/fs/fs_download.c @@ -36,7 +36,7 @@ #include "fs.h" #include "fs_tree.h" -#define DEBUG_DOWNLOAD GNUNET_NO +#define DEBUG_DOWNLOAD GNUNET_YES /** * We're storing the IBLOCKS after the @@ -539,22 +539,23 @@ receive_results (void *cls, const struct GNUNET_MessageHeader * msg) { struct GNUNET_FS_DownloadContext *dc = cls; - const struct ContentMessage *cm; + const struct PutMessage *cm; uint16_t msize; if ( (NULL == msg) || - (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_CONTENT) || - (ntohs (msg->size) <= sizeof (struct ContentMessage)) ) + (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_PUT) || + (sizeof (struct PutMessage) > ntohs(msg->size)) ) { + GNUNET_break (msg == NULL); try_reconnect (dc); return; } - msize = ntohs (msg->size); - cm = (const struct ContentMessage*) msg; + msize = ntohs(msg->size); + cm = (const struct PutMessage*) msg; process_result (dc, ntohl (cm->type), &cm[1], - msize - sizeof (struct ContentMessage)); + msize - sizeof (struct PutMessage)); if (dc->client == NULL) return; /* fatal error */ /* continue receiving */ diff --git a/src/fs/fs_search.c b/src/fs/fs_search.c index 5d03046e2..3229733de 100644 --- a/src/fs/fs_search.c +++ b/src/fs/fs_search.c @@ -574,23 +574,23 @@ receive_results (void *cls, const struct GNUNET_MessageHeader * msg) { struct GNUNET_FS_SearchContext *sc = cls; - const struct ContentMessage *cm; + const struct PutMessage *cm; uint16_t msize; if ( (NULL == msg) || - (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_CONTENT) || - (ntohs (msg->size) <= sizeof (struct ContentMessage)) ) + (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_PUT) || + (ntohs (msg->size) <= sizeof (struct PutMessage)) ) { try_reconnect (sc); return; } msize = ntohs (msg->size); - cm = (const struct ContentMessage*) msg; + cm = (const struct PutMessage*) msg; process_result (sc, ntohl (cm->type), GNUNET_TIME_absolute_ntoh (cm->expiration), &cm[1], - msize - sizeof (struct ContentMessage)); + msize - sizeof (struct PutMessage)); /* continue receiving */ GNUNET_CLIENT_receive (sc->client, &receive_results, diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index ead8ea17d..30d15eb66 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c @@ -1592,6 +1592,11 @@ transmit_to_client (void *cls, GNUNET_TIME_UNIT_FOREVER_REL, &transmit_to_client, cl); +#if DEBUG_FS + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Transmitted %u bytes to client\n", + (unsigned int) msize); +#endif return msize; } @@ -1655,7 +1660,6 @@ process_reply (void *cls, struct ClientResponseMessage *creply; struct ClientList *cl; struct PutMessage *pm; - struct ContentMessage *cm; struct ConnectedPeer *cp; GNUNET_HashCode chash; GNUNET_HashCode mhash; @@ -1740,8 +1744,8 @@ process_reply (void *cls, pm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_PUT); pm->header.size = htons (msize); pm->type = htonl (prq->type); - pm->expiration = GNUNET_TIME_relative_hton (GNUNET_TIME_absolute_get_remaining (prq->expiration)); - memcpy (&creply[1], prq->data, prq->size); + pm->expiration = GNUNET_TIME_absolute_hton (prq->expiration); + memcpy (&pm[1], prq->data, prq->size); if (NULL == cl->th) cl->th = GNUNET_SERVER_notify_transmit_ready (cl->client, msize, @@ -1759,18 +1763,18 @@ process_reply (void *cls, GNUNET_h2s (key), (unsigned int) cp->pid); #endif - msize = sizeof (struct ContentMessage) + prq->size; + msize = sizeof (struct PutMessage) + prq->size; reply = GNUNET_malloc (msize + sizeof (struct PendingMessage)); reply->cont = &transmit_reply_continuation; reply->cont_cls = pr; reply->msize = msize; reply->priority = (uint32_t) -1; /* send replies first! */ - cm = (struct ContentMessage*) &reply[1]; - cm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_CONTENT); - cm->header.size = htons (msize); - cm->type = htonl (prq->type); - cm->expiration = GNUNET_TIME_absolute_hton (prq->expiration); - memcpy (&reply[1], prq->data, prq->size); + pm = (struct PutMessage*) &reply[1]; + pm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_PUT); + pm->header.size = htons (msize); + pm->type = htonl (prq->type); + pm->expiration = GNUNET_TIME_absolute_hton (prq->expiration); + memcpy (&pm[1], prq->data, prq->size); add_to_pending_messages_for_peer (cp, reply, pr); } @@ -1816,7 +1820,7 @@ handle_p2p_put (void *cls, put = (const struct PutMessage*) message; dsize = msize - sizeof (struct PutMessage); type = ntohl (put->type); - expiration = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_ntoh (put->expiration)); + expiration = GNUNET_TIME_absolute_ntoh (put->expiration); /* first, validate! */ switch (type) diff --git a/src/fs/gnunet-service-fs_indexing.c b/src/fs/gnunet-service-fs_indexing.c index 7dea53ee9..72203fa7a 100644 --- a/src/fs/gnunet-service-fs_indexing.c +++ b/src/fs/gnunet-service-fs_indexing.c @@ -38,8 +38,7 @@ #include "gnunet-service-fs_indexing.h" #include "fs.h" -#define DEBUG_FS GNUNET_NO - +#define DEBUG_FS GNUNET_YES /** * In-memory information about indexed files (also available @@ -624,6 +623,11 @@ GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key, to remove the OnDemand block from the DS! */ return GNUNET_SYSERR; } +#if DEBUG_FS + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "On-demand encoded block for query `%s'\n", + GNUNET_h2s (key)); +#endif cont (cont_cls, key, nsize, diff --git a/src/fs/test_fs_download.c b/src/fs/test_fs_download.c index 5cb9e4111..d4b32b8c8 100644 --- a/src/fs/test_fs_download.c +++ b/src/fs/test_fs_download.c @@ -29,7 +29,7 @@ #include "gnunet_arm_service.h" #include "gnunet_fs_service.h" -#define VERBOSE GNUNET_NO +#define VERBOSE GNUNET_YES #define START_ARM GNUNET_YES @@ -78,16 +78,16 @@ static void timeout_kill_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { - if (publish != NULL) - { - GNUNET_FS_publish_stop (publish); - publish = NULL; - } if (download != NULL) { GNUNET_FS_download_stop (download, GNUNET_YES); download = NULL; } + else if (publish != NULL) + { + GNUNET_FS_publish_stop (publish); + publish = NULL; + } timeout_kill = GNUNET_SCHEDULER_NO_TASK; err = 1; } diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index 229d8910b..249ba3de0 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h @@ -440,22 +440,16 @@ extern "C" */ #define GNUNET_MESSAGE_TYPE_FS_START_SEARCH 136 -/** - * FS service has found content matching this client's - * request. - */ -#define GNUNET_MESSAGE_TYPE_FS_CONTENT 137 - /** * P2P request for content (one FS to another). */ -#define GNUNET_MESSAGE_TYPE_FS_GET 138 +#define GNUNET_MESSAGE_TYPE_FS_GET 137 /** - * P2P response with content or active - * migration of content. + * P2P response with content or active migration of content. Also + * used between the service and clients (in response to START_SEARCH). */ -#define GNUNET_MESSAGE_TYPE_FS_PUT 139 +#define GNUNET_MESSAGE_TYPE_FS_PUT 138 /** * Type used to match 'all' message types.