Skip to content

Commit 0ff1094

Browse files
committed
Try to cleanup shutdown websocket on server shutdown
#119
1 parent 8ecf3a3 commit 0ff1094

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/worker.zig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@ pub fn Blocking(comptime S: type, comptime WSH: type) type {
171171
thread_pool.stop();
172172
}
173173

174-
pub fn stop(_: *const Self) void {
175-
// noop, exists for compatibility with NonBlocking worker
176-
// we'll stop when the http.Server shutdown the listening socket.
174+
pub fn stop(self: *const Self) void {
175+
// The HTTP server will stop when the http.Server shutdown the listening socket.
176+
self.websocket.shutdown();
177177
}
178178

179179
// Called in a worker thread. `thread_buf` is a thread-specific buffer that
@@ -530,6 +530,7 @@ pub fn NonBlocking(comptime S: type, comptime WSH: type) type {
530530
log.err("Failed to add monitor to listening socket: {}", .{err});
531531
return;
532532
};
533+
defer self.websocket.shutdown();
533534

534535
var now = timestamp(0);
535536
var last_timeout = now;

0 commit comments

Comments
 (0)