src/server/util/io.c

changeset 684
48da20bde908
parent 683
db37761a8494
--- a/src/server/util/io.c	Wed Feb 18 12:31:19 2026 +0100
+++ b/src/server/util/io.c	Wed Feb 18 13:41:10 2026 +0100
@@ -77,6 +77,7 @@
     NULL,
     (io_setmode_f)net_sys_setmode,
     (io_poll_f)net_sys_poll,
+    (io_free_f)sysstream_free,
     0,
     0
 };
@@ -90,6 +91,7 @@
     (io_finish_f)net_http_finish,
     (io_setmode_f)net_http_setmode,
     (io_poll_f)net_http_poll,
+    (io_free_f)httpstream_free,
     0,
     IO_STREAM_TYPE_HTTP
 };
@@ -103,6 +105,7 @@
     (io_finish_f)net_ssl_finish,
     (io_setmode_f)net_ssl_setmode,
     (io_poll_f)net_ssl_poll,
+    (io_free_f)sslstream_free,
     0,
     IO_STREAM_TYPE_SSL
 };
@@ -120,10 +123,16 @@
 IOStream* Sysstream_new(pool_handle_t *pool, SYS_SOCKET fd) {
     Sysstream *st = pool_malloc(pool, sizeof(Sysstream));
     st->st = native_io_funcs;
+    st->pool = pool;
     st->fd = fd;
     return (IOStream*)st;
 }
 
+void sysstream_free(IOStream *st) {
+    Sysstream *sys = (Sysstream*)st;
+    pool_free(sys->pool, st);
+}
+
 #ifdef XP_UNIX
 ssize_t net_sys_write(Sysstream *st, const void *buf, size_t nbytes) {
     ssize_t r = write(st->fd, buf, nbytes);
@@ -288,6 +297,12 @@
     return (IOStream*)st;
 }
 
+void httpstream_free(IOStream *st) {
+    HttpStream *http = (HttpStream*)st;
+    http->fd->free(http->fd);
+    pool_free(http->pool, st);
+}
+
 int httpstream_enable_chunked_read(IOStream *st, char *buffer, size_t bufsize, int *cursize, int *pos) {
     if(st->read != (io_read_f)net_http_read) {
         log_ereport(LOG_FAILURE, "%s", "httpstream_enable_chunked_read: IOStream is not an HttpStream");
@@ -812,6 +827,12 @@
     return (IOStream*)st;
 }
 
+void sslstream_free(IOStream *st) {
+    SSLStream *ssl = (SSLStream*)st;
+    SSL_free(ssl->ssl);
+    pool_free(ssl->pool, st);
+}
+
 ssize_t net_ssl_write(SSLStream *st, const void *buf, size_t nbytes) {
     int ret = SSL_write(st->ssl, buf, nbytes);
     if(ret <= 0) {

mercurial