summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladislav Grishenko <themiron@mail.ru>2026-07-26 15:01:03 +0500
committerVladislav Grishenko <themiron@mail.ru>2026-07-26 16:02:18 +0500
commit9a0a973a895c34c541e12f17cd437d33cc47335b (patch)
treef54196dd1bc1a7de3e842cad7d64d17fed6636c8
parentdb8fc548ee0692905cf0955daf0622ca390efa4f (diff)
downloadaccel-ppp-sstp-flush-on-disconnect.tar.gz
accel-ppp-sstp-flush-on-disconnect.zip
sstp: flush queued output on disconnectsstp-flush-on-disconnect
Drain out_queue to the stream in sstp_disconnect before closing, so a queued response is sent before the connection is torn down. Best-effort, non-blocking, via a sstp_flush() helper that mirrors sstp_write. Fixes: 635ab1b7
-rw-r--r--accel-pppd/ctrl/sstp/sstp.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/accel-pppd/ctrl/sstp/sstp.c b/accel-pppd/ctrl/sstp/sstp.c
index 7c784afe..19665dcd 100644
--- a/accel-pppd/ctrl/sstp/sstp.c
+++ b/accel-pppd/ctrl/sstp/sstp.c
@@ -2123,6 +2123,30 @@ static int sstp_send(struct sstp_conn_t *conn, struct buffer_t *buf)
return 0;
}
+static void sstp_flush(struct sstp_conn_t *conn)
+{
+ 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 (conf_verbose && errno != EPIPE)
+ log_ppp_info2("sstp: flush: %s\n", strerror(errno));
+ break;
+ } else if (n == 0)
+ break;
+ buf_pull(buf, n);
+ }
+ list_del(&buf->entry);
+ free_buf(buf);
+ }
+}
+
static void sstp_msg_echo(struct triton_timer_t *t)
{
struct sstp_conn_t *conn = container_of(t, typeof(*conn), hello_timer);
@@ -2224,6 +2248,7 @@ static void sstp_disconnect(struct sstp_conn_t *conn)
triton_timer_del(&conn->hello_timer);
if (conn->hnd.tpd) {
+ sstp_flush(conn);
triton_md_unregister_handler(&conn->hnd, 0);
conn->stream->close(conn->stream);
}