mirror of
https://github.com/php/php-src.git
synced 2024-09-22 10:27:25 +00:00
Remove unused functions / variables / #if 0 blocks
This commit is contained in:
parent
757d7ace9a
commit
acf5fba0fb
@ -183,11 +183,6 @@ static void fcgi_setup_signals(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
int fcgi_in_shutdown(void)
|
||||
{
|
||||
return in_shutdown;
|
||||
}
|
||||
|
||||
int fcgi_init(void)
|
||||
{
|
||||
if (!is_initialized) {
|
||||
@ -278,76 +273,6 @@ void fcgi_shutdown(void)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
/* Do some black magic with the NT security API.
|
||||
* We prepare a DACL (Discretionary Access Control List) so that
|
||||
* we, the creator, are allowed all access, while "Everyone Else"
|
||||
* is only allowed to read and write to the pipe.
|
||||
* This avoids security issues on shared hosts where a luser messes
|
||||
* with the lower-level pipe settings and screws up the FastCGI service.
|
||||
*/
|
||||
static PACL prepare_named_pipe_acl(PSECURITY_DESCRIPTOR sd, LPSECURITY_ATTRIBUTES sa)
|
||||
{
|
||||
DWORD req_acl_size;
|
||||
char everyone_buf[32], owner_buf[32];
|
||||
PSID sid_everyone, sid_owner;
|
||||
SID_IDENTIFIER_AUTHORITY
|
||||
siaWorld = SECURITY_WORLD_SID_AUTHORITY,
|
||||
siaCreator = SECURITY_CREATOR_SID_AUTHORITY;
|
||||
PACL acl;
|
||||
|
||||
sid_everyone = (PSID)&everyone_buf;
|
||||
sid_owner = (PSID)&owner_buf;
|
||||
|
||||
req_acl_size = sizeof(ACL) +
|
||||
(2 * ((sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD)) + GetSidLengthRequired(1)));
|
||||
|
||||
acl = malloc(req_acl_size);
|
||||
|
||||
if (acl == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!InitializeSid(sid_everyone, &siaWorld, 1)) {
|
||||
goto out_fail;
|
||||
}
|
||||
*GetSidSubAuthority(sid_everyone, 0) = SECURITY_WORLD_RID;
|
||||
|
||||
if (!InitializeSid(sid_owner, &siaCreator, 1)) {
|
||||
goto out_fail;
|
||||
}
|
||||
*GetSidSubAuthority(sid_owner, 0) = SECURITY_CREATOR_OWNER_RID;
|
||||
|
||||
if (!InitializeAcl(acl, req_acl_size, ACL_REVISION)) {
|
||||
goto out_fail;
|
||||
}
|
||||
|
||||
if (!AddAccessAllowedAce(acl, ACL_REVISION, FILE_GENERIC_READ | FILE_GENERIC_WRITE, sid_everyone)) {
|
||||
goto out_fail;
|
||||
}
|
||||
|
||||
if (!AddAccessAllowedAce(acl, ACL_REVISION, FILE_ALL_ACCESS, sid_owner)) {
|
||||
goto out_fail;
|
||||
}
|
||||
|
||||
if (!InitializeSecurityDescriptor(sd, SECURITY_DESCRIPTOR_REVISION)) {
|
||||
goto out_fail;
|
||||
}
|
||||
|
||||
if (!SetSecurityDescriptorDacl(sd, TRUE, acl, FALSE)) {
|
||||
goto out_fail;
|
||||
}
|
||||
|
||||
sa->lpSecurityDescriptor = sd;
|
||||
|
||||
return acl;
|
||||
|
||||
out_fail:
|
||||
free(acl);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
void fcgi_set_allowed_clients(char *ip)
|
||||
{
|
||||
char *cur, *end;
|
||||
@ -383,154 +308,6 @@ void fcgi_set_allowed_clients(char *ip)
|
||||
}
|
||||
}
|
||||
|
||||
//TODO
|
||||
static int is_port_number(const char *bindpath)
|
||||
{
|
||||
while (*bindpath) {
|
||||
if (*bindpath < '0' || *bindpath > '9') {
|
||||
return 0;
|
||||
}
|
||||
bindpath++;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int fcgi_listen(const char *path, int backlog)
|
||||
{
|
||||
char *s;
|
||||
int tcp = 0;
|
||||
char host[MAXPATHLEN];
|
||||
short port = 0;
|
||||
int listen_socket;
|
||||
sa_t sa;
|
||||
socklen_t sock_len;
|
||||
#ifdef SO_REUSEADDR
|
||||
# ifdef _WIN32
|
||||
BOOL reuse = 1;
|
||||
# else
|
||||
int reuse = 1;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
if ((s = strchr(path, ':'))) {
|
||||
port = atoi(s+1);
|
||||
if (port != 0 && (s-path) < MAXPATHLEN) {
|
||||
strncpy(host, path, s-path);
|
||||
host[s-path] = '\0';
|
||||
tcp = 1;
|
||||
}
|
||||
} else if (is_port_number(path)) {
|
||||
port = atoi(path);
|
||||
if (port != 0) {
|
||||
host[0] = '\0';
|
||||
tcp = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Prepare socket address */
|
||||
if (tcp) {
|
||||
memset(&sa.sa_inet, 0, sizeof(sa.sa_inet));
|
||||
sa.sa_inet.sin_family = AF_INET;
|
||||
sa.sa_inet.sin_port = htons(port);
|
||||
sock_len = sizeof(sa.sa_inet);
|
||||
|
||||
if (!*host || !strncmp(host, "*", sizeof("*")-1)) {
|
||||
sa.sa_inet.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
} else {
|
||||
sa.sa_inet.sin_addr.s_addr = inet_addr(host);
|
||||
if (sa.sa_inet.sin_addr.s_addr == INADDR_NONE) {
|
||||
struct hostent *hep;
|
||||
|
||||
hep = gethostbyname(host);
|
||||
if (!hep || hep->h_addrtype != AF_INET || !hep->h_addr_list[0]) {
|
||||
fprintf(stderr, "Cannot resolve host name '%s'!\n", host);
|
||||
return -1;
|
||||
} else if (hep->h_addr_list[1]) {
|
||||
fprintf(stderr, "Host '%s' has multiple addresses. You must choose one explicitly!\n", host);
|
||||
return -1;
|
||||
}
|
||||
sa.sa_inet.sin_addr.s_addr = ((struct in_addr*)hep->h_addr_list[0])->s_addr;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
#ifdef _WIN32
|
||||
SECURITY_DESCRIPTOR sd;
|
||||
SECURITY_ATTRIBUTES saw;
|
||||
PACL acl;
|
||||
HANDLE namedPipe;
|
||||
|
||||
memset(&sa, 0, sizeof(saw));
|
||||
saw.nLength = sizeof(saw);
|
||||
saw.bInheritHandle = FALSE;
|
||||
acl = prepare_named_pipe_acl(&sd, &saw);
|
||||
|
||||
namedPipe = CreateNamedPipe(path,
|
||||
PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
|
||||
PIPE_TYPE_BYTE | PIPE_WAIT | PIPE_READMODE_BYTE,
|
||||
PIPE_UNLIMITED_INSTANCES,
|
||||
8192, 8192, 0, &saw);
|
||||
if (namedPipe == INVALID_HANDLE_VALUE) {
|
||||
return -1;
|
||||
}
|
||||
listen_socket = _open_osfhandle((long)namedPipe, 0);
|
||||
if (!is_initialized) {
|
||||
fcgi_init();
|
||||
}
|
||||
is_fastcgi = 1;
|
||||
return listen_socket;
|
||||
|
||||
#else
|
||||
int path_len = strlen(path);
|
||||
|
||||
if (path_len >= sizeof(sa.sa_unix.sun_path)) {
|
||||
fprintf(stderr, "Listening socket's path name is too long.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(&sa.sa_unix, 0, sizeof(sa.sa_unix));
|
||||
sa.sa_unix.sun_family = AF_UNIX;
|
||||
memcpy(sa.sa_unix.sun_path, path, path_len + 1);
|
||||
sock_len = (size_t)(((struct sockaddr_un *)0)->sun_path) + path_len;
|
||||
#ifdef HAVE_SOCKADDR_UN_SUN_LEN
|
||||
sa.sa_unix.sun_len = sock_len;
|
||||
#endif
|
||||
unlink(path);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Create, bind socket and start listen on it */
|
||||
if ((listen_socket = socket(sa.sa.sa_family, SOCK_STREAM, 0)) < 0 ||
|
||||
#ifdef SO_REUSEADDR
|
||||
setsockopt(listen_socket, SOL_SOCKET, SO_REUSEADDR, (char*)&reuse, sizeof(reuse)) < 0 ||
|
||||
#endif
|
||||
bind(listen_socket, (struct sockaddr *) &sa, sock_len) < 0 ||
|
||||
listen(listen_socket, backlog) < 0) {
|
||||
|
||||
fprintf(stderr, "Cannot bind/listen socket - [%d] %s.\n",errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!tcp) {
|
||||
chmod(path, 0777);
|
||||
} else {
|
||||
fcgi_set_allowed_clients(getenv("FCGI_WEB_SERVER_ADDRS"));
|
||||
}
|
||||
|
||||
if (!is_initialized) {
|
||||
fcgi_init();
|
||||
}
|
||||
is_fastcgi = 1;
|
||||
|
||||
#ifdef _WIN32
|
||||
if (tcp) {
|
||||
listen_socket = _open_osfhandle((long)listen_socket, 0);
|
||||
}
|
||||
#else
|
||||
fcgi_setup_signals();
|
||||
#endif
|
||||
return listen_socket;
|
||||
}
|
||||
|
||||
void fcgi_init_request(fcgi_request *req, int listen_socket)
|
||||
{
|
||||
memset(req, 0, sizeof(fcgi_request));
|
||||
@ -1139,36 +916,7 @@ int fcgi_write(fcgi_request *req, fcgi_request_type type, const char *str, int l
|
||||
if (req->out_hdr && req->out_hdr->type != type) {
|
||||
close_packet(req);
|
||||
}
|
||||
#if 0
|
||||
/* Unoptimized, but clear version */
|
||||
rest = len;
|
||||
while (rest > 0) {
|
||||
limit = sizeof(req->out_buf) - (req->out_pos - req->out_buf);
|
||||
|
||||
if (!req->out_hdr) {
|
||||
if (limit < sizeof(fcgi_header)) {
|
||||
if (!fcgi_flush(req, 0)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
open_packet(req, type);
|
||||
}
|
||||
limit = sizeof(req->out_buf) - (req->out_pos - req->out_buf);
|
||||
if (rest < limit) {
|
||||
memcpy(req->out_pos, str, rest);
|
||||
req->out_pos += rest;
|
||||
return len;
|
||||
} else {
|
||||
memcpy(req->out_pos, str, limit);
|
||||
req->out_pos += limit;
|
||||
rest -= limit;
|
||||
str += limit;
|
||||
if (!fcgi_flush(req, 0)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
/* Optimized version */
|
||||
limit = sizeof(req->out_buf) - (req->out_pos - req->out_buf);
|
||||
if (!req->out_hdr) {
|
||||
@ -1236,7 +984,7 @@ int fcgi_write(fcgi_request *req, fcgi_request_type type, const char *str, int l
|
||||
req->out_pos += rest;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
@ -1283,18 +1031,6 @@ char* fcgi_putenv(fcgi_request *req, char* var, int var_len, char* val)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
void fcgi_impersonate(void)
|
||||
{
|
||||
char *os_name;
|
||||
|
||||
os_name = getenv("OS");
|
||||
if (os_name && stricmp(os_name, "Windows_NT") == 0) {
|
||||
is_impersonate = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void fcgi_set_mgmt_var(const char * name, size_t name_len, const char * value, size_t value_len)
|
||||
{
|
||||
zval * zvalue;
|
||||
|
@ -115,8 +115,6 @@ typedef struct _fcgi_request {
|
||||
int fcgi_init(void);
|
||||
void fcgi_shutdown(void);
|
||||
int fcgi_is_fastcgi(void);
|
||||
int fcgi_in_shutdown(void);
|
||||
int fcgi_listen(const char *path, int backlog);
|
||||
void fcgi_init_request(fcgi_request *req, int listen_socket);
|
||||
int fcgi_accept_request(fcgi_request *req);
|
||||
int fcgi_finish_request(fcgi_request *req, int force_close);
|
||||
@ -134,10 +132,6 @@ int fcgi_read(fcgi_request *req, char *str, int len);
|
||||
int fcgi_write(fcgi_request *req, fcgi_request_type type, const char *str, int len);
|
||||
int fcgi_flush(fcgi_request *req, int close);
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
void fcgi_impersonate(void);
|
||||
#endif
|
||||
|
||||
void fcgi_set_mgmt_var(const char * name, size_t name_len, const char * value, size_t value_len);
|
||||
void fcgi_free_mgmt_var_cb(void * ptr);
|
||||
|
||||
|
@ -118,17 +118,6 @@ static void (*php_php_import_environment_variables)(zval *array_ptr TSRMLS_DC);
|
||||
* Set to non-zero if we are the parent process
|
||||
*/
|
||||
static int parent = 1;
|
||||
|
||||
/* Did parent received exit signals SIG_TERM/SIG_INT/SIG_QUIT */
|
||||
static int exit_signal = 0;
|
||||
|
||||
/* Is Parent waiting for children to exit */
|
||||
static int parent_waiting = 0;
|
||||
|
||||
/**
|
||||
* Process group
|
||||
*/
|
||||
static pid_t pgroup;
|
||||
#endif
|
||||
|
||||
static int request_body_fd;
|
||||
@ -1368,29 +1357,6 @@ static void init_request_info(TSRMLS_D)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
#ifndef PHP_WIN32
|
||||
/**
|
||||
* Clean up child processes upon exit
|
||||
*/
|
||||
void fastcgi_cleanup(int signal)
|
||||
{
|
||||
#ifdef DEBUG_FASTCGI
|
||||
fprintf(stderr, "FastCGI shutdown, pid %d\n", getpid());
|
||||
#endif
|
||||
|
||||
sigaction(SIGTERM, &old_term, 0);
|
||||
|
||||
/* Kill all the processes in our process group */
|
||||
kill(-pgroup, SIGTERM);
|
||||
|
||||
if (parent && parent_waiting) {
|
||||
exit_signal = 1;
|
||||
} else {
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
PHP_INI_BEGIN()
|
||||
STD_PHP_INI_ENTRY("cgi.rfc2616_headers", "0", PHP_INI_ALL, OnUpdateBool, rfc2616_headers, php_cgi_globals_struct, php_cgi_globals)
|
||||
STD_PHP_INI_ENTRY("cgi.nph", "0", PHP_INI_ALL, OnUpdateBool, nph, php_cgi_globals_struct, php_cgi_globals)
|
||||
@ -1522,16 +1488,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
fcgi_init();
|
||||
|
||||
#if 0 && defined(PHP_DEBUG)
|
||||
/* IIS is always making things more difficult. This allows
|
||||
* us to stop PHP and attach a debugger before much gets started */
|
||||
{
|
||||
char szMessage [256];
|
||||
wsprintf (szMessage, "Please attach a debugger to the process 0x%X [%d] (%s) and click OK", GetCurrentProcessId(), GetCurrentProcessId(), argv[0]);
|
||||
MessageBox(NULL, szMessage, "CGI Debug Time!", MB_OK|MB_SERVICE_NOTIFICATION);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SIGNAL_H
|
||||
#if defined(SIGPIPE) && defined(SIG_IGN)
|
||||
signal(SIGPIPE, SIG_IGN); /* ignore SIGPIPE in standalone mode so
|
||||
|
@ -123,37 +123,6 @@ void fpm_status_update_activity(struct fpm_shm_s *shm, int idle, int active, int
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
int fpm_status_get(int *idle, int *active, int *total, int *pm) /* {{{ */
|
||||
{
|
||||
struct fpm_status_s status;
|
||||
if (!fpm_status_shm || !fpm_status_shm->mem) {
|
||||
zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] unable to access status shared memory", fpm_status_pool);
|
||||
return 0;
|
||||
}
|
||||
if (!idle || !active || !total) {
|
||||
zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] unable to get status information : pointers are NULL", fpm_status_pool);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* one shot operation */
|
||||
status = *(struct fpm_status_s *)fpm_status_shm->mem;
|
||||
|
||||
if (idle) {
|
||||
*idle = status.idle;
|
||||
}
|
||||
if (active) {
|
||||
*active = status.active;
|
||||
}
|
||||
if (total) {
|
||||
*total = status.total;
|
||||
}
|
||||
if (pm) {
|
||||
*pm = status.pm;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static void fpm_status_handle_status_txt(struct fpm_status_s *status, char **output, char **content_type) /* {{{ */
|
||||
{
|
||||
if (!status || !output || !content_type) {
|
||||
|
@ -23,7 +23,6 @@ void fpm_status_update_activity(struct fpm_shm_s *shm, int idle, int active, int
|
||||
void fpm_status_update_accepted_conn(struct fpm_shm_s *shm, unsigned long int accepted_conn);
|
||||
void fpm_status_increment_accepted_conn(struct fpm_shm_s *shm);
|
||||
void fpm_status_set_pm(struct fpm_shm_s *shm, int pm);
|
||||
int fpm_status_get(int *idle, int *active, int *total, int *pm);
|
||||
int fpm_status_handle_status(char *uri, char *query_string, char **output, char **content_type);
|
||||
char* fpm_status_handle_ping(char *uri);
|
||||
|
||||
|
@ -84,10 +84,6 @@ static void fpm_stdio_child_said(int fd, short which, void *arg) /* {{{ */
|
||||
int in_buf = 0;
|
||||
int res;
|
||||
|
||||
#if 0
|
||||
zlog(ZLOG_STUFF, ZLOG_DEBUG, "child %d said %s", (int) child->pid, is_stdout ? "stdout" : "stderr");
|
||||
#endif
|
||||
|
||||
while (fifo_in || fifo_out) {
|
||||
if (fifo_in) {
|
||||
res = read(fd, buf + in_buf, max_buf_size - 1 - in_buf);
|
||||
@ -111,13 +107,6 @@ static void fpm_stdio_child_said(int fd, short which, void *arg) /* {{{ */
|
||||
close(child->fd_stderr);
|
||||
child->fd_stderr = -1;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (in_buf == 0 && !fpm_globals.is_child) {
|
||||
zlog(ZLOG_STUFF, ZLOG_DEBUG, "[pool %s] child %d, %s pipe is closed", child->wp->config->name,
|
||||
(int) child->pid, is_stdout ? "stdout" : "stderr");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
in_buf += res;
|
||||
|
Loading…
Reference in New Issue
Block a user