mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
roubustness only return 0 from fd service if handled
Otherwise our app outer loop will think the world is ending Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
parent
03674a655d
commit
040d2efa12
2 changed files with 22 additions and 18 deletions
20
lib/client.c
20
lib/client.c
|
@ -63,7 +63,7 @@ int lws_client_socket_service(struct libwebsocket_context *context, struct libwe
|
|||
|
||||
libwebsocket_close_and_free_session(context, wsi,
|
||||
LWS_CLOSE_STATUS_NOSTATUS);
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
n = recv(wsi->sock, pkt, sizeof pkt, 0);
|
||||
|
@ -71,7 +71,7 @@ int lws_client_socket_service(struct libwebsocket_context *context, struct libwe
|
|||
libwebsocket_close_and_free_session(context, wsi,
|
||||
LWS_CLOSE_STATUS_NOSTATUS);
|
||||
lwsl_err("ERROR reading from proxy socket\n");
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
pkt[13] = '\0';
|
||||
|
@ -79,7 +79,7 @@ int lws_client_socket_service(struct libwebsocket_context *context, struct libwe
|
|||
libwebsocket_close_and_free_session(context, wsi,
|
||||
LWS_CLOSE_STATUS_NOSTATUS);
|
||||
lwsl_err("ERROR from proxy: %s\n", pkt);
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* clear his proxy connection timeout */
|
||||
|
@ -171,15 +171,19 @@ int lws_client_socket_service(struct libwebsocket_context *context, struct libwe
|
|||
"look good %d\n", n);
|
||||
libwebsocket_close_and_free_session(context,
|
||||
wsi, LWS_CLOSE_STATUS_NOSTATUS);
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
} else
|
||||
wsi->ssl = NULL;
|
||||
#endif
|
||||
|
||||
p = libwebsockets_generate_client_handshake(context, wsi, p);
|
||||
if (p == NULL)
|
||||
return 1;
|
||||
if (p == NULL) {
|
||||
lwsl_err("Failed to generate handshake for client, closing it\n");
|
||||
libwebsocket_close_and_free_session(context, wsi,
|
||||
LWS_CLOSE_STATUS_NOSTATUS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* send our request to the server */
|
||||
|
||||
|
@ -194,7 +198,7 @@ int lws_client_socket_service(struct libwebsocket_context *context, struct libwe
|
|||
lwsl_debug("ERROR writing to client socket\n");
|
||||
libwebsocket_close_and_free_session(context, wsi,
|
||||
LWS_CLOSE_STATUS_NOSTATUS);
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
wsi->parser_state = WSI_TOKEN_NAME_PART;
|
||||
|
@ -271,7 +275,7 @@ bail3:
|
|||
free(wsi->c_protocol);
|
||||
libwebsocket_close_and_free_session(context, wsi,
|
||||
LWS_CLOSE_STATUS_NOSTATUS);
|
||||
return 1;
|
||||
return 0;
|
||||
|
||||
case LWS_CONNMODE_WS_CLIENT_WAITING_EXTENSION_CONNECT:
|
||||
lwsl_ext("LWS_CONNMODE_WS_CLIENT_WAITING_EXTENSION_CONNECT\n");
|
||||
|
|
|
@ -868,7 +868,7 @@ libwebsocket_service_fd(struct libwebsocket_context *context,
|
|||
if (errno != EINTR && errno != EAGAIN)
|
||||
libwebsocket_close_and_free_session(context,
|
||||
wsi, LWS_CLOSE_STATUS_NOSTATUS);
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
if (!len) {
|
||||
libwebsocket_close_and_free_session(context, wsi,
|
||||
|
@ -879,7 +879,7 @@ libwebsocket_service_fd(struct libwebsocket_context *context,
|
|||
n = libwebsocket_read(context, wsi, buf, len);
|
||||
if (n < 0)
|
||||
/* we closed wsi */
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* this handles POLLOUT for http serving fragments */
|
||||
|
@ -1035,7 +1035,7 @@ libwebsocket_service_fd(struct libwebsocket_context *context,
|
|||
&clilen);
|
||||
if (accept_fd < 0) {
|
||||
lwsl_warn("ERROR on accept %d\n", accept_fd);
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (context->fds_count >= MAX_CLIENTS) {
|
||||
|
@ -1089,7 +1089,7 @@ bail_prox_listener:
|
|||
|
||||
libwebsocket_close_and_free_session(context, wsi,
|
||||
LWS_CLOSE_STATUS_NORMAL);
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1102,7 +1102,7 @@ bail_prox_listener:
|
|||
pollfd) < 0) {
|
||||
libwebsocket_close_and_free_session(
|
||||
context, wsi, LWS_CLOSE_STATUS_NORMAL);
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* any incoming data ready? */
|
||||
|
@ -1172,7 +1172,7 @@ bail_prox_listener:
|
|||
|
||||
libwebsocket_close_and_free_session(context, wsi,
|
||||
LWS_CLOSE_STATUS_NOSTATUS);
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* the guy requested a callback when it was OK to write */
|
||||
|
@ -1183,7 +1183,7 @@ bail_prox_listener:
|
|||
pollfd) < 0) {
|
||||
libwebsocket_close_and_free_session(
|
||||
context, wsi, LWS_CLOSE_STATUS_NORMAL);
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1207,7 +1207,7 @@ read_pending:
|
|||
if (errno != EINTR && errno != EAGAIN)
|
||||
libwebsocket_close_and_free_session(context,
|
||||
wsi, LWS_CLOSE_STATUS_NOSTATUS);
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
if (!eff_buf.token_len) {
|
||||
libwebsocket_close_and_free_session(context, wsi,
|
||||
|
@ -1246,7 +1246,7 @@ read_pending:
|
|||
libwebsocket_close_and_free_session(
|
||||
context, wsi,
|
||||
LWS_CLOSE_STATUS_NOSTATUS);
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
if (m)
|
||||
more = 1;
|
||||
|
@ -1260,7 +1260,7 @@ read_pending:
|
|||
eff_buf.token_len);
|
||||
if (n < 0)
|
||||
/* we closed wsi */
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
eff_buf.token = NULL;
|
||||
|
|
Loading…
Add table
Reference in a new issue