progress on tracking down post-merge bugs that are stopping

rhizome direct push/pull/sync tests from working. #9
This commit is contained in:
gardners 2012-10-03 17:55:55 +02:00
parent 295f7c68ec
commit 99f8e9b86d
3 changed files with 28 additions and 24 deletions

View File

@ -777,21 +777,23 @@ int rhizome_direct_get_bars(const unsigned char bid_low[RHIZOME_MANIFEST_ID_BYTE
snprintf(query,1024,
"SELECT BAR,ROWID,ID,FILESIZE FROM MANIFESTS"
" WHERE ID>='%s' AND ID<='%s' AND FILESIZE BETWEEN %lld AND %lld"
" WHERE"
" FILESIZE BETWEEN %lld AND %lld"
" AND ID>='%s' AND ID<='%s'"
// The following formulation doesn't remove the weird returning of
// bundles with out of range filesize values
// " WHERE ID>='%s' AND ID<='%s' AND FILESIZE > %lld AND FILESIZE < %lld"
" ORDER BY BAR LIMIT %d;",
size_low, size_high,
alloca_tohex(bid_low,RHIZOME_MANIFEST_ID_BYTES),
alloca_tohex(bid_max,RHIZOME_MANIFEST_ID_BYTES),
size_low,size_high,
bars_requested);
sqlite3_stmt *statement=sqlite_prepare(query);
sqlite3_blob *blob=NULL;
int bars_written=0;
while(bars_written<bars_requested
&& sqlite_step_retry(&retry, statement) == SQLITE_ROW)
{
@ -807,7 +809,7 @@ int rhizome_direct_get_bars(const unsigned char bid_low[RHIZOME_MANIFEST_ID_BYTE
DEBUGF("WEIRDNESS ALERT: filesize=%lld, but query was: %s",
filesize,query);
break;
}
}
int64_t rowid = sqlite3_column_int64(statement, 1);
do ret = sqlite3_blob_open(rhizome_db, "main", "manifests", "bar",
rowid, 0 /* read only */, &blob);

View File

@ -783,7 +783,6 @@ void rhizome_direct_http_dispatch(rhizome_direct_sync_request *r)
len=r->cursor->buffer_offset_bytes+r->cursor->buffer_used;
sent=0;
while(sent<len) {
DEBUGF("write(%d, %s, %d)", sock, alloca_toprint(-1, (const char*)&r->cursor->buffer[sent], len-sent), len-sent);
int count=write(sock,&r->cursor->buffer[sent],len-sent);
if (count == -1) {
if (errno == EPIPE)
@ -880,7 +879,12 @@ void rhizome_direct_http_dispatch(rhizome_direct_sync_request *r)
}
DEBUGF("content_length=%d",content_length);
dump("response",(unsigned char *)p,content_length);
/* For some reason the response data gets overwritten during a push,
so we need to copy it, and use the copy instead. */
unsigned char *actionlist=alloca(content_length);
bcopy(p,actionlist,content_length);
dump("response",actionlist,content_length);
/* We now have the list of (1+RHIZOME_BAR_PREFIX_BYTES)-byte records that indicate
the list of BAR prefixes that differ between the two nodes. We can now action
@ -893,17 +897,16 @@ void rhizome_direct_http_dispatch(rhizome_direct_sync_request *r)
For now, I am just going to implement it in here, and we can generalise later.
*/
DEBUGF("XXX Need to parse responses into actions");
int i;
for(i=10;i<content_length;i+=(1+RHIZOME_BAR_PREFIX_BYTES))
{
int type=p[i];
int type=actionlist[i];
// unsigned char *bid_prefix=(unsigned char *)&p[i+1];
unsigned long long
bid_prefix_ll=rhizome_bar_bidprefix_ll((unsigned char *)&p[i+1]);
DEBUGF("%s %016llx*",type==1?"push":"pull",bid_prefix_ll);
bid_prefix_ll=rhizome_bar_bidprefix_ll((unsigned char *)&actionlist[i+1]);
dump("response",(unsigned char *)actionlist,content_length);
DEBUGF("%s %016llx* @ 0x%x",type==1?"push":"pull",bid_prefix_ll,i);
if (type==2&&r->pullP) {
WARN("XXX Rhizome direct http pull yet implemented");
/* Need to fetch manifest. Once we have the manifest, then we can
use our normal bundle fetch routines from rhizome_fetch.c
@ -914,7 +917,7 @@ void rhizome_direct_http_dispatch(rhizome_direct_sync_request *r)
existing routines.
*/
if (!rhizome_fetch_request_manifest_by_prefix
(&addr,(unsigned char *)&p[i+1],RHIZOME_BAR_PREFIX_BYTES,
(&addr,&actionlist[i+1],RHIZOME_BAR_PREFIX_BYTES,
1 /* import, getting file if needed */))
{
/* Fetching the manifest, and then using it to see if we want to
@ -929,7 +932,7 @@ void rhizome_direct_http_dispatch(rhizome_direct_sync_request *r)
/* Start by getting the manifest, which is the main thing we need, and also
gives us the information we need for sending any associated file. */
rhizome_manifest
*m=rhizome_direct_get_manifest((unsigned char *)&p[i+1],
*m=rhizome_direct_get_manifest(&actionlist[i+1],
RHIZOME_BAR_PREFIX_BYTES);
if (!m) {
WHY("This should never happen. The manifest exists, but when I went looking for it, it doesn't appear to be there.");
@ -999,7 +1002,6 @@ void rhizome_direct_http_dispatch(rhizome_direct_sync_request *r)
int sent=0;
/* Send buffer now */
while(sent<len) {
DEBUGF("write(%d, %s, %d)", sock, alloca_toprint(-1, &buffer[sent], len-sent), len-sent);
int r=write(sock,&buffer[sent],len-sent);
if (r>0) sent+=r;
if (r<0) goto closeit;
@ -1023,7 +1025,6 @@ void rhizome_direct_http_dispatch(rhizome_direct_sync_request *r)
int sr=sqlite3_blob_read(blob,buffer,count,i);
if (sr==SQLITE_OK||sr==SQLITE_DONE)
{
DEBUGF("write(%d, %s, %d)", sock, alloca_toprint(-1, (char *)buffer, count), count);
count=write(sock,buffer,count);
if (count<0) {
WHY_perror("write");
@ -1045,7 +1046,6 @@ void rhizome_direct_http_dispatch(rhizome_direct_sync_request *r)
len=snprintf(buffer,8192,"\r\n--%s--\r\n",boundary);
sent=0;
while(sent<len) {
DEBUGF("write(%d, %s, %d)", sock, alloca_toprint(-1, &buffer[sent], len-sent), len-sent);
int r=write(sock,&buffer[sent],len-sent);
if (r>0) sent+=r;
if (r<0) goto closeit;
@ -1060,6 +1060,7 @@ void rhizome_direct_http_dispatch(rhizome_direct_sync_request *r)
if (m) rhizome_manifest_free(m);
}
next_item:
DEBUGF("Next item.");
continue;
}

View File

@ -274,8 +274,9 @@ setup_sync() {
add_file file2
BID2=$BID
VERSION2=$VERSION
set_instance +A
executeOk_servald config set rhizome.direct.peer.count "1"
executeOk_servald config set rhizome.direct.peer.0 "http://${addr_localhost}:${PORTA}"
executeOk_servald config set rhizome.direct.peer.0 "http://${addr_localhost}:${PORTB}"
start_servald_instances dummy2 +B
}
@ -285,13 +286,13 @@ setup_Push() {
setup_sync
}
test_Push() {
executeOk_servald rhizome direct push
set_instance +A
executeOk_servald rhizome direct push
executeOk_servald rhizome list ''
assert_rhizome_list file1 file2
assert_rhizome_list file1
set_instance +B
executeOk_servald rhizome list ''
assert_rhizome_list file2
assert_rhizome_list file1 file2
}
doc_Pull="One way pull bundle from unconnected node"
@ -300,13 +301,13 @@ setup_Pull() {
setup_sync
}
test_Pull() {
executeOk_servald rhizome direct pull
set_instance +A
executeOk_servald rhizome list ''
assert_rhizome_list file1
set_instance +B
executeOk_servald rhizome direct pull
executeOk_servald rhizome list ''
assert_rhizome_list file1 file2
set_instance +B
executeOk_servald rhizome list ''
assert_rhizome_list file2
}
doc_Sync="Two-way sync bundles between unconnected nodes"