1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

COVA10299: check lws_change_pollfd

This commit is contained in:
Andy Green 2019-07-13 12:06:33 -07:00
parent fdeadbfdef
commit fc5defdd2a
10 changed files with 34 additions and 17 deletions

View file

@ -296,7 +296,8 @@ lws_callback_http_dummy(struct lws *wsi, enum lws_callback_reasons reason,
case LWS_CALLBACK_HTTP_BODY:
if (wsi->child_list) {
lwsl_user("%s: LWS_CALLBACK_HTTP_BODY: stashing %d\n", __func__, (int)len);
lws_buflist_append_segment(&wsi->http.buflist_post_body, in, len);
if (lws_buflist_append_segment(&wsi->http.buflist_post_body, in, len) < 0)
return -1;
lws_callback_on_writable(wsi->child_list);
}
break;

View file

@ -788,7 +788,7 @@ lws_hdr_simple_create(struct lws *wsi, enum lws_token_indexes h, const char *s);
LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_ensure_user_space(struct lws *wsi);
LWS_EXTERN int
LWS_EXTERN int LWS_WARN_UNUSED_RESULT
lws_change_pollfd(struct lws *wsi, int _and, int _or);
#ifndef LWS_NO_SERVER

View file

@ -204,7 +204,8 @@ user_service_go_again:
vwsi->handling_pollout = 0;
if (vwsi->leave_pollout_active)
lws_change_pollfd(wsi, 0, LWS_POLLOUT);
if (lws_change_pollfd(wsi, 0, LWS_POLLOUT))
goto bail_die;
return n;

View file

@ -184,9 +184,12 @@ lws_cgi(struct lws *wsi, const char * const *exec_array,
wsi->child_list = cgi->stdwsi[n];
}
lws_change_pollfd(cgi->stdwsi[LWS_STDIN], LWS_POLLIN, LWS_POLLOUT);
lws_change_pollfd(cgi->stdwsi[LWS_STDOUT], LWS_POLLOUT, LWS_POLLIN);
lws_change_pollfd(cgi->stdwsi[LWS_STDERR], LWS_POLLOUT, LWS_POLLIN);
if (lws_change_pollfd(cgi->stdwsi[LWS_STDIN], LWS_POLLIN, LWS_POLLOUT))
goto bail3;
if (lws_change_pollfd(cgi->stdwsi[LWS_STDOUT], LWS_POLLOUT, LWS_POLLIN))
goto bail3;
if (lws_change_pollfd(cgi->stdwsi[LWS_STDERR], LWS_POLLOUT, LWS_POLLIN))
goto bail3;
lwsl_debug("%s: fds in %d, out %d, err %d\n", __func__,
cgi->stdwsi[LWS_STDIN]->desc.sockfd,

View file

@ -354,7 +354,8 @@ lws_h1_server_socket_service(struct lws *wsi, struct lws_pollfd *pollfd)
case 0:
lwsl_info("%s: read 0 len a\n", __func__);
wsi->seen_zero_length_recv = 1;
lws_change_pollfd(wsi, LWS_POLLIN, 0);
if (lws_change_pollfd(wsi, LWS_POLLIN, 0))
goto fail;
#if !defined(LWS_WITHOUT_EXTENSIONS)
/*
* autobahn requires us to win the race between close
@ -635,7 +636,8 @@ rops_handle_POLLIN_h1(struct lws_context_per_thread *pt, struct lws *wsi,
* and turn off our POLLIN
*/
wsi->client_rx_avail = 1;
lws_change_pollfd(wsi, LWS_POLLIN, 0);
if (lws_change_pollfd(wsi, LWS_POLLIN, 0))
return LWS_HPI_RET_PLEASE_CLOSE_ME;
//lwsl_notice("calling back %s\n", wsi->protocol->name);

View file

@ -235,7 +235,8 @@ drain:
* and turn off our POLLIN
*/
wsi->client_rx_avail = 1;
lws_change_pollfd(wsi, LWS_POLLIN, 0);
if (lws_change_pollfd(wsi, LWS_POLLIN, 0))
return LWS_HPI_RET_PLEASE_CLOSE_ME;
/* let user code know, he'll usually ask for writeable
* callback and drain / re-enable it there
@ -1128,7 +1129,8 @@ next_child:
wsi2a = wsi->h2.child_list;
while (wsi2a) {
if (wsi2a->h2.requested_POLLOUT) {
lws_change_pollfd(wsi, 0, LWS_POLLOUT);
if (lws_change_pollfd(wsi, 0, LWS_POLLOUT))
return -1;
break;
}
wsi2a = wsi2a->h2.sibling_list;

View file

@ -637,7 +637,11 @@ ads_known:
goto oom4;
}
lws_change_pollfd(wsi, 0, LWS_POLLIN);
if (lws_change_pollfd(wsi, 0, LWS_POLLIN)) {
compatible_close(wsi->desc.sockfd);
cce = "change_pollfd failed";
goto oom4;
}
/*
* past here, we can't simply free the structs as error

View file

@ -158,8 +158,9 @@ lws_http_compression_transform(struct lws *wsi, unsigned char *buf,
* and switch to trying to process the head.
*/
if (buf && len) {
lws_buflist_append_segment(
&ctx->buflist_comp, buf, len);
if (lws_buflist_append_segment(
&ctx->buflist_comp, buf, len) < 0)
return -1;
lwsl_debug("%s: %p: adding %d to comp buflist\n",
__func__,wsi, (int)len);
}
@ -208,8 +209,9 @@ lws_http_compression_transform(struct lws *wsi, unsigned char *buf,
* ...we were sending stuff from the caller directly and not
* all of it got processed... stash on the buflist tail
*/
lws_buflist_append_segment(&ctx->buflist_comp,
buf + ilen_iused, len - ilen_iused);
if (lws_buflist_append_segment(&ctx->buflist_comp,
buf + ilen_iused, len - ilen_iused) < 0)
return -1;
lwsl_debug("%s: buffering %d unused comp input\n", __func__,
(int)(len - ilen_iused));

View file

@ -56,7 +56,8 @@ rops_handle_POLLIN_raw_proxy(struct lws_context_per_thread *pt, struct lws *wsi,
case 0:
lwsl_info("%s: read 0 len\n", __func__);
wsi->seen_zero_length_recv = 1;
lws_change_pollfd(wsi, LWS_POLLIN, 0);
if (lws_change_pollfd(wsi, LWS_POLLIN, 0))
goto fail;
/*
* we need to go to fail here, since it's the only

View file

@ -72,7 +72,8 @@ rops_handle_POLLIN_raw_skt(struct lws_context_per_thread *pt, struct lws *wsi,
case 0:
lwsl_info("%s: read 0 len\n", __func__);
wsi->seen_zero_length_recv = 1;
lws_change_pollfd(wsi, LWS_POLLIN, 0);
if (lws_change_pollfd(wsi, LWS_POLLIN, 0))
goto fail;
/*
* we need to go to fail here, since it's the only