win use platform invalid socket api elsewhere too
Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
parent
c53f7cad97
commit
fc772ccc00
5 changed files with 11 additions and 10 deletions
|
@ -159,8 +159,10 @@ struct libwebsocket *libwebsocket_client_connect_2(
|
|||
wsi->mode = LWS_CONNMODE_WS_CLIENT_WAITING_CONNECT;
|
||||
|
||||
lws_libev_accept(context, wsi, wsi->sock);
|
||||
if (insert_wsi_socket_into_fds(context, wsi))
|
||||
if (insert_wsi_socket_into_fds(context, wsi)) {
|
||||
compatible_close(wsi->sock);
|
||||
goto oom4;
|
||||
}
|
||||
|
||||
/*
|
||||
* past here, we can't simply free the structs as error
|
||||
|
@ -190,14 +192,12 @@ struct libwebsocket *libwebsocket_client_connect_2(
|
|||
(struct sockaddr_in *)v, n) < 0) {
|
||||
lwsl_err("Unable to find interface %s\n",
|
||||
context->iface);
|
||||
compatible_close(wsi->sock);
|
||||
goto failed;
|
||||
}
|
||||
|
||||
if (bind(wsi->sock, v, n) < 0) {
|
||||
lwsl_err("Error binding to interface %s",
|
||||
context->iface);
|
||||
compatible_close(wsi->sock);
|
||||
goto failed;
|
||||
}
|
||||
}
|
||||
|
@ -350,7 +350,7 @@ libwebsocket_client_connect(struct libwebsocket_context *context,
|
|||
if (wsi == NULL)
|
||||
goto bail;
|
||||
|
||||
wsi->sock = -1;
|
||||
wsi->sock = LWS_SOCK_INVALID;
|
||||
|
||||
/* -1 means just use latest supported */
|
||||
|
||||
|
|
|
@ -300,7 +300,7 @@ just_kill_connection:
|
|||
|
||||
/* lwsl_info("closing fd=%d\n", wsi->sock); */
|
||||
|
||||
if (!lws_ssl_close(wsi) && wsi->sock >= 0) {
|
||||
if (!lws_ssl_close(wsi) && lws_socket_is_valid(wsi->sock)) {
|
||||
n = shutdown(wsi->sock, SHUT_RDWR);
|
||||
if (n)
|
||||
lwsl_debug("closing: shutdown ret %d\n", LWS_ERRNO);
|
||||
|
@ -308,6 +308,7 @@ just_kill_connection:
|
|||
n = compatible_close(wsi->sock);
|
||||
if (n)
|
||||
lwsl_debug("closing: close ret %d\n", LWS_ERRNO);
|
||||
wsi->sock = LWS_SOCK_INVALID;
|
||||
}
|
||||
|
||||
/* outermost destroy notification for wsi (user_space still intact) */
|
||||
|
|
|
@ -120,7 +120,7 @@ int lws_issue_raw(struct libwebsocket *wsi, unsigned char *buf, size_t len)
|
|||
n = m;
|
||||
goto handle_truncated_send;
|
||||
}
|
||||
if (wsi->sock < 0)
|
||||
if (!lws_socket_is_valid(wsi->sock))
|
||||
lwsl_warn("** error invalid sock but expected to send\n");
|
||||
|
||||
/*
|
||||
|
|
|
@ -41,7 +41,7 @@ insert_wsi_socket_into_fds(struct libwebsocket_context *context,
|
|||
#endif
|
||||
|
||||
assert(wsi);
|
||||
assert(wsi->sock >= 0);
|
||||
assert(lws_socket_is_valid(wsi->sock));
|
||||
|
||||
lwsl_info("insert_wsi_socket_into_fds: wsi=%p, sock=%d, fds pos=%d\n",
|
||||
wsi, wsi->sock, context->fds_count);
|
||||
|
@ -115,7 +115,7 @@ remove_wsi_socket_from_fds(struct libwebsocket_context *context,
|
|||
wsi->position_in_fds_table = -1;
|
||||
|
||||
/* remove also from external POLL support via protocol 0 */
|
||||
if (wsi->sock) {
|
||||
if (lws_socket_is_valid(wsi->sock)) {
|
||||
if (context->protocols[0].callback(context, wsi,
|
||||
LWS_CALLBACK_DEL_POLL_FD, wsi->user_space,
|
||||
(void *) &pa, 0))
|
||||
|
|
|
@ -49,7 +49,7 @@ int lws_context_init_server(struct lws_context_creation_info *info,
|
|||
#endif
|
||||
sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
|
||||
if (sockfd < 0) {
|
||||
if (sockfd == -1) {
|
||||
lwsl_err("ERROR opening socket\n");
|
||||
return 1;
|
||||
}
|
||||
|
@ -671,7 +671,7 @@ int lws_server_socket_service(struct libwebsocket_context *context,
|
|||
struct libwebsocket *wsi, struct libwebsocket_pollfd *pollfd)
|
||||
{
|
||||
struct libwebsocket *new_wsi = NULL;
|
||||
int accept_fd = 0;
|
||||
int accept_fd = LWS_SOCK_INVALID;
|
||||
socklen_t clilen;
|
||||
struct sockaddr_in cli_addr;
|
||||
int n;
|
||||
|
|
Loading…
Add table
Reference in a new issue