diff options
author | Dmitry Pokrovsky <dpokrovsky@hotmail.com> | 2024-06-12 21:39:31 +0300 |
---|---|---|
committer | Dmitry Pokrovsky <dpokrovsky@hotmail.com> | 2024-06-12 21:43:30 +0300 |
commit | 635ab1b77b06a8891479a46a0e1ba88315ff3958 (patch) | |
tree | 6c586e7868456ce978f1d28fe2a96681b3cfe3e0 | |
parent | 27753b7429fc0f151019e90256ddea95c2638ecd (diff) | |
download | accel-ppp-635ab1b77b06a8891479a46a0e1ba88315ff3958.tar.gz accel-ppp-635ab1b77b06a8891479a46a0e1ba88315ff3958.zip |
1. Fixes the issue #124 "HTTP replay for non SSTP query"
2. Fixes log_debug2 in Triton lib
-rw-r--r-- | accel-pppd/ctrl/sstp/sstp.c | 77 | ||||
-rw-r--r-- | accel-pppd/triton/triton.c | 2 |
2 files changed, 40 insertions, 39 deletions
diff --git a/accel-pppd/ctrl/sstp/sstp.c b/accel-pppd/ctrl/sstp/sstp.c index 2e2c4d3b..e21a7769 100644 --- a/accel-pppd/ctrl/sstp/sstp.c +++ b/accel-pppd/ctrl/sstp/sstp.c @@ -1925,6 +1925,44 @@ static int sstp_handler(struct sstp_conn_t *conn, struct buffer_t *buf) return 0; } +static int sstp_write(struct triton_md_handler_t *h) +{ + struct sstp_conn_t *conn = container_of(h, typeof(*conn), hnd); + struct buffer_t *buf; + int n; + + while (!list_empty(&conn->out_queue)) { + buf = list_first_entry(&conn->out_queue, typeof(*buf), entry); + while (buf->len) { + n = conn->stream->write(conn->stream, buf->head, buf->len); + if (n < 0) { + if (errno == EINTR) + continue; + if (errno == EAGAIN) + goto defer; + if (conf_verbose && errno != EPIPE) + log_ppp_info2("sstp: write: %s\n", strerror(errno)); + goto drop; + } else if (n == 0) + goto defer; + buf_pull(buf, n); + } + list_del(&buf->entry); + free_buf(buf); + } + + triton_md_disable_handler(h, MD_MODE_WRITE); + return 0; + +defer: + triton_md_enable_handler(h, MD_MODE_WRITE); + return 0; + +drop: + triton_context_call(&conn->ctx, (triton_event_func)sstp_disconnect, conn); + return 1; +} + static int sstp_read(struct triton_md_handler_t *h) { struct sstp_conn_t *conn = container_of(h, typeof(*conn), hnd); @@ -1956,6 +1994,7 @@ static int sstp_read(struct triton_md_handler_t *h) return 0; drop: + n = sstp_write(h); sstp_disconnect(conn); return 1; } @@ -2049,44 +2088,6 @@ drop: return 1; } -static int sstp_write(struct triton_md_handler_t *h) -{ - struct sstp_conn_t *conn = container_of(h, typeof(*conn), hnd); - struct buffer_t *buf; - int n; - - while (!list_empty(&conn->out_queue)) { - buf = list_first_entry(&conn->out_queue, typeof(*buf), entry); - while (buf->len) { - n = conn->stream->write(conn->stream, buf->head, buf->len); - if (n < 0) { - if (errno == EINTR) - continue; - if (errno == EAGAIN) - goto defer; - if (conf_verbose && errno != EPIPE) - log_ppp_info2("sstp: write: %s\n", strerror(errno)); - goto drop; - } else if (n == 0) - goto defer; - buf_pull(buf, n); - } - list_del(&buf->entry); - free_buf(buf); - } - - triton_md_disable_handler(h, MD_MODE_WRITE); - return 0; - -defer: - triton_md_enable_handler(h, MD_MODE_WRITE); - return 0; - -drop: - triton_context_call(&conn->ctx, (triton_event_func)sstp_disconnect, conn); - return 1; -} - static inline void sstp_queue(struct sstp_conn_t *conn, struct buffer_t *buf) { list_add_tail(&buf->entry, &conn->out_queue); diff --git a/accel-pppd/triton/triton.c b/accel-pppd/triton/triton.c index 395a42df..841bd008 100644 --- a/accel-pppd/triton/triton.c +++ b/accel-pppd/triton/triton.c @@ -55,7 +55,7 @@ static __thread struct triton_context_t *this_ctx; static __thread jmp_buf jmp_env; static __thread void *thread_frame; -#define log_debug2(fmt, ...) +//#define log_debug2(fmt, ...) void triton_thread_wakeup(struct _triton_thread_t *thread) { |