mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
sse: drop the ah when the sse connection starts
This commit is contained in:
parent
c0b0c0ed72
commit
0b3c32c086
4 changed files with 41 additions and 1 deletions
|
@ -653,6 +653,18 @@ lws_http_redirect(struct lws *wsi, int code, const unsigned char *loc, int len,
|
|||
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT
|
||||
lws_http_transaction_completed(struct lws *wsi);
|
||||
|
||||
/**
|
||||
* lws_http_headers_detach() - drop the associated headers storage and allow
|
||||
* it to be reused by another connection
|
||||
* \param wsi: http connection
|
||||
*
|
||||
* Returns 1 if the HTTP connection must close now
|
||||
* Returns 0 and resets connection to wait for new HTTP header /
|
||||
* transaction if possible
|
||||
*/
|
||||
LWS_VISIBLE LWS_EXTERN int
|
||||
lws_http_headers_detach(struct lws *wsi);
|
||||
|
||||
/**
|
||||
* lws_http_compression_apply() - apply an http compression transform
|
||||
*
|
||||
|
|
|
@ -526,4 +526,8 @@ lws_http_compression_apply(struct lws *wsi, const char *name,
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
int
|
||||
lws_http_headers_detach(struct lws *wsi)
|
||||
{
|
||||
return lws_header_table_detach(wsi, 0);
|
||||
}
|
||||
|
|
|
@ -215,6 +215,18 @@ callback_sse(struct lws *wsi, enum lws_callback_reasons reason, void *user,
|
|||
pss->tail = lws_ring_get_oldest_tail(vhd->ring);
|
||||
pss->wsi = wsi;
|
||||
|
||||
/*
|
||||
* Drop the ah that contains the headers associated with
|
||||
* this connection... ah are a scarce resource, if we don't
|
||||
* drop it lws will forcibly drop the whole connection to free
|
||||
* the ah after 5 minutes or so.
|
||||
*
|
||||
* If the content of any http headers are important to you for
|
||||
* deciding what to send, copy them out to the pss before
|
||||
* doing the below to drop the ah.
|
||||
*/
|
||||
lws_http_headers_detach(wsi);
|
||||
|
||||
/* Unlike a normal http connection, we don't want any specific
|
||||
* timeout. We want to stay up until the client drops us */
|
||||
|
||||
|
|
|
@ -70,6 +70,18 @@ callback_sse(struct lws *wsi, enum lws_callback_reasons reason, void *user,
|
|||
|
||||
lws_set_timeout(wsi, NO_PENDING_TIMEOUT, 0);
|
||||
|
||||
/*
|
||||
* Drop the ah that contains the headers associated with
|
||||
* this connection... ah are a scarce resource, if we don't
|
||||
* drop it lws will forcibly drop the whole connection to free
|
||||
* the ah after 5 minutes or so.
|
||||
*
|
||||
* If the content of any http headers are important to you for
|
||||
* deciding what to send, copy them out to the pss before
|
||||
* doing the below to drop the ah.
|
||||
*/
|
||||
lws_http_headers_detach(wsi);
|
||||
|
||||
/* write the body separately */
|
||||
|
||||
lws_callback_on_writable(wsi);
|
||||
|
|
Loading…
Add table
Reference in a new issue