mirror of
https://github.com/eclipse-mosquitto/mosquitto.git
synced 2026-05-21 12:24:29 +02:00
Fix missing unix sockets support on Windows
This commit is contained in:
parent
2d2950a6a5
commit
189e370313
|
|
@ -68,7 +68,7 @@ else()
|
|||
endif()
|
||||
|
||||
option(WITH_UNIX_SOCKETS "Include Unix Domain Socket support?" ON)
|
||||
if(WITH_UNIX_SOCKETS AND NOT WIN32)
|
||||
if(WITH_UNIX_SOCKETS)
|
||||
add_definitions("-DWITH_UNIX_SOCKETS")
|
||||
endif()
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,11 @@ Contributors:
|
|||
#endif
|
||||
|
||||
#ifdef WITH_UNIX_SOCKETS
|
||||
# include <sys/un.h>
|
||||
# ifdef WIN32
|
||||
# include <afunix.h>
|
||||
# else
|
||||
# include <sys/un.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __QNX__
|
||||
|
|
@ -538,10 +542,12 @@ static int net__try_connect_unix(const char *host, mosq_sock_t *sock)
|
|||
if(s < 0){
|
||||
return MOSQ_ERR_ERRNO;
|
||||
}
|
||||
#ifndef WIN32
|
||||
rc = net__socket_nonblock(&s);
|
||||
if(rc){
|
||||
return rc;
|
||||
}
|
||||
#endif
|
||||
|
||||
rc = connect(s, (struct sockaddr *)&addr, sizeof(struct sockaddr_un));
|
||||
if(rc < 0){
|
||||
|
|
|
|||
16
src/net.c
16
src/net.c
|
|
@ -50,7 +50,11 @@ Contributors:
|
|||
#endif
|
||||
|
||||
#ifdef WITH_UNIX_SOCKETS
|
||||
# include "sys/un.h"
|
||||
# ifdef WIN32
|
||||
# include <afunix.h>
|
||||
# else
|
||||
# include <sys/un.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __QNX__
|
||||
|
|
@ -936,7 +940,9 @@ static int net__socket_listen_unix(struct mosquitto__listener *listener)
|
|||
struct sockaddr_un addr;
|
||||
int sock;
|
||||
int rc;
|
||||
#ifndef WIN32
|
||||
mode_t old_mask;
|
||||
#endif
|
||||
|
||||
if(listener->unix_socket_path == NULL){
|
||||
return MOSQ_ERR_INVAL;
|
||||
|
|
@ -946,7 +952,11 @@ static int net__socket_listen_unix(struct mosquitto__listener *listener)
|
|||
return MOSQ_ERR_INVAL;
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
DeleteFile(listener->unix_socket_path);
|
||||
#else
|
||||
unlink(listener->unix_socket_path);
|
||||
#endif
|
||||
log__printf(NULL, MOSQ_LOG_INFO, "Opening unix listen socket on path %s.", listener->unix_socket_path);
|
||||
memset(&addr, 0, sizeof(struct sockaddr_un));
|
||||
addr.sun_family = AF_UNIX;
|
||||
|
|
@ -967,9 +977,13 @@ static int net__socket_listen_unix(struct mosquitto__listener *listener)
|
|||
listener->socks[listener->sock_count-1] = sock;
|
||||
|
||||
|
||||
#ifndef WIN32
|
||||
old_mask = umask(0007);
|
||||
#endif
|
||||
rc = bind(sock, (struct sockaddr *)&addr, sizeof(struct sockaddr_un));
|
||||
#ifndef WIN32
|
||||
umask(old_mask);
|
||||
#endif
|
||||
|
||||
if(rc == -1){
|
||||
net__print_error(MOSQ_LOG_ERR, "Error binding unix socket: %s");
|
||||
|
|
|
|||
Loading…
Reference in a new issue