mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-20 21:53:12 +00:00
debugging and abstraction improvements in rhizome direct
synchronisation code. #9
This commit is contained in:
parent
f0472abf43
commit
f7e75d5347
@ -267,6 +267,7 @@ int rhizome_find_duplicate(const rhizome_manifest *m, rhizome_manifest **found,
|
||||
int checkVersionP);
|
||||
int rhizome_manifest_to_bar(rhizome_manifest *m,unsigned char *bar);
|
||||
long long rhizome_bar_version(unsigned char *bar);
|
||||
unsigned long long rhizome_bar_bidprefix(unsigned char *bar);
|
||||
int rhizome_queue_manifest_import(rhizome_manifest *m, struct sockaddr_in *peerip, int *manifest_kept);
|
||||
int rhizome_list_manifests(const char *service, const char *sender_sid, const char *recipient_sid, int limit, int offset);
|
||||
int rhizome_retrieve_manifest(const char *manifestid, rhizome_manifest **mp);
|
||||
|
@ -317,6 +317,8 @@ rhizome_direct_bundle_cursor *rhizome_direct_get_fill_response
|
||||
8);
|
||||
c->buffer_used+=1+8;
|
||||
who=-1;
|
||||
DEBUGF("They have previously unseen bundle %016llx*",
|
||||
rhizome_bar_bidprefix(&buffer[10+them*RHIZOME_BAR_BYTES]));
|
||||
} else if (relation>0) {
|
||||
/* We have a bundle that they don't have any version of
|
||||
Append 9-byte "I have [newer]" record consisting of 0x02 followed
|
||||
@ -327,6 +329,8 @@ rhizome_direct_bundle_cursor *rhizome_direct_get_fill_response
|
||||
8);
|
||||
c->buffer_used+=1+8;
|
||||
who=+1;
|
||||
DEBUGF("We have previously unseen bundle %016llx*",
|
||||
rhizome_bar_bidprefix(&usbuffer[10+us*RHIZOME_BAR_BYTES]));
|
||||
} else {
|
||||
/* We each have a version of this bundle, so see whose is newer */
|
||||
long long them_version
|
||||
@ -340,6 +344,10 @@ rhizome_direct_bundle_cursor *rhizome_direct_get_fill_response
|
||||
&c->buffer[c->buffer_offset_bytes+c->buffer_used+1],
|
||||
8);
|
||||
c->buffer_used+=1+8;
|
||||
DEBUGF("They have newer version of bundle %016llx* (%lld versus %lld)",
|
||||
rhizome_bar_bidprefix(&usbuffer[10+us*RHIZOME_BAR_BYTES]),
|
||||
rhizome_bar_version(&usbuffer[10+us*RHIZOME_BAR_BYTES]),
|
||||
rhizome_bar_version(&buffer[10+them*RHIZOME_BAR_BYTES]));
|
||||
} else if (them_version<us_version) {
|
||||
/* We have the newer version of the bundle */
|
||||
c->buffer[c->buffer_offset_bytes+c->buffer_used]=0x02; /* I have [newer] */
|
||||
@ -347,8 +355,13 @@ rhizome_direct_bundle_cursor *rhizome_direct_get_fill_response
|
||||
&c->buffer[c->buffer_offset_bytes+c->buffer_used+1],
|
||||
8);
|
||||
c->buffer_used+=1+8;
|
||||
DEBUGF("We have newer version of bundle %016llx* (%lld versus %lld)",
|
||||
rhizome_bar_bidprefix(&usbuffer[10+us*RHIZOME_BAR_BYTES]),
|
||||
rhizome_bar_version(&usbuffer[10+us*RHIZOME_BAR_BYTES]),
|
||||
rhizome_bar_version(&buffer[10+them*RHIZOME_BAR_BYTES]));
|
||||
} else {
|
||||
DEBUGF("We both have the same version of this bundle");
|
||||
DEBUGF("We both have the same version of %016llx*",
|
||||
rhizome_bar_bidprefix(&buffer[10+them*RHIZOME_BAR_BYTES]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#include "rhizome.h"
|
||||
#include "str.h"
|
||||
#include <assert.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
int rhizome_direct_clear_temporary_files(rhizome_http_request *r)
|
||||
{
|
||||
@ -202,7 +203,7 @@ int rhizome_direct_process_mime_line(rhizome_http_request *r,char *buffer,int co
|
||||
is significant, so lets just check once, and remember the result.
|
||||
Similarly check a few other conditions. */
|
||||
int boundaryLine=0;
|
||||
if (!bcmp(buffer,r->boundary_string,r->boundary_string_length))
|
||||
if (!memcmp(buffer,r->boundary_string,r->boundary_string_length))
|
||||
boundaryLine=1;
|
||||
|
||||
int endOfForm=0;
|
||||
|
@ -76,10 +76,20 @@ long long rhizome_bar_version(unsigned char *bar)
|
||||
long long version=0;
|
||||
int i;
|
||||
// for(i=0;i<7;i++) bar[8+6-i]=(m->version>>(8*i))&0xff;
|
||||
for(i=0;i<7;i++) version|=bar[8+6-i]<<(8*i);
|
||||
for(i=0;i<7;i++) version|=bar[8+6-i]<<(8LL*i);
|
||||
return version;
|
||||
}
|
||||
|
||||
unsigned long long rhizome_bar_bidprefix(unsigned char *bar)
|
||||
{
|
||||
long long bidprefix=0;
|
||||
int i;
|
||||
for(i=0;i<8;i++) bidprefix|=bar[8-i]<<(8*i);
|
||||
dump("bar",bar,32);
|
||||
return bidprefix;
|
||||
}
|
||||
|
||||
|
||||
int bundles_available=-1;
|
||||
int bundle_offset[2]={0,0};
|
||||
int overlay_rhizome_add_advertisements(int interface_number,overlay_buffer *e)
|
||||
|
Loading…
Reference in New Issue
Block a user