Diagnose and fix rhizome MeshMS

This commit is contained in:
Andrew Bettison 2012-05-23 19:01:07 +09:30
parent 3f9e20f2f0
commit 60e4209b88
4 changed files with 53 additions and 49 deletions

View File

@ -95,7 +95,7 @@ int rhizome_bk_xor(const char *author,
if (stowSid(authorSid,0,author)) return WHYF("stowSid(%s) failed", author); if (stowSid(authorSid,0,author)) return WHYF("stowSid(%s) failed", author);
int cn=0,in=0,kp=0; int cn=0,in=0,kp=0;
if (!keyring_find_sid(keyring,&cn,&in,&kp,authorSid)) if (!keyring_find_sid(keyring,&cn,&in,&kp,authorSid))
return WHY("keyring_find_sid() couldn't find that SID. Have you unlocked that identity?"); return WHYF("keyring_find_sid() couldn't find %s. Have you unlocked that identity?", author);
for(kp=0;kp<keyring->contexts[cn]->identities[in]->keypair_count;kp++) for(kp=0;kp<keyring->contexts[cn]->identities[in]->keypair_count;kp++)
if (keyring->contexts[cn]->identities[in]->keypairs[kp]->type==KEYTYPE_RHIZOME) if (keyring->contexts[cn]->identities[in]->keypairs[kp]->type==KEYTYPE_RHIZOME)
break; break;

View File

@ -801,10 +801,10 @@ int rhizome_find_duplicate(const rhizome_manifest *m, rhizome_manifest **found)
if (sqlite3_prepare_v2(rhizome_db, sqlcmd, strlen(sqlcmd) + 1, &statement, &cmdtail) != SQLITE_OK) { if (sqlite3_prepare_v2(rhizome_db, sqlcmd, strlen(sqlcmd) + 1, &statement, &cmdtail) != SQLITE_OK) {
ret = WHY(sqlite3_errmsg(rhizome_db)); ret = WHY(sqlite3_errmsg(rhizome_db));
} else { } else {
if (debug & DEBUG_RHIZOME) DEBUGF("fileHexHash = \"%s\"", m->fileHexHash);
char filehash[RHIZOME_FILEHASH_STRLEN + 1]; char filehash[RHIZOME_FILEHASH_STRLEN + 1];
strncpy(filehash, m->fileHexHash, sizeof filehash); strncpy(filehash, m->fileHexHash, sizeof filehash);
str_toupper_inplace(filehash); str_toupper_inplace(filehash);
if (debug & DEBUG_RHIZOME) DEBUGF("filehash=\"%s\"", filehash);
sqlite3_bind_text(statement, 1, filehash, -1, SQLITE_STATIC); sqlite3_bind_text(statement, 1, filehash, -1, SQLITE_STATIC);
if (m->version != -1) if (m->version != -1)
sqlite3_bind_int64(statement, 2, m->version); sqlite3_bind_int64(statement, 2, m->version);

View File

@ -354,22 +354,22 @@ int rhizome_suggest_queue_manifest_import(rhizome_manifest *m,
int priority=100; /* normal priority */ int priority=100; /* normal priority */
int i; int i;
if (0) WHYF("Rhizome considering %s (size=%lld, priority=%d)", if (0) DEBUGF("Rhizome considering %s (size=%lld, priority=%d)",
id,filesize,priority); id,filesize,priority);
if (rhizome_manifest_version_cache_lookup(m)) { if (rhizome_manifest_version_cache_lookup(m)) {
/* We already have this version or newer */ /* We already have this version or newer */
if (1||debug&DEBUG_RHIZOMESYNC) { if (1||debug&DEBUG_RHIZOMESYNC) {
WHYF("manifest id=%s, version=%lld\n", DEBUGF("manifest id=%s, version=%lld\n",
rhizome_manifest_get(m,"id",NULL,0), rhizome_manifest_get(m,"id",NULL,0),
rhizome_manifest_get_ll(m,"version")); rhizome_manifest_get_ll(m,"version"));
WHY("We already have that manifest or newer.\n"); DEBUG("We already have that manifest or newer.\n");
} }
rhizome_manifest_free(m); rhizome_manifest_free(m);
return -1; return -1;
} else { } else {
if (debug&DEBUG_RHIZOMESYNC) { if (debug&DEBUG_RHIZOMESYNC) {
WHYF("manifest id=%s, version=%lld is new to us.\n", DEBUGF("manifest id=%s, version=%lld is new to us.\n",
rhizome_manifest_get(m,"id",NULL,0), rhizome_manifest_get(m,"id",NULL,0),
rhizome_manifest_get_ll(m,"version")); rhizome_manifest_get_ll(m,"version"));
} }
@ -426,7 +426,7 @@ int rhizome_suggest_queue_manifest_import(rhizome_manifest *m,
} else candidate_count++; } else candidate_count++;
/* shuffle down */ /* shuffle down */
int bytes=(candidate_count-(i+1))*sizeof(rhizome_candidates); int bytes=(candidate_count-(i+1))*sizeof(rhizome_candidates);
if (0) WHYF("Moving slot %d to slot %d (%d bytes = %d slots)", if (0) DEBUGF("Moving slot %d to slot %d (%d bytes = %d slots)",
i,i+1,bytes,bytes/sizeof(rhizome_candidates)); i,i+1,bytes,bytes/sizeof(rhizome_candidates));
bcopy(&candidates[i], bcopy(&candidates[i],
&candidates[i+1], &candidates[i+1],
@ -439,9 +439,9 @@ int rhizome_suggest_queue_manifest_import(rhizome_manifest *m,
int j; int j;
if (0) { if (0) {
WHY("Rhizome priorities fetch list now:"); DEBUG("Rhizome priorities fetch list now:");
for(j=0;j<candidate_count;j++) for(j=0;j<candidate_count;j++)
WHYF("%02d:%s:size=%lld, priority=%d", DEBUGF("%02d:%s:size=%lld, priority=%d",
j, j,
rhizome_manifest_get(candidates[j].manifest,"id",NULL,0), rhizome_manifest_get(candidates[j].manifest,"id",NULL,0),
candidates[j].size,candidates[j].priority); candidates[j].size,candidates[j].priority);
@ -463,7 +463,7 @@ int rhizome_enqueue_suggestions()
if (i) { if (i) {
/* now shuffle up */ /* now shuffle up */
int bytes=(candidate_count-i)*sizeof(rhizome_candidates); int bytes=(candidate_count-i)*sizeof(rhizome_candidates);
if (0) WHYF("Moving slot %d to slot 0 (%d bytes = %d slots)", if (0) DEBUGF("Moving slot %d to slot 0 (%d bytes = %d slots)",
i,bytes,bytes/sizeof(rhizome_candidates)); i,bytes,bytes/sizeof(rhizome_candidates));
bcopy(&candidates[i],&candidates[0],bytes); bcopy(&candidates[i],&candidates[0],bytes);
candidate_count-=i; candidate_count-=i;
@ -494,15 +494,15 @@ int rhizome_queue_manifest_import(rhizome_manifest *m,
if (rhizome_manifest_version_cache_lookup(m)) { if (rhizome_manifest_version_cache_lookup(m)) {
/* We already have this version or newer */ /* We already have this version or newer */
if (debug&DEBUG_RHIZOMESYNC) { if (debug&DEBUG_RHIZOMESYNC) {
WHYF("manifest id=%s, version=%lld\n", DEBUGF("manifest id=%s, version=%lld\n",
rhizome_manifest_get(m,"id",NULL,0), rhizome_manifest_get(m,"id",NULL,0),
rhizome_manifest_get_ll(m,"version")); rhizome_manifest_get_ll(m,"version"));
WHY("We already have that manifest or newer.\n"); DEBUG("We already have that manifest or newer.\n");
} }
return -1; return -1;
} else { } else {
if (debug&DEBUG_RHIZOMESYNC) { if (debug&DEBUG_RHIZOMESYNC) {
WHYF("manifest id=%s, version=%lld is new to us.\n", DEBUGF("manifest id=%s, version=%lld is new to us.\n",
rhizome_manifest_get(m,"id",NULL,0), rhizome_manifest_get(m,"id",NULL,0),
rhizome_manifest_get_ll(m,"version")); rhizome_manifest_get_ll(m,"version"));
} }
@ -510,7 +510,7 @@ int rhizome_queue_manifest_import(rhizome_manifest *m,
/* Don't queue if queue slots already full */ /* Don't queue if queue slots already full */
if (rhizome_file_fetch_queue_count>=MAX_QUEUED_FILES) { if (rhizome_file_fetch_queue_count>=MAX_QUEUED_FILES) {
if (debug&DEBUG_RHIZOME) WHY("Already busy fetching files"); if (debug&DEBUG_RHIZOME) DEBUG("Already busy fetching files");
return -1; return -1;
} }
/* Don't queue if already queued */ /* Don't queue if already queued */
@ -520,7 +520,7 @@ int rhizome_queue_manifest_import(rhizome_manifest *m,
*q=&file_fetch_queue[i]; *q=&file_fetch_queue[i];
if (!strcasecmp(id,rhizome_manifest_get(q->manifest,"id",NULL,0))) { if (!strcasecmp(id,rhizome_manifest_get(q->manifest,"id",NULL,0))) {
if (debug&DEBUG_RHIZOMESYNC) if (debug&DEBUG_RHIZOMESYNC)
WHYF("Already have %s in the queue.\n",id); DEBUGF("Already have %s in the queue.\n",id);
return -1; return -1;
} }
} }
@ -532,7 +532,7 @@ int rhizome_queue_manifest_import(rhizome_manifest *m,
long long filesize=rhizome_manifest_get_ll(m,"filesize"); long long filesize=rhizome_manifest_get_ll(m,"filesize");
if (debug&DEBUG_RHIZOMESYNC) if (debug&DEBUG_RHIZOMESYNC)
WHYF("Getting ready to fetch file %s for manifest %s\n",filehash,rhizome_manifest_get(m,"id",NULL,0)); DEBUGF("Getting ready to fetch file %s for manifest %s\n",filehash,rhizome_manifest_get(m,"id",NULL,0));
if (filesize > 0 && filehash[0]) if (filesize > 0 && filehash[0])
{ {
@ -553,7 +553,7 @@ int rhizome_queue_manifest_import(rhizome_manifest *m,
if (j==crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES) if (j==crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES)
{ {
/* We are already fetching this manifest */ /* We are already fetching this manifest */
if (debug&DEBUG_RHIZOME) WHYF("Already fetching manifest\n"); if (debug&DEBUG_RHIZOME) DEBUGF("Already fetching manifest\n");
return -1; return -1;
} }
for(j=0;j<=RHIZOME_FILEHASH_STRLEN;j++) for(j=0;j<=RHIZOME_FILEHASH_STRLEN;j++)
@ -561,7 +561,7 @@ int rhizome_queue_manifest_import(rhizome_manifest *m,
if (j==RHIZOME_FILEHASH_STRLEN + 1) if (j==RHIZOME_FILEHASH_STRLEN + 1)
{ {
/* We are already fetching this file */ /* We are already fetching this file */
if (debug&DEBUG_RHIZOME) WHYF("Already fetching file %s\n", if (debug&DEBUG_RHIZOME) DEBUGF("Already fetching file %s\n",
filehash); filehash);
return -1; return -1;
} }
@ -579,7 +579,7 @@ int rhizome_queue_manifest_import(rhizome_manifest *m,
if ((errno!=EINPROGRESS)&&(r!=0)) { if ((errno!=EINPROGRESS)&&(r!=0)) {
WHY_perror("connect"); WHY_perror("connect");
close (sock); close (sock);
if (debug&DEBUG_RHIZOME) WHY("Failed to open socket to peer's rhizome web server"); if (debug&DEBUG_RHIZOME) DEBUG("Failed to open socket to peer's rhizome web server");
return -1; return -1;
} }
@ -638,9 +638,13 @@ int rhizome_queue_manifest_import(rhizome_manifest *m,
else else
{ {
if (debug&DEBUG_RHIZOMESYNC) if (debug&DEBUG_RHIZOMESYNC)
WHYF("We already have the file for this manifest; importing from manifest alone.\n"); DEBUGF("We already have the file for this manifest; importing from manifest alone.\n");
m->finalised=1; const char *filehash = rhizome_manifest_get(m, "filehash", NULL, 0);
if (filehash == NULL)
return WHY("Manifest missing filehash");
strncpy(m->fileHexHash, filehash, sizeof m->fileHexHash);
m->fileHashedP=1; m->fileHashedP=1;
m->finalised=1;
m->manifest_bytes=m->manifest_all_bytes; m->manifest_bytes=m->manifest_all_bytes;
const char *id = rhizome_manifest_get(m, "id", NULL, 0); const char *id = rhizome_manifest_get(m, "id", NULL, 0);
if (id == NULL) if (id == NULL)
@ -687,7 +691,7 @@ int rhizome_fetching_get_fds(struct pollfd *fds,int *fdcount,int fdmax)
{ {
if ((*fdcount)>=fdmax) return -1; if ((*fdcount)>=fdmax) return -1;
if (debug&DEBUG_RHIZOMESYNC) { if (debug&DEBUG_RHIZOMESYNC) {
WHYF("rhizome file fetch request #%d is poll() slot #%d (fd %d)\n", DEBUGF("rhizome file fetch request #%d is poll() slot #%d (fd %d)\n",
i,*fdcount,file_fetch_queue[i].socket); } i,*fdcount,file_fetch_queue[i].socket); }
fds[*fdcount].fd=file_fetch_queue[i].socket; fds[*fdcount].fd=file_fetch_queue[i].socket;
switch(file_fetch_queue[i].state) { switch(file_fetch_queue[i].state) {
@ -716,7 +720,7 @@ int rhizome_fetch_poll()
rhizome_last_fetch_enqueue_time=overlay_gettime_ms(); rhizome_last_fetch_enqueue_time=overlay_gettime_ms();
} }
if (0&&debug&DEBUG_RHIZOME) WHYF("Checking %d active fetch requests", if (0&&debug&DEBUG_RHIZOME) DEBUGF("Checking %d active fetch requests",
rhizome_file_fetch_queue_count); rhizome_file_fetch_queue_count);
for(rn=0;rn<rhizome_file_fetch_queue_count;rn++) for(rn=0;rn<rhizome_file_fetch_queue_count;rn++)
{ {
@ -730,7 +734,7 @@ int rhizome_fetch_poll()
switch(q->state) switch(q->state)
{ {
case RHIZOME_FETCH_SENDINGHTTPREQUEST: case RHIZOME_FETCH_SENDINGHTTPREQUEST:
WHYF("sending http request (%d of %d bytes sent)", DEBUGF("sending http request (%d of %d bytes sent)",
q->request_ofs,q->request_len); q->request_ofs,q->request_len);
bytes=write(q->socket,&q->request[q->request_ofs], bytes=write(q->socket,&q->request[q->request_ofs],
q->request_len-q->request_ofs); q->request_len-q->request_ofs);
@ -741,8 +745,8 @@ int rhizome_fetch_poll()
/* Sent all of request. Switch to listening for HTTP response headers. /* Sent all of request. Switch to listening for HTTP response headers.
*/ */
if (debug&DEBUG_RHIZOME) { if (debug&DEBUG_RHIZOME) {
WHYF("Sent http request to fetch file. (%d of %d bytes)\n",q->request_ofs,q->request_len); DEBUGF("Sent http request to fetch file. (%d of %d bytes)\n",q->request_ofs,q->request_len);
WHYF("sent [%s]\n",q->request); DEBUGF("sent [%s]\n",q->request);
} }
q->request_len=0; q->request_ofs=0; q->request_len=0; q->request_ofs=0;
q->state=RHIZOME_FETCH_RXHTTPHEADERS; q->state=RHIZOME_FETCH_RXHTTPHEADERS;
@ -755,7 +759,7 @@ int rhizome_fetch_poll()
case RHIZOME_FETCH_RXFILE: case RHIZOME_FETCH_RXFILE:
/* Keep reading until we have the promised amount of data */ /* Keep reading until we have the promised amount of data */
if (debug&DEBUG_RHIZOME) if (debug&DEBUG_RHIZOME)
WHYF("receiving rhizome fetch file body (current offset=%d of %d)\n", DEBUGF("receiving rhizome fetch file body (current offset=%d of %d)\n",
q->file_ofs,q->file_len); q->file_ofs,q->file_len);
sigPipeFlag=0; sigPipeFlag=0;
@ -770,14 +774,14 @@ int rhizome_fetch_poll()
action=1; action=1;
if (debug&DEBUG_RHIZOME) if (debug&DEBUG_RHIZOME)
WHYF("Read %d bytes; we now have %d of %d bytes.\n", DEBUGF("Read %d bytes; we now have %d of %d bytes.\n",
bytes,q->file_ofs+bytes,q->file_len); bytes,q->file_ofs+bytes,q->file_len);
if (bytes>(q->file_len-q->file_ofs)) if (bytes>(q->file_len-q->file_ofs))
bytes=q->file_len-q->file_ofs; bytes=q->file_len-q->file_ofs;
if (fwrite(buffer,bytes,1,q->file)!=1) if (fwrite(buffer,bytes,1,q->file)!=1)
{ {
if (debug&DEBUG_RHIZOME) WHYF("Failed writing %d bytes to file. @ offset %d\n",bytes,q->file_ofs); if (debug&DEBUG_RHIZOME) DEBUGF("Failed writing %d bytes to file. @ offset %d\n",bytes,q->file_ofs);
q->close=1; q->close=1;
continue; continue;
} }
@ -791,7 +795,7 @@ int rhizome_fetch_poll()
{ {
/* got all of file */ /* got all of file */
q->close=1; q->close=1;
if (debug&DEBUG_RHIZOME) WHYF("Received all of file via rhizome -- now to import it\n"); if (debug&DEBUG_RHIZOME) DEBUGF("Received all of file via rhizome -- now to import it\n");
{ {
fclose(q->file); q->file=NULL; fclose(q->file); q->file=NULL;
const char *id = rhizome_manifest_get(q->manifest, "id", NULL, 0); const char *id = rhizome_manifest_get(q->manifest, "id", NULL, 0);
@ -802,8 +806,8 @@ int rhizome_fetch_poll()
return -1; return -1;
/* Do really write the manifest unchanged */ /* Do really write the manifest unchanged */
if (debug&DEBUG_RHIZOME) { if (debug&DEBUG_RHIZOME) {
WHYF("manifest has %d signatories\n",q->manifest->sig_count); DEBUGF("manifest has %d signatories\n",q->manifest->sig_count);
WHYF("manifest id = %s, len=%d\n", DEBUGF("manifest id = %s, len=%d\n",
rhizome_manifest_get(q->manifest,"id",NULL,0), rhizome_manifest_get(q->manifest,"id",NULL,0),
q->manifest->manifest_bytes); q->manifest->manifest_bytes);
dump("manifest",&q->manifest->manifestdata[0], dump("manifest",&q->manifest->manifestdata[0],
@ -829,7 +833,7 @@ int rhizome_fetch_poll()
break; break;
case RHIZOME_FETCH_RXHTTPHEADERS: case RHIZOME_FETCH_RXHTTPHEADERS:
/* Keep reading until we have two CR/LFs in a row */ /* Keep reading until we have two CR/LFs in a row */
if (debug&DEBUG_RHIZOME) WHY("receiving rhizome fetch http headers"); if (debug&DEBUG_RHIZOME) DEBUG("receiving rhizome fetch http headers");
sigPipeFlag=0; sigPipeFlag=0;
@ -869,23 +873,23 @@ int rhizome_fetch_poll()
/* Get HTTP result code */ /* Get HTTP result code */
char *s=strstr(q->request,"HTTP/1.0 "); char *s=strstr(q->request,"HTTP/1.0 ");
if (!s) { if (!s) {
if (debug&DEBUG_RHIZOME) WHYF("HTTP response lacked HTTP/1.0 response code.\n"); if (debug&DEBUG_RHIZOME) DEBUGF("HTTP response lacked HTTP/1.0 response code.\n");
q->close=1; continue; } q->close=1; continue; }
int http_response_code=strtoll(&s[9],NULL,10); int http_response_code=strtoll(&s[9],NULL,10);
if (http_response_code!=200) { if (http_response_code!=200) {
if (debug&DEBUG_RHIZOME) WHYF("Rhizome web server returned %d != 200 OK\n",http_response_code); if (debug&DEBUG_RHIZOME) DEBUGF("Rhizome web server returned %d != 200 OK\n",http_response_code);
q->close=1; continue; q->close=1; continue;
} }
/* Get content length */ /* Get content length */
s=strstr(q->request,"Content-length: "); s=strstr(q->request,"Content-length: ");
if (!s) { if (!s) {
if (debug&DEBUG_RHIZOME) if (debug&DEBUG_RHIZOME)
WHYF("Missing Content-Length: header.\n"); DEBUGF("Missing Content-Length: header.\n");
q->close=1; continue; } q->close=1; continue; }
q->file_len=strtoll(&s[16],NULL,10); q->file_len=strtoll(&s[16],NULL,10);
if (q->file_len<0) { if (q->file_len<0) {
if (debug&DEBUG_RHIZOME) if (debug&DEBUG_RHIZOME)
WHYF("Illegal file size (%d).\n",q->file_len); DEBUGF("Illegal file size (%d).\n",q->file_len);
q->close=1; continue; } q->close=1; continue; }
/* Okay, we have both, and are all set. /* Okay, we have both, and are all set.
@ -897,14 +901,14 @@ int rhizome_fetch_poll()
if (fwrite(&q->request[i+1],fileRxBytes,1,q->file)!=1) if (fwrite(&q->request[i+1],fileRxBytes,1,q->file)!=1)
{ {
if (debug&DEBUG_RHIZOME) if (debug&DEBUG_RHIZOME)
WHYF("Failed writing initial %d bytes to file.\n", DEBUGF("Failed writing initial %d bytes to file.\n",
fileRxBytes); fileRxBytes);
q->close=1; q->close=1;
continue; continue;
} }
q->file_ofs=fileRxBytes; q->file_ofs=fileRxBytes;
if (debug&DEBUG_RHIZOME) if (debug&DEBUG_RHIZOME)
WHYF("Read %d initial bytes of %d total\n", DEBUGF("Read %d initial bytes of %d total\n",
q->file_ofs,q->file_len); q->file_ofs,q->file_len);
q->state=RHIZOME_FETCH_RXFILE; q->state=RHIZOME_FETCH_RXFILE;
} }
@ -917,7 +921,7 @@ int rhizome_fetch_poll()
if (!action) { if (!action) {
if (time(0)-q->last_action>RHIZOME_IDLE_TIMEOUT) { if (time(0)-q->last_action>RHIZOME_IDLE_TIMEOUT) {
if (debug&DEBUG_RHIZOME) if (debug&DEBUG_RHIZOME)
WHY("Closing connection due to inactivity timeout."); DEBUG("Closing connection due to inactivity timeout.");
q->close=1; q->close=1;
continue; continue;
} }
@ -926,14 +930,14 @@ int rhizome_fetch_poll()
if (sigPipeFlag||((bytes==0)&&(errno==0))) { if (sigPipeFlag||((bytes==0)&&(errno==0))) {
/* broken pipe, so close connection */ /* broken pipe, so close connection */
if (debug&DEBUG_RHIZOME) if (debug&DEBUG_RHIZOME)
WHY("Closing rhizome fetch connection due to sigpipe"); DEBUG("Closing rhizome fetch connection due to sigpipe");
q->close=1; q->close=1;
continue; continue;
} }
break; break;
default: default:
if (debug&DEBUG_RHIZOME) if (debug&DEBUG_RHIZOME)
WHY("Closing rhizome fetch connection due to illegal/unimplemented state."); DEBUG("Closing rhizome fetch connection due to illegal/unimplemented state.");
q->close=1; q->close=1;
break; break;
} }
@ -962,7 +966,7 @@ int rhizome_fetch_poll()
rhizome_file_fetch_queue_count--; rhizome_file_fetch_queue_count--;
if (debug&DEBUG_RHIZOME) if (debug&DEBUG_RHIZOME)
WHYF("Released rhizome fetch slot (%d remaining)", DEBUGF("Released rhizome fetch slot (%d remaining)",
rhizome_file_fetch_queue_count); rhizome_file_fetch_queue_count);
} }
} }

View File

@ -319,7 +319,8 @@ int overlay_rhizome_saw_advertisements(int i,overlay_frame *f, long long now)
{ {
/* Extract whole manifests */ /* Extract whole manifests */
while(ofs<f->payload->length) { while(ofs<f->payload->length) {
char *manifest_id=NULL; char manifest_id_buf[RHIZOME_MANIFEST_ID_STRLEN + 1];
char *manifest_id = NULL;
manifest_length=(f->payload->bytes[ofs]<<8)+f->payload->bytes[ofs+1]; manifest_length=(f->payload->bytes[ofs]<<8)+f->payload->bytes[ofs+1];
if (manifest_length>=0xff00) { if (manifest_length>=0xff00) {
ofs++; ofs++;
@ -383,7 +384,7 @@ int overlay_rhizome_saw_advertisements(int i,overlay_frame *f, long long now)
importManifest=1; importManifest=1;
} }
manifest_id=rhizome_manifest_get(m,"id",NULL,0); manifest_id = rhizome_manifest_get(m, "id", manifest_id_buf, sizeof manifest_id_buf);
} }
else else
{ {
@ -402,17 +403,16 @@ int overlay_rhizome_saw_advertisements(int i,overlay_frame *f, long long now)
m=rhizome_read_manifest_file((char *)&f->payload->bytes[ofs], m=rhizome_read_manifest_file((char *)&f->payload->bytes[ofs],
manifest_length,RHIZOME_VERIFY); manifest_length,RHIZOME_VERIFY);
if (m->errors) { if (m->errors) {
if (debug&DEBUG_RHIZOME) WHYF("Verifying manifest %s revealed errors -- not storing.",manifest_id); if (debug&DEBUG_RHIZOME) WHYF("Verifying manifest %s revealed errors -- not storing.", manifest_id);
rhizome_queue_ignore_manifest(m,(struct sockaddr_in*)f->recvaddr,60000); rhizome_queue_ignore_manifest(m,(struct sockaddr_in*)f->recvaddr,60000);
rhizome_manifest_free(m); rhizome_manifest_free(m);
} else { } else {
if (debug&DEBUG_RHIZOME) WHYF("Verifying manifest %s revealed no errors -- will try to store.",manifest_id); if (debug&DEBUG_RHIZOME) WHYF("Verifying manifest %s revealed no errors -- will try to store.", manifest_id);
/* Add manifest to import queue. We need to know originating IPv4 address /* Add manifest to import queue. We need to know originating IPv4 address
so that we can transfer by HTTP. */ so that we can transfer by HTTP. */
if (0) WHY("Suggesting fetching of a bundle"); if (0) WHY("Suggesting fetching of a bundle");
rhizome_suggest_queue_manifest_import rhizome_suggest_queue_manifest_import(m,(struct sockaddr_in *)f->recvaddr);
(m,(struct sockaddr_in *)f->recvaddr);
} }
} }
else else