xref: /PHP-7.4/sapi/fpm/fpm/fpm_sockets.h (revision 1ad08256)
1 	/* (c) 2007,2008 Andrei Nigmatulin */
2 
3 #ifndef FPM_MISC_H
4 #define FPM_MISC_H 1
5 
6 #include <sys/types.h>
7 #include <sys/socket.h>
8 #include <sys/un.h>
9 #include <unistd.h>
10 #include <fcntl.h>
11 
12 #include "fpm_worker_pool.h"
13 
14 /*
15   On FreeBSD and OpenBSD, backlog negative values are truncated to SOMAXCONN
16 */
17 #if (__FreeBSD__) || (__OpenBSD__)
18 #define FPM_BACKLOG_DEFAULT -1
19 #else
20 #define FPM_BACKLOG_DEFAULT 511
21 #endif
22 
23 #define FPM_ENV_SOCKET_SET_MAX 256
24 #define FPM_ENV_SOCKET_SET_SIZE 128
25 
26 enum fpm_address_domain fpm_sockets_domain_from_address(char *addr);
27 int fpm_sockets_init_main();
28 int fpm_socket_get_listening_queue(int sock, unsigned *cur_lq, unsigned *max_lq);
29 int fpm_socket_unix_test_connect(struct sockaddr_un *sock, size_t socklen);
30 
31 
fd_set_blocked(int fd,int blocked)32 static inline int fd_set_blocked(int fd, int blocked) /* {{{ */
33 {
34 	int flags = fcntl(fd, F_GETFL);
35 
36 	if (flags < 0) {
37 		return -1;
38 	}
39 
40 	if (blocked) {
41 		flags &= ~O_NONBLOCK;
42 	} else {
43 		flags |= O_NONBLOCK;
44 	}
45 	return fcntl(fd, F_SETFL, flags);
46 }
47 /* }}} */
48 
49 #endif
50