[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@18.227.140.235: ~ $
	/* $Id: fpm.c,v 1.23 2008/07/20 16:38:31 anight Exp $ */
	/* (c) 2007,2008 Andrei Nigmatulin */

#include "fpm_config.h"

#include <stdlib.h> /* for exit */

#include "fpm.h"
#include "fpm_children.h"
#include "fpm_signals.h"
#include "fpm_env.h"
#include "fpm_events.h"
#include "fpm_cleanup.h"
#include "fpm_php.h"
#include "fpm_sockets.h"
#include "fpm_unix.h"
#include "fpm_process_ctl.h"
#include "fpm_conf.h"
#include "fpm_worker_pool.h"
#include "fpm_scoreboard.h"
#include "fpm_stdio.h"
#include "fpm_log.h"
#include "zlog.h"

struct fpm_globals_s fpm_globals = {
	.parent_pid = 0, 
	.argc = 0,
	.argv = NULL,
	.config = NULL,
	.prefix = NULL,
	.pid = NULL,
	.running_children = 0,
	.error_log_fd = 0,
	.log_level = 0,
	.listening_socket = 0,
	.max_requests = 0,
	.is_child = 0,
	.test_successful = 0,
	.heartbeat = 0,
	.run_as_root = 0,
	.force_stderr = 0,
	.send_config_pipe = {0, 0},
};

int fpm_init(int argc, char **argv, char *config, char *prefix, char *pid, int test_conf, int run_as_root, int force_daemon, int force_stderr) /* {{{ */
{
	fpm_globals.argc = argc;
	fpm_globals.argv = argv;
	if (config && *config) {
		fpm_globals.config = strdup(config);
	}
	fpm_globals.prefix = prefix;
	fpm_globals.pid = pid;
	fpm_globals.run_as_root = run_as_root;
	fpm_globals.force_stderr = force_stderr;

	if (0 > fpm_php_init_main()           ||
	    0 > fpm_stdio_init_main()         ||
	    0 > fpm_conf_init_main(test_conf, force_daemon) ||
	    0 > fpm_unix_init_main()          ||
	    0 > fpm_scoreboard_init_main()    ||
	    0 > fpm_pctl_init_main()          ||
	    0 > fpm_env_init_main()           ||
	    0 > fpm_signals_init_main()       ||
	    0 > fpm_children_init_main()      ||
	    0 > fpm_sockets_init_main()       ||
	    0 > fpm_worker_pool_init_main()   ||
	    0 > fpm_event_init_main()) {

		if (fpm_globals.test_successful) {
			exit(FPM_EXIT_OK);
		} else {
			zlog(ZLOG_ERROR, "FPM initialization failed");
			return -1;
		}
	}

	if (0 > fpm_conf_write_pid()) {
		zlog(ZLOG_ERROR, "FPM initialization failed");
		return -1;
	}

	fpm_stdio_init_final();
	zlog(ZLOG_NOTICE, "fpm is running, pid %d", (int) fpm_globals.parent_pid);

	return 0;
}
/* }}} */

/*	children: return listening socket
	parent: never return */
int fpm_run(int *max_requests) /* {{{ */
{
	struct fpm_worker_pool_s *wp;

	/* create initial children in all pools */
	for (wp = fpm_worker_all_pools; wp; wp = wp->next) {
		int is_parent;

		is_parent = fpm_children_create_initial(wp);

		if (!is_parent) {
			goto run_child;
		}

		/* handle error */
		if (is_parent == 2) {
			fpm_pctl(FPM_PCTL_STATE_TERMINATING, FPM_PCTL_ACTION_SET);
			fpm_event_loop(1);
		}
	}

	/* run event loop forever */
	fpm_event_loop(0);

run_child: /* only workers reach this point */

	fpm_cleanups_run(FPM_CLEANUP_CHILD);

	*max_requests = fpm_globals.max_requests;
	return fpm_globals.listening_socket;
}
/* }}} */


Filemanager

Name Type Size Permission Actions
events Folder 0755
fastcgi.c File 25.94 KB 0644
fastcgi.h File 4.47 KB 0644
fpm.c File 2.84 KB 0644
fpm.h File 1.13 KB 0644
fpm_arrays.h File 1.82 KB 0644
fpm_atomic.h File 3.95 KB 0644
fpm_children.c File 10.99 KB 0644
fpm_children.h File 873 B 0644
fpm_cleanup.c File 849 B 0644
fpm_cleanup.h File 519 B 0644
fpm_clock.c File 2.23 KB 0644
fpm_clock.h File 239 B 0644
fpm_conf.c File 49.14 KB 0644
fpm_conf.h File 2.43 KB 0644
fpm_env.c File 5.39 KB 0644
fpm_env.h File 491 B 0644
fpm_events.c File 11.67 KB 0644
fpm_events.h File 1.59 KB 0644
fpm_log.c File 11.53 KB 0644
fpm_log.h File 300 B 0644
fpm_main.c File 62.74 KB 0644
fpm_php.c File 6.42 KB 0644
fpm_php.h File 1.23 KB 0644
fpm_php_trace.c File 3.49 KB 0644
fpm_process_ctl.c File 13.65 KB 0644
fpm_process_ctl.h File 1.23 KB 0644
fpm_request.c File 8.01 KB 0644
fpm_request.h File 1.18 KB 0644
fpm_scoreboard.c File 7.84 KB 0644
fpm_scoreboard.h File 2.5 KB 0644
fpm_shm.c File 1.23 KB 0644
fpm_shm.h File 263 B 0644
fpm_signals.c File 4.72 KB 0644
fpm_signals.h File 315 B 0644
fpm_sockets.c File 11.39 KB 0644
fpm_sockets.h File 1006 B 0644
fpm_status.c File 13.7 KB 0644
fpm_status.h File 1.03 KB 0644
fpm_stdio.c File 7.36 KB 0644
fpm_stdio.h File 569 B 0644
fpm_str.h File 483 B 0644
fpm_systemd.c File 3.11 KB 0644
fpm_systemd.h File 275 B 0644
fpm_trace.c File 641 B 0644
fpm_trace.h File 378 B 0644
fpm_trace_ptrace.c File 1.6 KB 0644
fpm_unix.c File 19.23 KB 0644
fpm_unix.h File 518 B 0644
fpm_worker_pool.c File 1.57 KB 0644
fpm_worker_pool.h File 1.23 KB 0644
zlog.c File 4.47 KB 0644
zlog.h File 978 B 0644