Back to index

php5  5.3.10
Defines | Functions
fpm_sockets.h File Reference
#include <unistd.h>
#include <fcntl.h>
#include "fpm_worker_pool.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define FPM_BACKLOG_DEFAULT   128
#define IPQUAD(sin_addr)

Functions

enum fpm_address_domain fpm_sockets_domain_from_address (char *addr)
int fpm_sockets_init_main ()
int fpm_socket_get_listening_queue (int sock, unsigned *cur_lq, unsigned *max_lq)
static int fd_set_blocked (int fd, int blocked)

Define Documentation

#define FPM_BACKLOG_DEFAULT   128

Definition at line 19 of file fpm_sockets.h.

#define IPQUAD (   sin_addr)
Value:
(unsigned int) ((unsigned char *) &(sin_addr)->s_addr)[0], \
                     (unsigned int) ((unsigned char *) &(sin_addr)->s_addr)[1], \
                     (unsigned int) ((unsigned char *) &(sin_addr)->s_addr)[2], \
                     (unsigned int) ((unsigned char *) &(sin_addr)->s_addr)[3]

Definition at line 44 of file fpm_sockets.h.


Function Documentation

static int fd_set_blocked ( int  fd,
int  blocked 
) [inline, static]

Definition at line 27 of file fpm_sockets.h.

{
       int flags = fcntl(fd, F_GETFL);

       if (flags < 0) {
              return -1;
       }

       if (blocked) {
              flags &= ~O_NONBLOCK;
       } else {
              flags |= O_NONBLOCK;
       }
       return fcntl(fd, F_SETFL, flags);
}

Here is the caller graph for this function:

int fpm_socket_get_listening_queue ( int  sock,
unsigned *  cur_lq,
unsigned *  max_lq 
)

Definition at line 447 of file fpm_sockets.c.

{
       return -1;
}

Here is the caller graph for this function:

Definition at line 232 of file fpm_sockets.c.

{
       if (strchr(address, ':')) {
              return FPM_AF_INET;
       }

       if (strlen(address) == strspn(address, "0123456789")) {
              return FPM_AF_INET;
       }
       return FPM_AF_UNIX;
}

Here is the caller graph for this function:

Definition at line 298 of file fpm_sockets.c.

{
       unsigned i, lq_len;
       struct fpm_worker_pool_s *wp;
       char *inherited = getenv("FPM_SOCKETS");
       struct listening_socket_s *ls;

       if (0 == fpm_array_init(&sockets_list, sizeof(struct listening_socket_s), 10)) {
              return -1;
       }

       /* import inherited sockets */
       while (inherited && *inherited) {
              char *comma = strchr(inherited, ',');
              int type, fd_no;
              char *eq;

              if (comma) {
                     *comma = '\0';
              }

              eq = strchr(inherited, '=');
              if (eq) {
                     *eq = '\0';
                     fd_no = atoi(eq + 1);
                     type = fpm_sockets_domain_from_address(inherited);
                     zlog(ZLOG_NOTICE, "using inherited socket fd=%d, \"%s\"", fd_no, inherited);
                     fpm_sockets_hash_op(fd_no, 0, inherited, type, FPM_STORE_SOCKET);
              }

              if (comma) {
                     inherited = comma + 1;
              } else {
                     inherited = 0;
              }
       }

       /* create all required sockets */
       for (wp = fpm_worker_all_pools; wp; wp = wp->next) {
              switch (wp->listen_address_domain) {
                     case FPM_AF_INET :
                            wp->listening_socket = fpm_socket_af_inet_listening_socket(wp);
                            break;

                     case FPM_AF_UNIX :
                            if (0 > fpm_unix_resolve_socket_premissions(wp)) {
                                   return -1;
                            }
                            wp->listening_socket = fpm_socket_af_unix_listening_socket(wp);
                            break;
              }

              if (wp->listening_socket == -1) {
                     return -1;
              }

       if (wp->listen_address_domain == FPM_AF_INET && fpm_socket_get_listening_queue(wp->listening_socket, NULL, &lq_len) >= 0) {
                     fpm_scoreboard_update(-1, -1, -1, (int)lq_len, -1, -1, FPM_SCOREBOARD_ACTION_SET, wp->scoreboard);
              }
       }

       /* close unused sockets that was inherited */
       ls = sockets_list.data;

       for (i = 0; i < sockets_list.used; ) {
              if (ls->refcount == 0) {
                     close(ls->sock);
                     if (ls->type == FPM_AF_UNIX) {
                            unlink(ls->key);
                     }
                     free(ls->key);
                     fpm_array_item_remove(&sockets_list, i);
              } else {
                     ++i;
                     ++ls;
              }
       }

       if (0 > fpm_cleanup_add(FPM_CLEANUP_ALL, fpm_sockets_cleanup, 0)) {
              return -1;
       }
       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function: