Back to index

php5  5.3.10
fpm_sockets.h
Go to the documentation of this file.
00001 
00002        /* $Id: fpm_sockets.h,v 1.12 2008/08/26 15:09:15 anight Exp $ */
00003        /* (c) 2007,2008 Andrei Nigmatulin */
00004 
00005 #ifndef FPM_MISC_H
00006 #define FPM_MISC_H 1
00007 
00008 #include <unistd.h>
00009 #include <fcntl.h>
00010 
00011 #include "fpm_worker_pool.h"
00012 
00013 /*
00014   On FreeBSD and OpenBSD, backlog negative values are truncated to SOMAXCONN
00015 */
00016 #if (__FreeBSD__) || (__OpenBSD__)
00017 #define FPM_BACKLOG_DEFAULT -1
00018 #else
00019 #define FPM_BACKLOG_DEFAULT 128
00020 #endif
00021 
00022 enum fpm_address_domain fpm_sockets_domain_from_address(char *addr);
00023 int fpm_sockets_init_main();
00024 int fpm_socket_get_listening_queue(int sock, unsigned *cur_lq, unsigned *max_lq);
00025 
00026 
00027 static inline int fd_set_blocked(int fd, int blocked) /* {{{ */
00028 {
00029        int flags = fcntl(fd, F_GETFL);
00030 
00031        if (flags < 0) {
00032               return -1;
00033        }
00034 
00035        if (blocked) {
00036               flags &= ~O_NONBLOCK;
00037        } else {
00038               flags |= O_NONBLOCK;
00039        }
00040        return fcntl(fd, F_SETFL, flags);
00041 }
00042 /* }}} */
00043 
00044 #define IPQUAD(sin_addr) \
00045                      (unsigned int) ((unsigned char *) &(sin_addr)->s_addr)[0], \
00046                      (unsigned int) ((unsigned char *) &(sin_addr)->s_addr)[1], \
00047                      (unsigned int) ((unsigned char *) &(sin_addr)->s_addr)[2], \
00048                      (unsigned int) ((unsigned char *) &(sin_addr)->s_addr)[3]
00049 
00050 #endif