From 639c33a879af1fa2b57ae33ffe5d262cd5efd838 Mon Sep 17 00:00:00 2001 From: James Thomas Date: Tue, 26 Dec 2023 03:23:42 -0500 Subject: [PATCH] PR comments + cleanup --- src/internal.h | 7 ++----- src/io_posix.c | 11 +++++------ src/io_win.c | 4 ++-- src/udx.c | 6 +++--- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/internal.h b/src/internal.h index e5f20a72..0543adba 100644 --- a/src/internal.h +++ b/src/internal.h @@ -37,13 +37,10 @@ void udx__close_handles (udx_socket_t *socket); udx_packet_t * -udx__get_packet (udx_socket_t *socket); +udx__shift_packet (udx_socket_t *socket); void udx__confirm_packet (udx_packet_t *pkt); void -udx__cancel_packet (udx_packet_t *pkt, udx_socket_t *socket); - -void -udx__initialize_stream_queue (udx_socket_t *socket); +udx__unshift_packet (udx_packet_t *pkt, udx_socket_t *socket); #endif // UDX_INTERNAL_H diff --git a/src/io_posix.c b/src/io_posix.c index e8534748..73f2b1b4 100644 --- a/src/io_posix.c +++ b/src/io_posix.c @@ -116,7 +116,7 @@ udx__on_writable (udx_socket_t *socket) { bool adjust_ttl; while (npkts < UDX_SENDMMSG_BATCH_SIZE) { - udx_packet_t *pkt = udx__get_packet(socket); + udx_packet_t *pkt = udx__shift_packet(socket); if (pkt == NULL) { finished = true; @@ -129,7 +129,7 @@ udx__on_writable (udx_socket_t *socket) { } if (pkt->ttl != ttl) { - udx__cancel_packet(pkt, socket); + udx__unshift_packet(pkt, socket); break; } @@ -174,8 +174,7 @@ udx__on_writable (udx_socket_t *socket) { // cancel packets in reverse ! for (int i = npkts; i > npkts - unsent; i--) { - __builtin_trap(); - udx__cancel_packet(batch[i - 1], socket); + udx__unshift_packet(batch[i - 1], socket); } for (int i = 0; i < nsent; i++) { @@ -191,7 +190,7 @@ udx__on_writable (udx_socket_t *socket) { } #else /* no sendmmsg */ while (true) { - udx_packet_t *pkt = udx__get_packet(socket); + udx_packet_t *pkt = udx__shift_packet(socket); if (pkt == NULL) break; bool adjust_ttl = pkt->ttl > 0 && socket->ttl != pkt->ttl; @@ -208,7 +207,7 @@ udx__on_writable (udx_socket_t *socket) { if (adjust_ttl) uv_udp_set_ttl((uv_udp_t *) socket, socket->ttl); if (size == UV_EAGAIN) { - udx__cancel_packet(pkt, socket); + udx__unshift_packet(pkt, socket); break; } // todo: set in confirm packet with uv_now() diff --git a/src/io_win.c b/src/io_win.c index cdb0b1f7..92208038 100644 --- a/src/io_win.c +++ b/src/io_win.c @@ -86,7 +86,7 @@ udx__recvmsg (udx_socket_t *socket, uv_buf_t *buf, struct sockaddr *addr, int ad void udx__on_writable (udx_socket_t *socket) { while (true) { - udx_packet_t *pkt = udx__get_packet(socket); + udx_packet_t *pkt = udx__shift_packet(socket); if (pkt == NULL) break; bool adjust_ttl = pkt->ttl > 0 && socket->ttl != pkt->ttl; @@ -103,7 +103,7 @@ udx__on_writable (udx_socket_t *socket) { if (adjust_ttl) uv_udp_set_ttl((uv_udp_t *) socket, socket->ttl); if (size == UV_EAGAIN) { - udx__cancel_packet(pkt, socket); + udx__unshift_packet(pkt, socket); break; } // todo: set in confirm packet with uv_now() diff --git a/src/udx.c b/src/udx.c index 06a2cce4..65271930 100644 --- a/src/udx.c +++ b/src/udx.c @@ -674,7 +674,7 @@ get_stream (udx_socket_t *socket) { // undo packet _must_ be called in reverse order of get_packet udx_packet_t * -udx__get_packet (udx_socket_t *socket) { +udx__shift_packet (udx_socket_t *socket) { // debug_printf("in get packet\n"); while (socket->send_queue.len > 0) { @@ -953,7 +953,7 @@ udx__confirm_packet (udx_packet_t *pkt) { // or re-arm destroy, state flags void -udx__cancel_packet (udx_packet_t *pkt, udx_socket_t *socket) { +udx__unshift_packet (udx_packet_t *pkt, udx_socket_t *socket) { // don't need early return once all pkt types are covered if (pkt->type == UDX_PACKET_TYPE_SOCKET_SEND || pkt->type == UDX_PACKET_TYPE_STREAM_RELAY) { @@ -1942,7 +1942,7 @@ udx_stream_init (udx_t *udx, udx_stream_t *stream, uint32_t local_id, udx_stream udx__fifo_init(&(stream->unordered), 1); udx__fifo_init(&stream->write_queue, 1); - udx__fifo_init(&stream->retransmit_queue, 16); + udx__fifo_init(&stream->retransmit_queue, 1); stream->set_id = udx->streams_len++;