mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-29 07:58:01 -04:00
server: fix --server=<fd> on OSes returning SO_ACCEPTCONN > 1
Closes #1956
This commit is contained in:
parent
76503fb86a
commit
d66a00678d
1 changed files with 6 additions and 1 deletions
7
server.c
7
server.c
|
|
@ -4,6 +4,7 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
|
@ -23,6 +24,8 @@
|
||||||
#include "wayland.h"
|
#include "wayland.h"
|
||||||
#include "xmalloc.h"
|
#include "xmalloc.h"
|
||||||
|
|
||||||
|
#define NON_ZERO_OPT (INT_MIN / 7)
|
||||||
|
|
||||||
struct client;
|
struct client;
|
||||||
struct terminal_instance;
|
struct terminal_instance;
|
||||||
|
|
||||||
|
|
@ -474,7 +477,7 @@ prepare_socket(int fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
int const socket_options[] = { SO_DOMAIN, SO_ACCEPTCONN, SO_TYPE };
|
int const socket_options[] = { SO_DOMAIN, SO_ACCEPTCONN, SO_TYPE };
|
||||||
int const socket_options_values[] = { AF_UNIX, 1, SOCK_STREAM};
|
int const socket_options_values[] = { AF_UNIX, NON_ZERO_OPT, SOCK_STREAM};
|
||||||
char const * const socket_options_names[] = { "SO_DOMAIN", "SO_ACCEPTCONN", "SO_TYPE" };
|
char const * const socket_options_names[] = { "SO_DOMAIN", "SO_ACCEPTCONN", "SO_TYPE" };
|
||||||
|
|
||||||
xassert(ALEN(socket_options) == ALEN(socket_options_values));
|
xassert(ALEN(socket_options) == ALEN(socket_options_values));
|
||||||
|
|
@ -489,6 +492,8 @@ prepare_socket(int fd)
|
||||||
LOG_ERRNO("failed to read socket option from passed file descriptor");
|
LOG_ERRNO("failed to read socket option from passed file descriptor");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (socket_options_values[i] == NON_ZERO_OPT && socket_option)
|
||||||
|
socket_option = NON_ZERO_OPT;
|
||||||
if (socket_option != socket_options_values[i]) {
|
if (socket_option != socket_options_values[i]) {
|
||||||
LOG_ERR("wrong socket value for socket option '%s' on passed file descriptor",
|
LOG_ERR("wrong socket value for socket option '%s' on passed file descriptor",
|
||||||
socket_options_names[i]);
|
socket_options_names[i]);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue