Add some helpful debug logging

This commit is contained in:
Andrew Bettison 2012-05-24 18:46:08 +09:30
parent 43c7297a47
commit c847478140
2 changed files with 13 additions and 4 deletions

View File

@ -154,6 +154,13 @@ int rhizome_add_manifest(rhizome_manifest *m_in,
const char *author // NULL or zero-length to make an unauthored manifest
)
{
if (debug&DEBUG_RHIZOMESYNC)
DEBUGF("rhizome_add_manifest(m_in=%p, m_out=%p, filename=%s, groups=%p, ttl=%d, verifyP=%d, checkFileP=%d, signP=%d, author=%s)",
m_in, m_out,
filename ? filename : "NULL",
groups, ttl, verifyP, checkFileP, signP,
author ? author : "NULL"
);
if (m_out) *m_out = NULL;
if (author && !author[0]) author = NULL;
@ -200,6 +207,8 @@ int rhizome_add_manifest(rhizome_manifest *m_in,
if (lstat(filename,&stat))
return WHYF("Could not stat() payload file '%s'",filename);
m_in->fileLength = stat.st_size;
if (debug & DEBUG_RHIZOME)
DEBUGF("filename=%s, fileLength=%lld", filename, m_in->fileLength);
long long mfilesize = rhizome_manifest_get_ll(m_in, "filesize");
if (mfilesize != -1 && mfilesize != m_in->fileLength) {
WHYF("Manifest.filesize (%lld) != actual file size (%lld)", mfilesize, m_in->fileLength);

View File

@ -612,17 +612,17 @@ int rhizome_queue_manifest_import(rhizome_manifest *m, struct sockaddr_in *peeri
return -1;
}
q->manifest->dataFileName = strdup(filename);
q->file=fopen(filename,"w");
q->file=fopen(q->manifest->dataFileName,"w");
if (!q->file) {
WHY_perror("fopen");
if (debug&DEBUG_RHIZOME)
DEBUGF("Could not open '%s' to write received file.", filename);
DEBUGF("Could not open '%s' to write received file.", q->manifest->dataFileName);
close(sock);
return -1;
}
rhizome_file_fetch_queue_count++;
if (debug&DEBUG_RHIZOME) DEBUGF("Queued file for fetching (%d in queue)",
rhizome_file_fetch_queue_count);
if (debug&DEBUG_RHIZOME) DEBUGF("Queued file for fetching into %s (%d in queue)",
q->manifest->dataFileName, rhizome_file_fetch_queue_count);
return 0;
}
else