}
/* allocate the per-connection user memory (if any) */
- if (wsi->protocol->per_session_data_size &&
- !libwebsocket_ensure_user_space(wsi)) {
+ if (libwebsocket_ensure_user_space(wsi)) {
lwsl_err("Problem allocating wsi user mem\n");
goto bail2;
}
lwsl_info("HTTP request for '%s'\n",
lws_hdr_simple_ptr(wsi, WSI_TOKEN_GET_URI));
- if (libwebsocket_ensure_user_space(wsi) == NULL) {
+ if (libwebsocket_ensure_user_space(wsi)) {
/* drop the header info */
if (wsi->u.hdr.ah)
free(wsi->u.hdr.ah);
return wsi->u.ws.rsv;
}
-/**
- * libwebsocket_ensure_user_space(): return the user context for the connection if possible
- * @wsi: websocket connection instance
- */
-
-void *
+int
libwebsocket_ensure_user_space(struct libwebsocket *wsi)
{
if (!wsi->protocol)
- return NULL;
+ return 1;
/* allocate the per-connection user memory (if any) */
wsi->protocol->per_session_data_size);
if (wsi->user_space == NULL) {
lwsl_err("Out of memory for conn user space\n");
- return NULL;
+ return 1;
}
memset(wsi->user_space, 0,
wsi->protocol->per_session_data_size);
}
- return wsi->user_space;
+ return 0;
}
static void lwsl_emit_stderr(int level, const char *line)
LWS_EXTERN unsigned char
libwebsocket_get_reserved_bits(struct libwebsocket *wsi);
-LWS_EXTERN void *
-libwebsocket_ensure_user_space(struct libwebsocket *wsi);
-
LWS_EXTERN int
libwebsocket_rx_flow_control(struct libwebsocket *wsi, int enable);
lws_hdr_simple_create(struct libwebsocket *wsi,
enum lws_token_indexes h, const char *s);
+LWS_EXTERN int
+libwebsocket_ensure_user_space(struct libwebsocket *wsi);
+
#ifndef LWS_NO_SERVER
LWS_EXTERN int handshake_0405(struct libwebsocket_context *context,
struct libwebsocket *wsi);
}
/* allocate the per-connection user memory (if any) */
- if (wsi->protocol->per_session_data_size &&
- !libwebsocket_ensure_user_space(wsi))
+ if (libwebsocket_ensure_user_space(wsi))
goto bail;
/* create the response packet */
this is how you can get a pointer to the active protocol if needed.
</blockquote>
<hr>
-<h2>libwebsocket_ensure_user_space - </h2>
-<i>void *</i>
-<b>libwebsocket_ensure_user_space</b>
-(<i>struct libwebsocket *</i> <b>wsi</b>)
-<h3>Arguments</h3>
-<dl>
-<dt><b>wsi</b>
-<dd>websocket connection instance
-</dl>
-<hr>
<h2>lws_set_log_level - Set the logging bitfield</h2>
<i>void</i>
<b>lws_set_log_level</b>