mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-02-20 09:26:37 +00:00
push profiling down deeper into rhizome_fetch_poll()'s children.
This commit is contained in:
parent
60015a1aee
commit
e551017896
@ -546,6 +546,7 @@ struct file_packet{
|
||||
|
||||
static void interface_read_file(struct overlay_interface *interface)
|
||||
{
|
||||
IN();
|
||||
/* Grab packets, unpackage and dispatch frames to consumers */
|
||||
struct file_packet packet;
|
||||
time_ms_t now = gettime_ms();
|
||||
@ -560,6 +561,7 @@ static void interface_read_file(struct overlay_interface *interface)
|
||||
if (interface->recv_offset<length){
|
||||
if (lseek(interface->alarm.poll.fd,interface->recv_offset,SEEK_SET) == -1){
|
||||
WHY_perror("lseek");
|
||||
OUT();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -614,10 +616,12 @@ static void interface_read_file(struct overlay_interface *interface)
|
||||
}
|
||||
|
||||
static void interface_read_stream(struct overlay_interface *interface){
|
||||
IN();
|
||||
unsigned char buffer[OVERLAY_INTERFACE_RX_BUFFER_SIZE];
|
||||
ssize_t nread = read(interface->alarm.poll.fd, buffer, OVERLAY_INTERFACE_RX_BUFFER_SIZE);
|
||||
if (nread == -1){
|
||||
WHY_perror("read");
|
||||
OUT();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -643,6 +647,7 @@ static void interface_read_stream(struct overlay_interface *interface){
|
||||
state->dst_offset=0;
|
||||
}
|
||||
}
|
||||
OUT();
|
||||
}
|
||||
|
||||
static void write_stream_buffer(overlay_interface *interface){
|
||||
|
@ -1198,9 +1198,10 @@ static int rhizome_fetch_switch_to_mdp(struct rhizome_fetch_slot *slot)
|
||||
or with a temporary generated SID, so that we don't end up with two
|
||||
instances with the same SID.
|
||||
*/
|
||||
IN()
|
||||
if (!my_subscriber) {
|
||||
DEBUGF("I don't have an identity, so we cannot fall back to MDP");
|
||||
return rhizome_fetch_close(slot);
|
||||
RETURN(rhizome_fetch_close(slot));
|
||||
}
|
||||
|
||||
if (config.debug.rhizome_rx)
|
||||
@ -1250,17 +1251,19 @@ static int rhizome_fetch_switch_to_mdp(struct rhizome_fetch_slot *slot)
|
||||
rhizome_fetch_mdp_requestmanifest(slot);
|
||||
}
|
||||
|
||||
return 0;
|
||||
RETURN(0);
|
||||
}
|
||||
|
||||
void rhizome_fetch_write(struct rhizome_fetch_slot *slot)
|
||||
{
|
||||
IN();
|
||||
if (config.debug.rhizome_rx)
|
||||
DEBUGF("write_nonblock(%d, %s)", slot->alarm.poll.fd, alloca_toprint(-1, &slot->request[slot->request_ofs], slot->request_len-slot->request_ofs));
|
||||
int bytes = write_nonblock(slot->alarm.poll.fd, &slot->request[slot->request_ofs], slot->request_len-slot->request_ofs);
|
||||
if (bytes == -1) {
|
||||
WHY("Got error while sending HTTP request.");
|
||||
rhizome_fetch_switch_to_mdp(slot);
|
||||
OUT();
|
||||
return;
|
||||
} else {
|
||||
// reset timeout
|
||||
@ -1279,6 +1282,8 @@ void rhizome_fetch_write(struct rhizome_fetch_slot *slot)
|
||||
}else if(slot->state==RHIZOME_FETCH_CONNECTING)
|
||||
slot->state = RHIZOME_FETCH_SENDINGHTTPREQUEST;
|
||||
}
|
||||
OUT();
|
||||
return;
|
||||
}
|
||||
|
||||
int rhizome_fetch_flush_blob_buffer(struct rhizome_fetch_slot *slot)
|
||||
@ -1644,6 +1649,7 @@ void rhizome_fetch_poll(struct sched_ent *alarm)
|
||||
*/
|
||||
int unpack_http_response(char *response, struct http_response_parts *parts)
|
||||
{
|
||||
IN();
|
||||
parts->code = -1;
|
||||
parts->reason = NULL;
|
||||
parts->content_length = -1;
|
||||
@ -1652,12 +1658,12 @@ int unpack_http_response(char *response, struct http_response_parts *parts)
|
||||
if (!str_startswith(response, "HTTP/1.0 ", (const char **)&p)) {
|
||||
if (config.debug.rhizome_rx)
|
||||
DEBUGF("Malformed HTTP reply: missing HTTP/1.0 preamble");
|
||||
return -1;
|
||||
RETURN(-1);
|
||||
}
|
||||
if (!(isdigit(p[0]) && isdigit(p[1]) && isdigit(p[2]) && p[3] == ' ')) {
|
||||
if (config.debug.rhizome_rx)
|
||||
DEBUGF("Malformed HTTP reply: missing three-digit status code");
|
||||
return -1;
|
||||
RETURN(-1);
|
||||
}
|
||||
parts->code = (p[0]-'0') * 100 + (p[1]-'0') * 10 + p[2]-'0';
|
||||
p += 4;
|
||||
@ -1679,7 +1685,7 @@ int unpack_http_response(char *response, struct http_response_parts *parts)
|
||||
if (p == nump || (*p != '\r' && *p != '\n')) {
|
||||
if (config.debug.rhizome_rx)
|
||||
DEBUGF("Invalid HTTP reply: malformed Content-Length header");
|
||||
return -1;
|
||||
RETURN(-1);
|
||||
}
|
||||
}
|
||||
while (*p++ != '\n')
|
||||
@ -1689,5 +1695,5 @@ int unpack_http_response(char *response, struct http_response_parts *parts)
|
||||
++p;
|
||||
++p; // skip '\n' at end of blank line
|
||||
parts->content_start = p;
|
||||
return 0;
|
||||
RETURN(0);
|
||||
}
|
||||
|
@ -474,6 +474,7 @@ int rhizome_server_sql_query_fill_buffer(rhizome_http_request *r, char *table, c
|
||||
|
||||
int http_header_complete(const char *buf, size_t len, size_t read_since_last_call)
|
||||
{
|
||||
IN();
|
||||
const char *bufend = buf + len;
|
||||
size_t tail = read_since_last_call + 4;
|
||||
if (tail < len)
|
||||
@ -487,7 +488,7 @@ int http_header_complete(const char *buf, size_t len, size_t read_since_last_cal
|
||||
default: count = 0; break;
|
||||
}
|
||||
}
|
||||
return count == 2;
|
||||
RETURN(count == 2);
|
||||
}
|
||||
|
||||
int rhizome_direct_parse_http_request(rhizome_http_request *r);
|
||||
|
Loading…
x
Reference in New Issue
Block a user