diff options
author | 2023-01-12 18:15:50 -0800 | |
---|---|---|
committer | 2023-01-12 19:38:27 -0800 | |
commit | 2eac47a1231de87a9ed2c22981b3dab5bddc9ba8 (patch) | |
tree | 4581c15129c12145fdf2e73ff9ecdcbe3b53a772 | |
parent | 32f8cb31be6fb5b0b9aea1c6d4e95d118e8ef816 (diff) | |
download | bun-2eac47a1231de87a9ed2c22981b3dab5bddc9ba8.tar.gz bun-2eac47a1231de87a9ed2c22981b3dab5bddc9ba8.tar.zst bun-2eac47a1231de87a9ed2c22981b3dab5bddc9ba8.zip |
Upgrade uSockets
-rw-r--r-- | src/deps/_libusockets.h | 2 | ||||
-rw-r--r-- | src/deps/libuwsockets.cpp | 14 | ||||
m--------- | src/deps/uws | 0 | ||||
-rw-r--r-- | src/deps/uws.zig | 18 |
4 files changed, 32 insertions, 2 deletions
diff --git a/src/deps/_libusockets.h b/src/deps/_libusockets.h index 2c09395e9..6eee9e747 100644 --- a/src/deps/_libusockets.h +++ b/src/deps/_libusockets.h @@ -330,6 +330,8 @@ bool uws_res_try_end(int ssl, uws_res_t *res, const char *bytes, size_t len, void uws_res_prepare_for_sendfile(int ssl, uws_res_t *res); void uws_res_override_write_offset(int ssl, uws_res_t *res, uintmax_t offset); +void uws_app_close(int ssl, uws_app_t *app); + #ifdef __cplusplus } #endif diff --git a/src/deps/libuwsockets.cpp b/src/deps/libuwsockets.cpp index d059efa47..0bc61d614 100644 --- a/src/deps/libuwsockets.cpp +++ b/src/deps/libuwsockets.cpp @@ -297,6 +297,20 @@ extern "C" } } + void uws_app_close(int ssl, uws_app_t *app) + { + if (ssl) + { + uWS::SSLApp *uwsApp = (uWS::SSLApp *)app; + uwsApp->close(); + } + else + { + uWS::App *uwsApp = (uWS::App *)app; + uwsApp->close(); + } + } + void uws_app_listen(int ssl, uws_app_t *app, int port, uws_listen_handler handler, void *user_data) { diff --git a/src/deps/uws b/src/deps/uws -Subproject 70b1b9fc1341e8b791b42c5447f90505c2abe15 +Subproject 906e2f8f5656d844e6b8a048a73ce571a1d8b85 diff --git a/src/deps/uws.zig b/src/deps/uws.zig index bfcd00e7a..485af99e8 100644 --- a/src/deps/uws.zig +++ b/src/deps/uws.zig @@ -389,6 +389,10 @@ pub const SocketContext = opaque { us_socket_context_free(@as(i32, @boolToInt(ssl)), this); } + pub fn close(this: *SocketContext, ssl: bool) void { + us_socket_context_close(@as(i32, @boolToInt(ssl)), this); + } + pub fn ext(this: *SocketContext, ssl: bool, comptime ContextType: type) ?*ContextType { const alignment = if (ContextType == *anyopaque) @sizeOf(usize) @@ -967,12 +971,22 @@ pub const ListenSocket = opaque { } }; extern fn us_listen_socket_close(ssl: i32, ls: *ListenSocket) void; +extern fn uws_app_close(ssl: i32, app: *uws_app_s) void; +extern fn us_socket_context_close(ssl: i32, ctx: *anyopaque) void; pub fn NewApp(comptime ssl: bool) type { return opaque { const ssl_flag = @as(i32, @boolToInt(ssl)); const ThisApp = @This(); + pub fn close(this: *ThisApp) void { + if (comptime is_bindgen) { + unreachable; + } + + return uws_app_close(ssl_flag, @ptrCast(*uws_app_s, this)); + } + pub fn create(opts: us_socket_context_options_t) *ThisApp { if (comptime is_bindgen) { unreachable; @@ -1246,8 +1260,8 @@ pub fn NewApp(comptime ssl: bool) type { uws_res_end(ssl_flag, res.downcast(), data.ptr, data.len, close_connection); } - pub fn tryEnd(res: *Response, data: []const u8, total: usize, close: bool) bool { - return uws_res_try_end(ssl_flag, res.downcast(), data.ptr, data.len, total, close); + pub fn tryEnd(res: *Response, data: []const u8, total: usize, close_: bool) bool { + return uws_res_try_end(ssl_flag, res.downcast(), data.ptr, data.len, total, close_); } pub fn state(res: *const Response) State { |