diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index c553f10f..bec14f9a 100644 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -2150,9 +2150,17 @@ libwebsocket_get_reserved_bits(struct libwebsocket *wsi) return wsi->u.ws.rsv; } +/** + * libwebsocket_ensure_user_space(): return the user context for the connection if possible + * @wsi: websocket connection instance + */ + void * libwebsocket_ensure_user_space(struct libwebsocket *wsi) { + if (!wsi->protocol) + return NULL; + /* allocate the per-connection user memory (if any) */ if (wsi->protocol->per_session_data_size && !wsi->user_space) { diff --git a/libwebsockets-api-doc.html b/libwebsockets-api-doc.html index b041e743..7fd87027 100644 --- a/libwebsockets-api-doc.html +++ b/libwebsockets-api-doc.html @@ -382,6 +382,16 @@ Some apis can act on all live connections of a given protocol, this is how you can get a pointer to the active protocol if needed.
+

libwebsocket_ensure_user_space -

+void * +libwebsocket_ensure_user_space +(struct libwebsocket * wsi) +

Arguments

+
+
wsi +
websocket connection instance +
+

lws_set_log_level - Set the logging bitfield

void lws_set_log_level