From 2dde21c4070e072c530165f430c285ec74ad9f80 Mon Sep 17 00:00:00 2001 From: Radkesvat <134321679+radkesvat@users.noreply.github.com> Date: Tue, 2 Apr 2024 19:03:54 +0300 Subject: [PATCH] changes on queue --- tunnels/adapters/connector/tcp.c | 3 ++- tunnels/adapters/tcp_connector/tcp_connector.c | 3 ++- tunnels/adapters/tcp_listener/tcp_listener.c | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/tunnels/adapters/connector/tcp.c b/tunnels/adapters/connector/tcp.c index 15cc40b2..d5c29ec5 100644 --- a/tunnels/adapters/connector/tcp.c +++ b/tunnels/adapters/connector/tcp.c @@ -79,7 +79,8 @@ static void on_write_complete(hio_t *io, const void *buf, int writebytes) if (contextQueueLen(queue) > 0) { contextQueuePush(cstate->queue, cpy_ctx); - resume_write_queue(cstate); + if (resume_write_queue(cstate)) + hio_setcb_write(io, NULL); } else { diff --git a/tunnels/adapters/tcp_connector/tcp_connector.c b/tunnels/adapters/tcp_connector/tcp_connector.c index 74527ad4..3e7f1f57 100644 --- a/tunnels/adapters/tcp_connector/tcp_connector.c +++ b/tunnels/adapters/tcp_connector/tcp_connector.c @@ -80,7 +80,8 @@ static void on_write_complete(hio_t *io, const void *buf, int writebytes) if (contextQueueLen(queue) > 0) { contextQueuePush(cstate->queue, cpy_ctx); - resume_write_queue(cstate); + if (resume_write_queue(cstate)) + hio_setcb_write(io, NULL); } else { diff --git a/tunnels/adapters/tcp_listener/tcp_listener.c b/tunnels/adapters/tcp_listener/tcp_listener.c index 54b55e61..7309fcc2 100644 --- a/tunnels/adapters/tcp_listener/tcp_listener.c +++ b/tunnels/adapters/tcp_listener/tcp_listener.c @@ -119,7 +119,8 @@ static void on_write_complete(hio_t *io, const void *buf, int writebytes) if (contextQueueLen(queue) > 0) { contextQueuePush(cstate->queue, cpy_ctx); - resume_write_queue(cstate); + if (resume_write_queue(cstate)) + hio_setcb_write(io, NULL); } else { @@ -191,7 +192,7 @@ static inline void downStream(tunnel_t *self, context_t *c) int nwrite = hio_write(cstate->io, rawBuf(c->payload), bytes); if (nwrite >= 0 && nwrite < bytes) { - cstate->write_paused = true; + cstate->write_paused = true; if (c->src_io) hio_read_stop(c->src_io); hio_setcb_write(cstate->io, on_write_complete);