php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
fpm_worker_pool.c
Go to the documentation of this file.
1 /* (c) 2007,2008 Andrei Nigmatulin */
2
3#include "fpm_config.h"
4
5#include <string.h>
6#include <stdlib.h>
7#include <unistd.h>
8
9#include "fpm.h"
10#include "fpm_worker_pool.h"
11#include "fpm_cleanup.h"
12#include "fpm_children.h"
13#include "fpm_shm.h"
14#include "fpm_scoreboard.h"
15#include "fpm_conf.h"
16#include "fpm_unix.h"
17
19
20void fpm_worker_pool_free_limit_extensions(char **limit_extensions) {
21 char **ext = limit_extensions;
22 while (*ext) {
23 free(*ext);
24 ext++;
25 }
26 free(limit_extensions);
27}
28
29void fpm_worker_pool_free(struct fpm_worker_pool_s *wp) /* {{{ */
30{
31 if (wp->config) {
32 free(wp->config);
33 }
34 if (wp->user) {
35 free(wp->user);
36 }
37 if (wp->set_user) {
38 free(wp->set_user);
39 }
40 if (wp->home) {
41 free(wp->home);
42 }
43 if (wp->limit_extensions) {
45 }
47 free(wp);
48}
49/* }}} */
50
51static void fpm_worker_pool_cleanup(int which, void *arg) /* {{{ */
52{
53 struct fpm_worker_pool_s *wp, *wp_next;
54
55 for (wp = fpm_worker_all_pools; wp; wp = wp_next) {
56 wp_next = wp->next;
59 if ((which & FPM_CLEANUP_CHILD) == 0 && fpm_globals.parent_pid == getpid()) {
61 }
63 }
65}
66/* }}} */
67
69{
70 struct fpm_worker_pool_s *ret;
71
72 ret = malloc(sizeof(struct fpm_worker_pool_s));
73 if (!ret) {
74 return 0;
75 }
76
77 memset(ret, 0, sizeof(struct fpm_worker_pool_s));
78
79 ret->idle_spawn_rate = 1;
80 ret->log_fd = -1;
81 return ret;
82}
83
85{
86 if (0 > fpm_cleanup_add(FPM_CLEANUP_ALL, fpm_worker_pool_cleanup, 0)) {
87 return -1;
88 }
89 return 0;
90}
file_private const char ext[]
zval * arg
Definition ffi.c:3975
memset(ptr, 0, type->size)
struct fpm_globals_s fpm_globals
Definition fpm.c:24
int fpm_children_free(struct fpm_child_s *child)
int fpm_cleanup_add(int type, void(*cleanup)(int, void *), void *arg)
Definition fpm_cleanup.c:18
@ FPM_CLEANUP_CHILD
Definition fpm_cleanup.h:10
@ FPM_CLEANUP_ALL
Definition fpm_cleanup.h:15
int fpm_worker_pool_config_free(struct fpm_worker_pool_config_s *wpc)
Definition fpm_conf.c:662
void fpm_scoreboard_free(struct fpm_worker_pool_s *wp)
int fpm_unix_free_socket_permissions(struct fpm_worker_pool_s *wp)
Definition fpm_unix.c:338
struct fpm_worker_pool_s * fpm_worker_pool_alloc(void)
void fpm_worker_pool_free_limit_extensions(char **limit_extensions)
void fpm_worker_pool_free(struct fpm_worker_pool_s *wp)
struct fpm_worker_pool_s * fpm_worker_all_pools
int fpm_worker_pool_init_main(void)
#define NULL
Definition gdcache.h:45
struct fpm_worker_pool_config_s * config
struct fpm_worker_pool_s * next
struct fpm_child_s * children
zval * ret