mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-18 20:57:56 +00:00
fixed bug in rhizome direct http push code.
Rhizome direct push via HTTP now works. #9
This commit is contained in:
parent
bbe6d12693
commit
c356ead09c
@ -308,6 +308,11 @@ typedef struct rhizome_http_request {
|
||||
struct sched_ent alarm;
|
||||
long long initiate_time; /* time connection was initiated */
|
||||
|
||||
/* identify request from others being run.
|
||||
Monotonic counter feeds it. Only used for debugging when we write
|
||||
post-<uuid>.log files for multi-part form requests. */
|
||||
unsigned int uuid;
|
||||
|
||||
/* The HTTP request as currently received */
|
||||
int request_length;
|
||||
#define RHIZOME_HTTP_REQUEST_MAXLEN 1024
|
||||
|
@ -318,7 +318,9 @@ int rhizome_direct_process_post_multipart_bytes(rhizome_http_request *r,const ch
|
||||
DEBUG(alloca_toprint(-1, bytes, count));
|
||||
{
|
||||
DEBUGF("Saw %d multi-part form bytes",count);
|
||||
FILE *f=fopen("post.log","a");
|
||||
char logname[128];
|
||||
snprintf(logname,128,"post-%08x.log",r->uuid);
|
||||
FILE *f=fopen(logname,"a");
|
||||
if (f) fwrite(bytes,count,1,f);
|
||||
if (f) fclose(f);
|
||||
}
|
||||
@ -813,7 +815,7 @@ void rhizome_direct_http_dispatch(rhizome_direct_sync_request *r)
|
||||
int r=write(sock,&buffer[sent],len-sent);
|
||||
if (r>0) sent+=r;
|
||||
if (r<0) goto closeit;
|
||||
}
|
||||
}
|
||||
|
||||
/* send file contents now */
|
||||
long long rowid = -1;
|
||||
|
@ -246,6 +246,8 @@ void rhizome_client_poll(struct sched_ent *alarm)
|
||||
return;
|
||||
}
|
||||
|
||||
static unsigned int rhizome_http_request_uuid_counter=0;
|
||||
|
||||
void rhizome_server_poll(struct sched_ent *alarm)
|
||||
{
|
||||
struct sockaddr addr;
|
||||
@ -271,6 +273,7 @@ void rhizome_server_poll(struct sched_ent *alarm)
|
||||
WHYF_perror("calloc(%u, 1)", sizeof(rhizome_http_request));
|
||||
WHY("Cannot respond to request, out of memory");
|
||||
} else {
|
||||
request->uuid=rhizome_http_request_uuid_counter++;
|
||||
/* We are now trying to read the HTTP request */
|
||||
request->request_type=RHIZOME_HTTP_REQUEST_RECEIVING;
|
||||
request->alarm.function = rhizome_client_poll;
|
||||
|
Loading…
Reference in New Issue
Block a user