#include "gnunet-service-fs_indexing.h"
#include "fs.h"
+#define DEBUG_FS GNUNET_YES
+
/**
* Maximum number of outgoing messages we queue per peer.
* FIXME: set to a tiny value for testing; make configurable.
#define MAX_QUEUE_PER_PEER 2
-
/**
* Maximum number of requests (from other peers) that we're
* willing to have pending at any given point in time.
size_t msize;
uint32_t prio;
-
+#if DEBUG_FS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Matched result for query `%s' with pending request\n",
+ GNUNET_h2s (key));
+#endif
GNUNET_CRYPTO_hash (prq->data,
prq->size,
&chash);
pr->remaining_priority = 0;
if (pr->client_request_list != NULL)
{
+#if DEBUG_FS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Transmitting result for query `%s' to local client\n",
+ GNUNET_h2s (key));
+#endif
cl = pr->client_request_list->client_list;
msize = sizeof (struct PutMessage) + prq->size;
creply = GNUNET_malloc (msize + sizeof (struct ClientResponseMessage));
else
{
cp = pr->pht_entry->cp;
+#if DEBUG_FS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Transmitting result for query `%s' to other peer (PID=%u)\n",
+ GNUNET_h2s (key),
+ (unsigned int) cp->pid);
+#endif
msize = sizeof (struct ContentMessage) + prq->size;
reply = GNUNET_malloc (msize + sizeof (struct PendingMessage));
reply->cont = &transmit_reply_continuation;
return GNUNET_SYSERR;
}
+#if DEBUG_FS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received result for query `%s' from peer `%4s'\n",
+ GNUNET_h2s (&query),
+ GNUNET_i2s (other));
+#endif
/* now, lookup 'query' */
prq.data = (const void*) &put[1];
prq.size = dsize;
{
#if DEBUG_FS
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Result from datastore filtered by bloomfilter.\n");
+ "Result from datastore filtered by bloomfilter (duplicate).\n");
#endif
GNUNET_FS_drq_get_next (GNUNET_YES);
return;
}
+#if DEBUG_FS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Found result for query `%s' in local datastore\n",
+ GNUNET_h2s (key));
+#endif
pr->results_found++;
if ( (pr->type == GNUNET_DATASTORE_BLOCKTYPE_KBLOCK) ||
(pr->type == GNUNET_DATASTORE_BLOCKTYPE_SBLOCK) ||
return GNUNET_OK;
}
+#if DEBUG_FS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received request for `%s' of type %u from peer `%4s'\n",
+ GNUNET_h2s (&gm->query),
+ (unsigned int) ntohl (gm->type),
+ GNUNET_i2s (other));
+#endif
pr = GNUNET_malloc (sizeof (struct PendingRequest) +
(bm & GET_MESSAGE_BIT_SKS_NAMESPACE)?sizeof(GNUNET_HashCode):0);
if ((bm & GET_MESSAGE_BIT_SKS_NAMESPACE))
client_list = cl;
}
type = ntohl (sm->type);
-
+#if DEBUG_FS
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Received request for `%s' of type %u from local client\n",
+ GNUNET_h2s (&sm->query),
+ (unsigned int) type);
+#endif
/* FIXME: detect duplicate request; if duplicate, simply update (merge)
'pr->replies_seen'! */
pr = GNUNET_malloc (sizeof (struct PendingRequest) +
static struct GNUNET_FS_PublishContext *publish;
+static GNUNET_SCHEDULER_TaskIdentifier timeout_kill;
+
static char *fn;
+static int err;
+
+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;
+ }
+ timeout_kill = GNUNET_SCHEDULER_NO_TASK;
+ err = 1;
+}
static void
abort_publish_task (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- GNUNET_FS_publish_stop (publish);
- publish = NULL;
+ if (publish != NULL)
+ {
+ GNUNET_FS_publish_stop (publish);
+ publish = NULL;
+ }
}
{
uint64_t size;
- GNUNET_FS_download_stop (download, GNUNET_YES);
- download = NULL;
+ if (download != NULL)
+ {
+ GNUNET_FS_download_stop (download, GNUNET_YES);
+ download = NULL;
+ }
GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_size (fn, &size, GNUNET_YES));
GNUNET_assert (size == FILESIZE);
GNUNET_DISK_directory_remove (fn);
GNUNET_free (fn);
fn = NULL;
+ GNUNET_SCHEDULER_cancel (sched, timeout_kill);
+ timeout_kill = GNUNET_SCHEDULER_NO_TASK;
}
case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
printf ("Download complete, %llu kbps.\n",
(unsigned long long) (FILESIZE * 1000 / (1+GNUNET_TIME_absolute_get_duration (start).value) / 1024));
- GNUNET_SCHEDULER_add_continuation (sched,
- &abort_download_task,
- NULL,
- GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+ GNUNET_SCHEDULER_add_now (sched,
+ &abort_download_task,
+ NULL);
break;
case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
GNUNET_assert (download == event->value.download.dc);
fprintf (stderr,
"Error downloading file: %s\n",
event->value.download.specifics.error.message);
- GNUNET_SCHEDULER_add_continuation (sched,
- &abort_download_task,
- NULL,
- GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+ GNUNET_SCHEDULER_add_now (sched,
+ &abort_download_task,
+ NULL);
break;
case GNUNET_FS_STATUS_PUBLISH_START:
GNUNET_assert (0 == strcmp ("publish-context", event->value.publish.cctx));
GNUNET_FS_uri_destroy (kuri);
GNUNET_CONTAINER_meta_data_destroy (meta);
GNUNET_assert (NULL != fi);
+ timeout_kill = GNUNET_SCHEDULER_add_delayed (sched,
+ TIMEOUT,
+ &timeout_kill_task,
+ NULL);
start = GNUNET_TIME_absolute_get ();
publish = GNUNET_FS_publish_start (fs,
fi,
"nohelp", options, &run, NULL);
stop_arm (&p1);
GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-download/");
- return 0;
+ return err;
}
/* end of test_fs_download.c */