aboutsummaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-02-01 13:55:28 +0000
committerChristian Grothoff <christian@grothoff.org>2010-02-01 13:55:28 +0000
commit8f30685560bfd084d681aa3a9470002479bcff80 (patch)
treec09a7f0a3171a4563d3fbb253d924d002f06f27b /src/fs
parent36b60a0ac26d8102667c590587b8a0d33c203cc9 (diff)
downloadgnunet-8f30685560bfd084d681aa3a9470002479bcff80.tar.gz
gnunet-8f30685560bfd084d681aa3a9470002479bcff80.zip
fixes
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/fs.h38
-rw-r--r--src/fs/fs_download.c15
-rw-r--r--src/fs/fs_search.c10
-rw-r--r--src/fs/gnunet-service-fs.c26
-rw-r--r--src/fs/gnunet-service-fs_indexing.c8
-rw-r--r--src/fs/test_fs_download.c12
6 files changed, 46 insertions, 63 deletions
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
@@ -1300,35 +1300,6 @@ struct SearchMessage
1300 1300
1301 1301
1302/** 1302/**
1303 * Response from FS service with a result for a previous FS search.
1304 * Note that queries for DBLOCKS and IBLOCKS that have received a
1305 * single response are considered done.
1306 */
1307struct ContentMessage
1308{
1309
1310 /**
1311 * Message type will be
1312 * GNUNET_MESSAGE_TYPE_FS_CONTENT.
1313 */
1314 struct GNUNET_MessageHeader header;
1315
1316 /**
1317 * Type of the content that was found,
1318 * should never be 0.
1319 */
1320 uint32_t type GNUNET_PACKED;
1321
1322 /**
1323 * When will this result expire?
1324 */
1325 struct GNUNET_TIME_AbsoluteNBO expiration;
1326
1327 /* followed by the actual block of data */
1328
1329};
1330
1331/**
1332 * Only the (mandatory) query is included. 1303 * Only the (mandatory) query is included.
1333 */ 1304 */
1334#define GET_MESSAGE_BIT_QUERY_ONLY 0 1305#define GET_MESSAGE_BIT_QUERY_ONLY 0
@@ -1417,7 +1388,10 @@ struct GetMessage
1417 1388
1418 1389
1419/** 1390/**
1420 * Message sent between peers providing FS-content. 1391 * Response from FS service with a result for a previous FS search.
1392 * Note that queries for DBLOCKS and IBLOCKS that have received a
1393 * single response are considered done. This message is transmitted
1394 * between peers as well as between the service and a client.
1421 */ 1395 */
1422struct PutMessage 1396struct PutMessage
1423{ 1397{
@@ -1428,14 +1402,14 @@ struct PutMessage
1428 struct GNUNET_MessageHeader header; 1402 struct GNUNET_MessageHeader header;
1429 1403
1430 /** 1404 /**
1431 * Type of the block (in big endian). 1405 * Type of the block (in big endian). Should never be zero.
1432 */ 1406 */
1433 uint32_t type GNUNET_PACKED; 1407 uint32_t type GNUNET_PACKED;
1434 1408
1435 /** 1409 /**
1436 * When does this result expire? 1410 * When does this result expire?
1437 */ 1411 */
1438 struct GNUNET_TIME_RelativeNBO expiration; 1412 struct GNUNET_TIME_AbsoluteNBO expiration;
1439 1413
1440 /* this is followed by the actual encrypted content */ 1414 /* this is followed by the actual encrypted content */
1441 1415
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 @@
36#include "fs.h" 36#include "fs.h"
37#include "fs_tree.h" 37#include "fs_tree.h"
38 38
39#define DEBUG_DOWNLOAD GNUNET_NO 39#define DEBUG_DOWNLOAD GNUNET_YES
40 40
41/** 41/**
42 * We're storing the IBLOCKS after the 42 * We're storing the IBLOCKS after the
@@ -539,22 +539,23 @@ receive_results (void *cls,
539 const struct GNUNET_MessageHeader * msg) 539 const struct GNUNET_MessageHeader * msg)
540{ 540{
541 struct GNUNET_FS_DownloadContext *dc = cls; 541 struct GNUNET_FS_DownloadContext *dc = cls;
542 const struct ContentMessage *cm; 542 const struct PutMessage *cm;
543 uint16_t msize; 543 uint16_t msize;
544 544
545 if ( (NULL == msg) || 545 if ( (NULL == msg) ||
546 (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_CONTENT) || 546 (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_PUT) ||
547 (ntohs (msg->size) <= sizeof (struct ContentMessage)) ) 547 (sizeof (struct PutMessage) > ntohs(msg->size)) )
548 { 548 {
549 GNUNET_break (msg == NULL);
549 try_reconnect (dc); 550 try_reconnect (dc);
550 return; 551 return;
551 } 552 }
552 msize = ntohs (msg->size); 553 msize = ntohs(msg->size);
553 cm = (const struct ContentMessage*) msg; 554 cm = (const struct PutMessage*) msg;
554 process_result (dc, 555 process_result (dc,
555 ntohl (cm->type), 556 ntohl (cm->type),
556 &cm[1], 557 &cm[1],
557 msize - sizeof (struct ContentMessage)); 558 msize - sizeof (struct PutMessage));
558 if (dc->client == NULL) 559 if (dc->client == NULL)
559 return; /* fatal error */ 560 return; /* fatal error */
560 /* continue receiving */ 561 /* 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,
574 const struct GNUNET_MessageHeader * msg) 574 const struct GNUNET_MessageHeader * msg)
575{ 575{
576 struct GNUNET_FS_SearchContext *sc = cls; 576 struct GNUNET_FS_SearchContext *sc = cls;
577 const struct ContentMessage *cm; 577 const struct PutMessage *cm;
578 uint16_t msize; 578 uint16_t msize;
579 579
580 if ( (NULL == msg) || 580 if ( (NULL == msg) ||
581 (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_CONTENT) || 581 (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_FS_PUT) ||
582 (ntohs (msg->size) <= sizeof (struct ContentMessage)) ) 582 (ntohs (msg->size) <= sizeof (struct PutMessage)) )
583 { 583 {
584 try_reconnect (sc); 584 try_reconnect (sc);
585 return; 585 return;
586 } 586 }
587 msize = ntohs (msg->size); 587 msize = ntohs (msg->size);
588 cm = (const struct ContentMessage*) msg; 588 cm = (const struct PutMessage*) msg;
589 process_result (sc, 589 process_result (sc,
590 ntohl (cm->type), 590 ntohl (cm->type),
591 GNUNET_TIME_absolute_ntoh (cm->expiration), 591 GNUNET_TIME_absolute_ntoh (cm->expiration),
592 &cm[1], 592 &cm[1],
593 msize - sizeof (struct ContentMessage)); 593 msize - sizeof (struct PutMessage));
594 /* continue receiving */ 594 /* continue receiving */
595 GNUNET_CLIENT_receive (sc->client, 595 GNUNET_CLIENT_receive (sc->client,
596 &receive_results, 596 &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,
1592 GNUNET_TIME_UNIT_FOREVER_REL, 1592 GNUNET_TIME_UNIT_FOREVER_REL,
1593 &transmit_to_client, 1593 &transmit_to_client,
1594 cl); 1594 cl);
1595#if DEBUG_FS
1596 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1597 "Transmitted %u bytes to client\n",
1598 (unsigned int) msize);
1599#endif
1595 return msize; 1600 return msize;
1596} 1601}
1597 1602
@@ -1655,7 +1660,6 @@ process_reply (void *cls,
1655 struct ClientResponseMessage *creply; 1660 struct ClientResponseMessage *creply;
1656 struct ClientList *cl; 1661 struct ClientList *cl;
1657 struct PutMessage *pm; 1662 struct PutMessage *pm;
1658 struct ContentMessage *cm;
1659 struct ConnectedPeer *cp; 1663 struct ConnectedPeer *cp;
1660 GNUNET_HashCode chash; 1664 GNUNET_HashCode chash;
1661 GNUNET_HashCode mhash; 1665 GNUNET_HashCode mhash;
@@ -1740,8 +1744,8 @@ process_reply (void *cls,
1740 pm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_PUT); 1744 pm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_PUT);
1741 pm->header.size = htons (msize); 1745 pm->header.size = htons (msize);
1742 pm->type = htonl (prq->type); 1746 pm->type = htonl (prq->type);
1743 pm->expiration = GNUNET_TIME_relative_hton (GNUNET_TIME_absolute_get_remaining (prq->expiration)); 1747 pm->expiration = GNUNET_TIME_absolute_hton (prq->expiration);
1744 memcpy (&creply[1], prq->data, prq->size); 1748 memcpy (&pm[1], prq->data, prq->size);
1745 if (NULL == cl->th) 1749 if (NULL == cl->th)
1746 cl->th = GNUNET_SERVER_notify_transmit_ready (cl->client, 1750 cl->th = GNUNET_SERVER_notify_transmit_ready (cl->client,
1747 msize, 1751 msize,
@@ -1759,18 +1763,18 @@ process_reply (void *cls,
1759 GNUNET_h2s (key), 1763 GNUNET_h2s (key),
1760 (unsigned int) cp->pid); 1764 (unsigned int) cp->pid);
1761#endif 1765#endif
1762 msize = sizeof (struct ContentMessage) + prq->size; 1766 msize = sizeof (struct PutMessage) + prq->size;
1763 reply = GNUNET_malloc (msize + sizeof (struct PendingMessage)); 1767 reply = GNUNET_malloc (msize + sizeof (struct PendingMessage));
1764 reply->cont = &transmit_reply_continuation; 1768 reply->cont = &transmit_reply_continuation;
1765 reply->cont_cls = pr; 1769 reply->cont_cls = pr;
1766 reply->msize = msize; 1770 reply->msize = msize;
1767 reply->priority = (uint32_t) -1; /* send replies first! */ 1771 reply->priority = (uint32_t) -1; /* send replies first! */
1768 cm = (struct ContentMessage*) &reply[1]; 1772 pm = (struct PutMessage*) &reply[1];
1769 cm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_CONTENT); 1773 pm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_PUT);
1770 cm->header.size = htons (msize); 1774 pm->header.size = htons (msize);
1771 cm->type = htonl (prq->type); 1775 pm->type = htonl (prq->type);
1772 cm->expiration = GNUNET_TIME_absolute_hton (prq->expiration); 1776 pm->expiration = GNUNET_TIME_absolute_hton (prq->expiration);
1773 memcpy (&reply[1], prq->data, prq->size); 1777 memcpy (&pm[1], prq->data, prq->size);
1774 add_to_pending_messages_for_peer (cp, reply, pr); 1778 add_to_pending_messages_for_peer (cp, reply, pr);
1775 } 1779 }
1776 1780
@@ -1816,7 +1820,7 @@ handle_p2p_put (void *cls,
1816 put = (const struct PutMessage*) message; 1820 put = (const struct PutMessage*) message;
1817 dsize = msize - sizeof (struct PutMessage); 1821 dsize = msize - sizeof (struct PutMessage);
1818 type = ntohl (put->type); 1822 type = ntohl (put->type);
1819 expiration = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_ntoh (put->expiration)); 1823 expiration = GNUNET_TIME_absolute_ntoh (put->expiration);
1820 1824
1821 /* first, validate! */ 1825 /* first, validate! */
1822 switch (type) 1826 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 @@
38#include "gnunet-service-fs_indexing.h" 38#include "gnunet-service-fs_indexing.h"
39#include "fs.h" 39#include "fs.h"
40 40
41#define DEBUG_FS GNUNET_NO 41#define DEBUG_FS GNUNET_YES
42
43 42
44/** 43/**
45 * In-memory information about indexed files (also available 44 * In-memory information about indexed files (also available
@@ -624,6 +623,11 @@ GNUNET_FS_handle_on_demand_block (const GNUNET_HashCode * key,
624 to remove the OnDemand block from the DS! */ 623 to remove the OnDemand block from the DS! */
625 return GNUNET_SYSERR; 624 return GNUNET_SYSERR;
626 } 625 }
626#if DEBUG_FS
627 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
628 "On-demand encoded block for query `%s'\n",
629 GNUNET_h2s (key));
630#endif
627 cont (cont_cls, 631 cont (cont_cls,
628 key, 632 key,
629 nsize, 633 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 @@
29#include "gnunet_arm_service.h" 29#include "gnunet_arm_service.h"
30#include "gnunet_fs_service.h" 30#include "gnunet_fs_service.h"
31 31
32#define VERBOSE GNUNET_NO 32#define VERBOSE GNUNET_YES
33 33
34#define START_ARM GNUNET_YES 34#define START_ARM GNUNET_YES
35 35
@@ -78,16 +78,16 @@ static void
78timeout_kill_task (void *cls, 78timeout_kill_task (void *cls,
79 const struct GNUNET_SCHEDULER_TaskContext *tc) 79 const struct GNUNET_SCHEDULER_TaskContext *tc)
80{ 80{
81 if (publish != NULL)
82 {
83 GNUNET_FS_publish_stop (publish);
84 publish = NULL;
85 }
86 if (download != NULL) 81 if (download != NULL)
87 { 82 {
88 GNUNET_FS_download_stop (download, GNUNET_YES); 83 GNUNET_FS_download_stop (download, GNUNET_YES);
89 download = NULL; 84 download = NULL;
90 } 85 }
86 else if (publish != NULL)
87 {
88 GNUNET_FS_publish_stop (publish);
89 publish = NULL;
90 }
91 timeout_kill = GNUNET_SCHEDULER_NO_TASK; 91 timeout_kill = GNUNET_SCHEDULER_NO_TASK;
92 err = 1; 92 err = 1;
93} 93}