add outermost wsi lifetime callbacks
Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
parent
09f005819a
commit
76b6ea191c
3 changed files with 18 additions and 0 deletions
|
@ -485,6 +485,11 @@ just_kill_connection:
|
|||
#ifdef LWS_OPENSSL_SUPPORT
|
||||
}
|
||||
#endif
|
||||
|
||||
/* outermost destroy notification for wsi (user_space still intact) */
|
||||
context->protocols[0].callback(context, wsi,
|
||||
LWS_CALLBACK_WSI_DESTROY, wsi->user_space, NULL, 0);
|
||||
|
||||
if (wsi->protocol && wsi->protocol->per_session_data_size &&
|
||||
wsi->user_space) /* user code may own */
|
||||
free(wsi->user_space);
|
||||
|
|
|
@ -182,6 +182,8 @@ enum libwebsocket_callback_reasons {
|
|||
LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED,
|
||||
LWS_CALLBACK_PROTOCOL_INIT,
|
||||
LWS_CALLBACK_PROTOCOL_DESTROY,
|
||||
LWS_CALLBACK_WSI_CREATE, /* always protocol[0] */
|
||||
LWS_CALLBACK_WSI_DESTROY, /* always protocol[0] */
|
||||
LWS_CALLBACK_GET_THREAD_ID,
|
||||
|
||||
/* external poll() management support */
|
||||
|
@ -680,6 +682,10 @@ struct libwebsocket_extension;
|
|||
* context is getting destroyed. Take the opportunity to
|
||||
* deallocate everything that was allocated by the protocol.
|
||||
*
|
||||
* LWS_CALLBACK_WSI_CREATE: outermost (earliest) wsi create notification
|
||||
*
|
||||
* LWS_CALLBACK_WSI_DESTROY: outermost (latest) wsi destroy notification
|
||||
*
|
||||
* The next four reasons are optional and only need taking care of if you
|
||||
* will be integrating libwebsockets sockets into an external polling
|
||||
* array.
|
||||
|
|
|
@ -119,6 +119,13 @@ libwebsocket_create_new_server_wsi(struct libwebsocket_context *context)
|
|||
new_wsi->user_space = NULL;
|
||||
new_wsi->ietf_spec_revision = 0;
|
||||
|
||||
/*
|
||||
* outermost create notification for wsi
|
||||
* no user_space because no protocol selection
|
||||
*/
|
||||
context->protocols[0].callback(context, new_wsi,
|
||||
LWS_CALLBACK_WSI_CREATE, NULL, NULL, 0);
|
||||
|
||||
return new_wsi;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue