Skip to content

Commit

Permalink
Backend timeout test
Browse files Browse the repository at this point in the history
  • Loading branch information
oystedal committed Oct 10, 2016
1 parent 3717ab1 commit 80cef52
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
20 changes: 14 additions & 6 deletions examples/client_http_run_once.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ static uint32_t config_rcv_buffer_size = 65536;
static uint32_t config_max_flows = 50;
static char request[512];
static const char *request_tail = "HTTP/1.0\r\nUser-agent: libneat\r\nConnection: close\r\n\r\n";
static char *config_property = "{\
\"transport\": [\
{\
\"value\": \"SCTP\",\
\"precedence\": 1\
},\
{\
\"value\": \"TCP\",\
\"precedence\": 1\
}\
]\
}";\

static neat_error_code
on_error(struct neat_flow_operations *opCB)
Expand Down Expand Up @@ -86,7 +98,6 @@ main(int argc, char *argv[])
struct neat_ctx *ctx = NULL;
struct neat_flow *flows[config_max_flows];
struct neat_flow_operations ops[config_max_flows];
uint64_t prop = 0;
int result = 0;
int arg = 0;
uint32_t num_flows = 1;
Expand Down Expand Up @@ -140,10 +151,7 @@ main(int argc, char *argv[])
goto cleanup;
}

neat_get_property(ctx, flows[i], &prop);
prop |= NEAT_PROPERTY_OPTIONAL_SECURITY;
prop |= NEAT_PROPERTY_RETRANSMISSIONS_REQUIRED;
neat_set_property(ctx, flows[i], prop);
neat_set_property(ctx, flows[i], config_property);

ops[i].on_connected = on_connected;
ops[i].on_error = on_error;
Expand Down Expand Up @@ -177,7 +185,7 @@ main(int argc, char *argv[])
.revents = 0,
}
};
int rc = poll(fds, 1, 1000);
int rc = poll(fds, 1, neat_get_backend_timeout(ctx));

if (rc > 0) {
/* there's stuff to do */
Expand Down
1 change: 1 addition & 0 deletions neat.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ NEAT_EXTERN struct neat_ctx *neat_init_ctx();
NEAT_EXTERN void neat_start_event_loop(struct neat_ctx *nc, neat_run_mode run_mode);
NEAT_EXTERN void neat_stop_event_loop(struct neat_ctx *nc);
NEAT_EXTERN int neat_get_backend_fd(struct neat_ctx *nc);
NEAT_EXTERN int neat_get_backend_timeout(struct neat_ctx *nc);
NEAT_EXTERN void neat_free_ctx(struct neat_ctx *nc);

typedef uint64_t neat_error_code;
Expand Down
9 changes: 8 additions & 1 deletion neat_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,13 @@ int neat_get_backend_fd(struct neat_ctx *nc)
return uv_backend_fd(nc->loop);
}

int neat_get_backend_timeout(struct neat_ctx *nc)
{
neat_log(NEAT_LOG_DEBUG, "%s", __func__);

return uv_backend_timeout(nc->loop);
}

static void neat_walk_cb(uv_handle_t *handle, void *arg)
{
neat_log(NEAT_LOG_DEBUG, "%s", __func__);
Expand Down Expand Up @@ -3345,7 +3352,7 @@ neat_read_from_lower_layer(struct neat_ctx *ctx, struct neat_flow *flow,

/*Update flow statistics */
flow->flow_stats.bytes_received += (int)rv;


end:
// Fill in optional return values if they are requested
Expand Down

0 comments on commit 80cef52

Please sign in to comment.