Skip to content

Commit

Permalink
PR comments + cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jthomas43 committed Dec 26, 2023
1 parent e46d66f commit 639c33a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
7 changes: 2 additions & 5 deletions src/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 5 additions & 6 deletions src/io_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down Expand Up @@ -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++) {
Expand All @@ -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;
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions src/io_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions src/udx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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++;

Expand Down

0 comments on commit 639c33a

Please sign in to comment.