From 25a64b5485cf1ac861cd2a8b2dd6d7b74dbdbba5 Mon Sep 17 00:00:00 2001 From: gardners Date: Wed, 3 Oct 2012 01:35:13 +0930 Subject: [PATCH] fixed some more bugs in rhizome direct http pull. Now actually triggers the http request to obtain the file, but the peer address is 0.0.0.0:0. Investigating. #9 --- rhizome_fetch.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/rhizome_fetch.c b/rhizome_fetch.c index 1f5f77d2..ee8f4e46 100644 --- a/rhizome_fetch.c +++ b/rhizome_fetch.c @@ -508,7 +508,7 @@ int rhizome_suggest_queue_manifest_import(rhizome_manifest *m, struct sockaddr_i candidates[i].peer=*peerip; int j; - if (0) { + if (1) { DEBUG("Rhizome priorities fetch list now:"); for(j=0;jalarm = gettime_ms() + rhizome_fetch_interval_ms; - alarm->deadline = alarm->alarm + rhizome_fetch_interval_ms*3; - schedule(alarm); + if (alarm) { + alarm->alarm = gettime_ms() + rhizome_fetch_interval_ms; + alarm->deadline = alarm->alarm + rhizome_fetch_interval_ms*3; + schedule(alarm); + } return; } @@ -569,7 +571,7 @@ int rhizome_queue_manifest_import(rhizome_manifest *m, struct sockaddr_in *peeri the cache slot number to implicitly store the first bits. */ - if (debug & DEBUG_RHIZOME_RX) + if (1||debug & DEBUG_RHIZOME_RX) DEBUGF("Fetching manifest bid=%s version=%lld size=%lld:", bid, m->version, filesize); if (rhizome_manifest_version_cache_lookup(m)) { @@ -591,10 +593,12 @@ int rhizome_queue_manifest_import(rhizome_manifest *m, struct sockaddr_in *peeri /* Don't queue if already queued */ int i; for (i = 0; i < rhizome_file_fetch_queue_count; ++i) { - if (memcmp(m->cryptoSignPublic, file_fetch_queue[i].manifest->cryptoSignPublic, RHIZOME_MANIFEST_ID_BYTES) == 0) { - if (debug & DEBUG_RHIZOME_RX) - DEBUGF(" manifest fetch already queued"); - return 3; + if (file_fetch_queue[i].manifest) { + if (memcmp(m->cryptoSignPublic, file_fetch_queue[i].manifest->cryptoSignPublic, RHIZOME_MANIFEST_ID_BYTES) == 0) { + if (debug & DEBUG_RHIZOME_RX) + DEBUGF(" manifest fetch already queued"); + return 3; + } } } @@ -803,8 +807,9 @@ void rhizome_write_content(rhizome_file_fetch_record *q, char *buffer, int bytes DEBUGF("Couldn't read manifest from %s",q->filename); rhizome_manifest_free(m); } else { - DEBUGF("All looks good for importing manifest"); + DEBUGF("All looks good for importing manifest %p",m); rhizome_suggest_queue_manifest_import(m,&q->peer); + rhizome_enqueue_suggestions(NULL); } } } @@ -1014,12 +1019,12 @@ int rhizome_fetch_request_manifest_by_prefix(struct sockaddr_in *peerip, return -1; } if (strlen(q->filename)filename)) - strcpy(filename,q->filename); + strcpy(q->filename,filename); else q->filename[0]=0; if ((q->file = fopen(filename, "w")) == NULL) { WHY_perror("fopen"); - if (debug & DEBUG_RHIZOME_RX) + // if (debug & DEBUG_RHIZOME_RX) DEBUGF("Could not open '%s' to write received file", filename); close(sock); return -1;