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