mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
plat: ENOTCONN
This commit is contained in:
parent
11fdbd8402
commit
95f3eb2980
10 changed files with 17 additions and 12 deletions
|
@ -82,7 +82,7 @@ lws_plat_check_connection_error(struct lws *wsi)
|
|||
|
||||
|
||||
int
|
||||
lws_plat_set_socket_options(struct lws_vhost *vhost, int fd)
|
||||
lws_plat_set_socket_options(struct lws_vhost *vhost, int fd, int unix_skt)
|
||||
{
|
||||
int optval = 1;
|
||||
socklen_t optlen = sizeof(optval);
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#define LWS_EINPROGRESS EINPROGRESS
|
||||
#define LWS_EINTR EINTR
|
||||
#define LWS_EISCONN EISCONN
|
||||
#define LWS_ENOTCONN ENOTCONN
|
||||
#define LWS_EWOULDBLOCK EWOULDBLOCK
|
||||
|
||||
#define lws_set_blocking_send(wsi)
|
||||
|
|
|
@ -202,7 +202,7 @@ lws_plat_service(struct lws_context *context, int timeout_ms)
|
|||
}
|
||||
|
||||
int
|
||||
lws_plat_set_socket_options(struct lws_vhost *vhost, int fd)
|
||||
lws_plat_set_socket_options(struct lws_vhost *vhost, int fd, int unix_skt)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#define LWS_EINPROGRESS EINPROGRESS
|
||||
#define LWS_EINTR EINTR
|
||||
#define LWS_EISCONN EISCONN
|
||||
#define LWS_ENOTCONN ENOTCONN
|
||||
#define LWS_EWOULDBLOCK EWOULDBLOCK
|
||||
|
||||
#define lws_set_blocking_send(wsi)
|
||||
|
|
|
@ -125,6 +125,7 @@
|
|||
#define LWS_EINPROGRESS EINPROGRESS
|
||||
#define LWS_EINTR EINTR
|
||||
#define LWS_EISCONN EISCONN
|
||||
#define LWS_ENOTCONN ENOTCONN
|
||||
#define LWS_EWOULDBLOCK EWOULDBLOCK
|
||||
#define lws_set_blocking_send(wsi)
|
||||
#define LWS_SOCK_INVALID (-1)
|
||||
|
|
|
@ -66,7 +66,7 @@ lws_send_pipe_choked(struct lws *wsi)
|
|||
|
||||
|
||||
int
|
||||
lws_plat_set_socket_options(struct lws_vhost *vhost, int fd)
|
||||
lws_plat_set_socket_options(struct lws_vhost *vhost, int fd, int unix_skt)
|
||||
{
|
||||
int optval = 1;
|
||||
socklen_t optlen = sizeof(optval);
|
||||
|
@ -81,7 +81,7 @@ lws_plat_set_socket_options(struct lws_vhost *vhost, int fd)
|
|||
|
||||
(void)fcntl(fd, F_SETFD, FD_CLOEXEC);
|
||||
|
||||
if (vhost->ka_time) {
|
||||
if (!unix_skt && vhost->ka_time) {
|
||||
/* enable keepalive on this socket */
|
||||
optval = 1;
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE,
|
||||
|
@ -126,7 +126,7 @@ lws_plat_set_socket_options(struct lws_vhost *vhost, int fd)
|
|||
}
|
||||
|
||||
#if defined(SO_BINDTODEVICE)
|
||||
if (vhost->bind_iface && vhost->iface) {
|
||||
if (!unix_skt && vhost->bind_iface && vhost->iface) {
|
||||
lwsl_info("binding listen skt to %s using SO_BINDTODEVICE\n", vhost->iface);
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, vhost->iface,
|
||||
strlen(vhost->iface)) < 0) {
|
||||
|
@ -139,18 +139,18 @@ lws_plat_set_socket_options(struct lws_vhost *vhost, int fd)
|
|||
/* Disable Nagle */
|
||||
optval = 1;
|
||||
#if defined (__sun) || defined(__QNX__)
|
||||
if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (const void *)&optval, optlen) < 0)
|
||||
if (!unix_skt && setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (const void *)&optval, optlen) < 0)
|
||||
return 1;
|
||||
#elif !defined(__APPLE__) && \
|
||||
!defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && \
|
||||
!defined(__NetBSD__) && \
|
||||
!defined(__OpenBSD__) && \
|
||||
!defined(__HAIKU__)
|
||||
if (setsockopt(fd, SOL_TCP, TCP_NODELAY, (const void *)&optval, optlen) < 0)
|
||||
if (!unix_skt && setsockopt(fd, SOL_TCP, TCP_NODELAY, (const void *)&optval, optlen) < 0)
|
||||
return 1;
|
||||
#else
|
||||
tcp_proto = getprotobyname("TCP");
|
||||
if (setsockopt(fd, tcp_proto->p_proto, TCP_NODELAY, &optval, optlen) < 0)
|
||||
if (!unix_skt && setsockopt(fd, tcp_proto->p_proto, TCP_NODELAY, &optval, optlen) < 0)
|
||||
return 1;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#define LWS_EINPROGRESS WSAEINPROGRESS
|
||||
#define LWS_EINTR WSAEINTR
|
||||
#define LWS_EISCONN WSAEISCONN
|
||||
#define LWS_ENOTCONN WSAENOTCONN
|
||||
#define LWS_EWOULDBLOCK WSAEWOULDBLOCK
|
||||
#define MSG_NOSIGNAL 0
|
||||
#define SHUT_RDWR SD_BOTH
|
||||
|
|
|
@ -41,7 +41,8 @@ lws_poll_listen_fd(struct lws_pollfd *fd)
|
|||
}
|
||||
|
||||
int
|
||||
lws_plat_set_socket_options(struct lws_vhost *vhost, lws_sockfd_type fd)
|
||||
lws_plat_set_socket_options(struct lws_vhost *vhost, lws_sockfd_type fd,
|
||||
int unix_skt)
|
||||
{
|
||||
int optval = 1;
|
||||
int optlen = sizeof(optval);
|
||||
|
|
|
@ -69,7 +69,7 @@ lws_ssl_capable_read(struct lws *wsi, unsigned char *buf, int len)
|
|||
errno = 0;
|
||||
n = SSL_read(wsi->tls.ssl, buf, len);
|
||||
#if defined(LWS_WITH_ESP32)
|
||||
if (!n && errno == ENOTCONN) {
|
||||
if (!n && errno == LWS_ENOTCONN) {
|
||||
lwsl_debug("%p: SSL_read ENOTCONN\n", wsi);
|
||||
return LWS_SSL_CAPABLE_ERROR;
|
||||
}
|
||||
|
|
|
@ -210,7 +210,7 @@ lws_ssl_capable_read(struct lws *wsi, unsigned char *buf, int len)
|
|||
errno = 0;
|
||||
n = SSL_read(wsi->tls.ssl, buf, len);
|
||||
#if defined(LWS_WITH_ESP32)
|
||||
if (!n && errno == ENOTCONN) {
|
||||
if (!n && errno == LWS_ENOTCONN) {
|
||||
lwsl_debug("%p: SSL_read ENOTCONN\n", wsi);
|
||||
return LWS_SSL_CAPABLE_ERROR;
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ lws_ssl_capable_read(struct lws *wsi, unsigned char *buf, int len)
|
|||
|
||||
lwsl_debug("%p: SSL_read says %d\n", wsi, n);
|
||||
/* manpage: returning 0 means connection shut down */
|
||||
if (!n || (n == -1 && errno == ENOTCONN)) {
|
||||
if (!n || (n == -1 && errno == LWS_ENOTCONN)) {
|
||||
wsi->socket_is_permanently_unusable = 1;
|
||||
|
||||
return LWS_SSL_CAPABLE_ERROR;
|
||||
|
|
Loading…
Add table
Reference in a new issue