Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion include/udx.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ extern "C" {
#endif

#include <math.h>
#include <stdalign.h>
#include <stdbool.h>
#include <stdint.h>
#include <uv.h>
Expand Down Expand Up @@ -428,7 +429,8 @@ struct udx_packet_s {
bool is_app_limited; // was throughput app-limited (vs network limited) at the time the packet was transmitted?

// just alloc it in place here, easier to manage
uint8_t header[UDX_HEADER_SIZE];
alignas(4) uint8_t header[UDX_HEADER_SIZE];

uint16_t nwbufs; // nwbufs = nbufs - 1
uint16_t nwbufs_capacity; // initially ARRAY_SIZEOF(wbuf_sml), used for realloc

Expand Down
10 changes: 7 additions & 3 deletions src/udx.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,8 @@ send_probe (udx_stream_t *stream) {

// todo: send a data packet with seq=remote_acked-1 instead

uint8_t header[20];
alignas(4) uint8_t header[20];

udx_write_header(header, stream, UDX_HEADER_HEARTBEAT);

// fast path
Expand Down Expand Up @@ -2655,7 +2656,9 @@ stream_on_destroy_send (udx_stream_t *stream) {

static void
_stream_on_destroy_send (uv_udp_send_t *req, int status) {
debug_printf("udx destroy send: err=%s\n", uv_strerror(status));
if (status < 0) {
debug_printf("udx destroy send: err=%s\n", uv_strerror(status));
}
udx_stream_t *stream = req->data;
stream_on_destroy_send(stream);
free(req);
Expand All @@ -2682,7 +2685,8 @@ udx_stream_destroy (udx_stream_t *stream) {

// write destroy packet

uint8_t header[20];
alignas(4) uint8_t header[20];

udx_write_header(header, stream, UDX_HEADER_DESTROY);
stream->seq++;

Expand Down
2 changes: 2 additions & 0 deletions test/stream-bbr-state.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,13 @@ send_periodic (uv_timer_t *timer) {
static void
send_ack_slow (udx_stream_write_t *r, int status, int unordered) {
// printf("send_ack (slow)\n");
free(r);
}

static void
send_ack_fast (udx_stream_write_t *r, int status, int unordered) {
// printf("send_ack (fast) elapsed=%ld\n", uv_now(&loop) - start_ms);
free(r);
}

static void
Expand Down
5 changes: 4 additions & 1 deletion test/stream-change-remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ main () {
e = udx_stream_connect(&dstream, &dsock, 3, (struct sockaddr *) &caddr);
assert(e == 0);

uv_buf_t buf = uv_buf_init(malloc(NBYTES_TO_SEND), NBYTES_TO_SEND);
char *data = malloc(NBYTES_TO_SEND);

uv_buf_t buf = uv_buf_init(data, NBYTES_TO_SEND);

write_hash = hash(write_hash, (uint8_t *) buf.base, buf.len);

Expand All @@ -177,6 +179,7 @@ main () {
printf("read_hash=%lu write_hash=%lu\n", read_hash, write_hash);

free(req);
free(data);

return 0;
}
3 changes: 3 additions & 0 deletions test/stream-destroy-before-connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ main () {
e = udx_stream_destroy(&stream);
assert(e == 0);

e = uv_run(&loop, UV_RUN_DEFAULT);
assert(e == 0);

uv_loop_close(&loop);

return 0;
Expand Down
5 changes: 4 additions & 1 deletion test/stream-relay-force-slow-path.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ main () {
e = udx_stream_connect(&dstream, &dsock, 3, (struct sockaddr *) &caddr);
assert(e == 0);

uv_buf_t buf = uv_buf_init(calloc(NBYTES_TO_SEND, 1), NBYTES_TO_SEND);
char *data = calloc(NBYTES_TO_SEND, 1);

uv_buf_t buf = uv_buf_init(data, NBYTES_TO_SEND);

memcpy(buf.base, "hello", 5);

Expand All @@ -148,6 +150,7 @@ main () {
assert(nbytes_read == NBYTES_TO_SEND && read_hash == write_hash);

free(req);
free(data);

return 0;
}
5 changes: 4 additions & 1 deletion test/stream-relay.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ main () {
e = udx_stream_connect(&dstream, &dsock, 3, (struct sockaddr *) &caddr);
assert(e == 0);

uv_buf_t buf = uv_buf_init(calloc(NBYTES_TO_SEND, 1), NBYTES_TO_SEND);
char *data = calloc(NBYTES_TO_SEND, 1);

uv_buf_t buf = uv_buf_init(data, NBYTES_TO_SEND);

memcpy(buf.base, "hello", 5);

Expand All @@ -146,6 +148,7 @@ main () {
assert(nbytes_read == NBYTES_TO_SEND && read_hash == write_hash);

free(req);
free(data);

return 0;
}
3 changes: 3 additions & 0 deletions test/stream-write-read-multiple.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,8 @@ main () {

assert(ack_called == 2 && total_read == buf.len * 2);

free(areq);
free(breq);

return 0;
}
8 changes: 4 additions & 4 deletions test/stream-write-read-perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,24 @@ on_read (udx_stream_t *handle, ssize_t read_len, const uv_buf_t *buf) {
}

static void
on_b_sock_close () {
on_b_sock_close (udx_socket_t *socket) {
printf("sending socket closing\n");
}

static void
on_b_stream_close () {
on_b_stream_close (udx_stream_t *stream, int status) {
printf("sending stream closing\n");
int e = udx_socket_close(&bsock);
assert(e == 0 && "udx_socket_close (sender, 'b')");
}

static void
on_a_sock_close () {
on_a_sock_close (udx_socket_t *socket) {
printf("receiving socket closing\n");
}

static void
on_a_stream_close () {
on_a_stream_close (udx_stream_t *stream, int status) {
printf("receiving stream closing\n");
int e = udx_socket_close(&asock);
assert(e == 0 && "udx_socket_close (receiver, 'a')");
Expand Down