[PHP-CVS] svn: /php/php-src/branches/PHP_5_3/sapi/fpm/fpm/ fastcgi.c fastcgi.h fpm_main.c

2011-10-08 Thread Jérôme Loyet
fat  Sat, 08 Oct 2011 13:52:27 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=317897

Log:
- backparted from 5.4 branch (remove is_fastcgi because FPM is always fastcgi)

Changed paths:
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fastcgi.c
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fastcgi.h
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_main.c

Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fastcgi.c
===
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fastcgi.c	2011-10-08 13:47:52 UTC (rev 317896)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fastcgi.c	2011-10-08 13:52:27 UTC (rev 317897)
@@ -142,7 +142,6 @@
 static HashTable fcgi_mgmt_vars;

 static int is_initialized = 0;
-static int is_fastcgi = 0;
 static int in_shutdown = 0;
 static in_addr_t *allowed_clients = NULL;

@@ -204,9 +203,7 @@
 			return 0;
 		}
 # endif
-		if ((GetStdHandle(STD_OUTPUT_HANDLE) == INVALID_HANDLE_VALUE) 
-		(GetStdHandle(STD_ERROR_HANDLE)  == INVALID_HANDLE_VALUE) 
-		(GetStdHandle(STD_INPUT_HANDLE)  != INVALID_HANDLE_VALUE)) {
+		{
 			char *str;
 			DWORD pipe_mode = PIPE_READMODE_BYTE | PIPE_WAIT;
 			HANDLE pipe = GetStdHandle(STD_INPUT_HANDLE);
@@ -225,38 +222,16 @@
 			if (str != NULL) {
 fcgi_accept_mutex = (HANDLE) atoi(str);
 			}
-			return is_fastcgi = 1;
-		} else {
-			return is_fastcgi = 0;
+			return 1;
 		}
 #else
-		errno = 0;
-		if (getpeername(0, (struct sockaddr *)sa, len) != 0  errno == ENOTCONN) {
-			fcgi_setup_signals();
-			return is_fastcgi = 1;
-		} else {
-			return is_fastcgi = 0;
-		}
+		fcgi_setup_signals();
+		return 1;
 #endif
 	}
-	return is_fastcgi;
+	return 1;
 }

-
-int fcgi_is_fastcgi(void)
-{
-	if (!is_initialized) {
-		return fcgi_init();
-	} else {
-		return is_fastcgi;
-	}
-}
-
-void fcgi_set_is_fastcgi(int new_value)
-{
-	is_fastcgi = new_value;
-}
-
 void fcgi_set_in_shutdown(int new_value)
 {
 	in_shutdown = new_value;
@@ -267,7 +242,6 @@
 	if (is_initialized) {
 		zend_hash_destroy(fcgi_mgmt_vars);
 	}
-	is_fastcgi = 0;
 	if (allowed_clients) {
 		free(allowed_clients);
 	}

Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fastcgi.h
===
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fastcgi.h	2011-10-08 13:47:52 UTC (rev 317896)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fastcgi.h	2011-10-08 13:52:27 UTC (rev 317897)
@@ -114,12 +114,10 @@

 int fcgi_init(void);
 void fcgi_shutdown(void);
-int fcgi_is_fastcgi(void);
 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);

-void fcgi_set_is_fastcgi(int new_value);
 void fcgi_set_in_shutdown(int);
 void fcgi_set_allowed_clients(char *);
 void fcgi_close(fcgi_request *req, int force, int destroy);

Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_main.c
===
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_main.c	2011-10-08 13:47:52 UTC (rev 317896)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_main.c	2011-10-08 13:52:27 UTC (rev 317897)
@@ -106,6 +106,7 @@
 #include fpm/fpm_conf.h
 #include fpm/fpm_php.h
 #include fpm/fpm_log.h
+#include fpm/zlog.h

 #ifndef PHP_WIN32
 /* XXX this will need to change later when threaded fastcgi is implemented.  shane */
@@ -124,6 +125,7 @@
 #endif

 static int request_body_fd;
+static int fpm_is_running = 0;

 static char *sapi_cgibin_getenv(char *name, size_t name_len TSRMLS_DC);
 static void fastcgi_ini_parser(zval *arg1, zval *arg2, zval *arg3, int callback_type, void *arg TSRMLS_DC);
@@ -260,34 +262,33 @@
 	zend_llist_destroy(sorted_exts);
 }

-#ifndef STDOUT_FILENO
-#define STDOUT_FILENO 1
+#ifndef STDOUT_FILENO
+#define STDOUT_FILENO 1
 #endif

 static inline size_t sapi_cgibin_single_write(const char *str, uint str_length TSRMLS_DC)
 {
-#ifdef PHP_WRITE_STDOUT
-	long ret;
-#else
 	size_t ret;
-#endif

-	if (fcgi_is_fastcgi()) {
+	/* sapi has started which means everyhting must be send through fcgi */
+	if (fpm_is_running) {
 		fcgi_request *request = (fcgi_request*) SG(server_context);
-		long ret = fcgi_write(request, FCGI_STDOUT, str, str_length);
+		ret = fcgi_write(request, FCGI_STDOUT, str, str_length);
 		if (ret = 0) {
 			return 0;
 		}
 		return ret;
 	}

-#ifdef PHP_WRITE_STDOUT
-	ret = write(STDOUT_FILENO, str, str_length);
-	if (ret = 0) return 0;
+	/* sapi has not started, output to stdout instead of fcgi */
+#ifdef PHP_WRITE_STDOUT
+	ret = write(STDOUT_FILENO, str, str_length);
+	if (ret = 0) {
+		return 0;
+	}
 	return ret;
 #else
-	ret = fwrite(str, 1, MIN(str_length, 16384), stdout);
-	return ret;
+	return fwrite(str, 1, MIN(str_length, 16384), stdout);
 #endif
 }

@@ -313,17 +314,20 @@

 static void sapi_cgibin_flush(void *server_context)
 {
-	if (fcgi_is_fastcgi()) 

[PHP-CVS] svn: /php/php-src/branches/PHP_5_3/sapi/fpm/fpm/ fastcgi.c

2011-10-08 Thread Jérôme Loyet
fat  Sat, 08 Oct 2011 13:53:49 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=317898

Log:
remove unused variable

Changed paths:
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fastcgi.c

Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fastcgi.c
===
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fastcgi.c 2011-10-08 13:52:27 UTC 
(rev 317897)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fastcgi.c 2011-10-08 13:53:49 UTC 
(rev 317898)
@@ -185,10 +185,6 @@
 int fcgi_init(void)
 {
if (!is_initialized) {
-#ifndef _WIN32
-   sa_t sa;
-   socklen_t len = sizeof(sa);
-#endif
zend_hash_init(fcgi_mgmt_vars, 0, NULL, fcgi_free_mgmt_var_cb, 
1);
fcgi_set_mgmt_var(FCGI_MPXS_CONNS, sizeof(FCGI_MPXS_CONNS) 
- 1, 0, sizeof(0)-1);


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/branches/PHP_5_3/sapi/fpm/fpm/ fastcgi.c fpm.c fpm_children.c fpm_cleanup.c fpm_conf.c fpm_conf.h fpm_env.c fpm_events.c fpm_log.c fpm_main.c fpm_php.c fpm_php_trace.c fpm_

2011-10-08 Thread Jérôme Loyet
fat  Sat, 08 Oct 2011 14:04:09 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=317901

Log:
- Backported from 5.4 branch:
  * enhanced log messages
  * code cosmetic

Changed paths:
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fastcgi.c
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm.c
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_children.c
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_cleanup.c
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_conf.c
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_conf.h
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_env.c
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_events.c
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_log.c
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_main.c
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_php.c
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_php_trace.c
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_process_ctl.c
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_request.c
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_shm.c
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_signals.c
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_sockets.c
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_status.c
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_stdio.c
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_trace_mach.c
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_trace_pread.c
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_trace_ptrace.c
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_unix.c
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_worker_pool.c

Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fastcgi.c
===
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fastcgi.c	2011-10-08 14:00:07 UTC (rev 317900)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fastcgi.c	2011-10-08 14:04:09 UTC (rev 317901)
@@ -29,9 +29,9 @@
 #include limits.h

 #include php_config.h
-#include fpm/fpm.h
-#include fpm/fpm_request.h
-#include fpm/zlog.h
+#include fpm.h
+#include fpm_request.h
+#include zlog.h

 #ifdef _WIN32

@@ -268,7 +268,7 @@
 			}
 			allowed_clients[n] = inet_addr(cur);
 			if (allowed_clients[n] == INADDR_NONE) {
-fprintf(stderr, Wrong IP address '%s' in FCGI_WEB_SERVER_ADDRS or listen.allowed_clients\n, cur);
+zlog(ZLOG_ERROR, Wrong IP address '%s' in listen.allowed_clients, cur);
 			}
 			n++;
 			cur = end;
@@ -816,7 +816,7 @@
 			n++;
 		}
 		if (!allowed) {
-			fprintf(stderr, Connection from disallowed IP address '%s' is dropped.\n, inet_ntoa(sa.sa_inet.sin_addr));
+			zlog(ZLOG_ERROR, Connection disallowed: IP address '%s' has been dropped., inet_ntoa(sa.sa_inet.sin_addr));
 			closesocket(req-fd);
 			req-fd = -1;
 			continue;
@@ -872,7 +872,7 @@
 		}
 		fcgi_close(req, 1, 0);
 	} else {
-		fprintf(stderr, Too many open file descriptors. FD_SETSIZE limit exceeded.);
+		zlog(ZLOG_ERROR, Too many open file descriptors. FD_SETSIZE limit exceeded.);
 		fcgi_close(req, 1, 0);
 	}
 #endif

Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm.c
===
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm.c	2011-10-08 14:00:07 UTC (rev 317900)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm.c	2011-10-08 14:04:09 UTC (rev 317901)
@@ -65,11 +65,13 @@
 		if (fpm_globals.test_successful) {
 			exit(0);
 		} else {
+			zlog(ZLOG_ERROR, FPM initialization failed);
 			return -1;
 		}
 	}

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


Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_children.c
===
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_children.c	2011-10-08 14:00:07 UTC (rev 317900)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_children.c	2011-10-08 14:04:09 UTC (rev 317901)
@@ -147,13 +147,13 @@
 {
 	fpm_globals.max_requests = wp-config-pm_max_requests;

-	if (0  fpm_stdio_init_child(wp) ||
-		0  fpm_log_init_child(wp) ||
-		0  fpm_status_init_child(wp) ||
-		0  fpm_unix_init_child(wp) ||
-		0  fpm_signals_init_child() ||
-		0  fpm_env_init_child(wp) ||
-		0  fpm_php_init_child(wp)) {
+	if (0  fpm_stdio_init_child(wp)  ||
+	0  fpm_log_init_child(wp)||
+	0  fpm_status_init_child(wp) ||
+	0  fpm_unix_init_child(wp)   ||
+	0  fpm_signals_init_child()  ||
+	0  fpm_env_init_child(wp)||
+	0  fpm_php_init_child(wp)) {

 		zlog(ZLOG_ERROR, [pool %s] child failed to initialize, wp-config-name);
 		exit(255);
@@ -292,7 +292,7 @@
 }
 			}
 		} else {
-			zlog(ZLOG_ALERT, oops, unknown child (%d) exited %s, pid, buf);
+			zlog(ZLOG_ALERT, oops, unknown child (%d) exited %s. Please open a bug 

[PHP-CVS] svn: /php/php-src/branches/PHP_5_3/sapi/fpm/fpm/ fastcgi.c

2011-07-18 Thread Jérôme Loyet
fat  Mon, 18 Jul 2011 20:59:18 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=313403

Log:
remove forgotten debug log

Changed paths:
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fastcgi.c

Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fastcgi.c
===
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fastcgi.c 2011-07-18 20:38:57 UTC 
(rev 313402)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fastcgi.c 2011-07-18 20:59:18 UTC 
(rev 313403)
@@ -508,7 +508,6 @@
ret = 0;
break;
}
-   zlog(ZLOG_DEBUG, %s=%s, tmp, s);
zend_hash_update(req-env, tmp, eff_name_len+1, s, 
sizeof(char*), NULL);
p += name_len + val_len;
}

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/sapi/fpm/fpm/fastcgi.c branches/PHP_5_3/sapi/fpm/fpm/fpm_config.h branches/PHP_5_3/sapi/fpm/fpm/fpm_main.c branches/PHP_5_4/sapi/fpm/fpm/fastcgi.c branche

2011-07-17 Thread Jérôme Loyet
fat  Sun, 17 Jul 2011 23:33:22 +

Revision: http://svn.php.net/viewvc?view=revisionrevision=313347

Log:
- get rid of FPM_AUTOCONFIG_H which has never existed since FPM integration 
into core

Changed paths:
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fastcgi.c
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_config.h
U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_main.c
U   php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fastcgi.c
U   php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_config.h
U   php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_main.c
U   php/php-src/trunk/sapi/fpm/fpm/fastcgi.c
U   php/php-src/trunk/sapi/fpm/fpm/fpm_config.h
U   php/php-src/trunk/sapi/fpm/fpm/fpm_main.c

Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fastcgi.c
===
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fastcgi.c 2011-07-17 23:26:02 UTC 
(rev 313346)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fastcgi.c 2011-07-17 23:33:22 UTC 
(rev 313347)
@@ -28,13 +28,10 @@
 #include errno.h
 #include limits.h

-#ifdef FPM_AUTOCONFIG_H
-#include fpm_autoconfig.h
-#else
 #include php_config.h
-#endif
 #include fpm/fpm.h
 #include fpm/fpm_request.h
+#include fpm/zlog.h

 #ifdef _WIN32

@@ -511,6 +508,7 @@
ret = 0;
break;
}
+   zlog(ZLOG_DEBUG, %s=%s, tmp, s);
zend_hash_update(req-env, tmp, eff_name_len+1, s, 
sizeof(char*), NULL);
p += name_len + val_len;
}

Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_config.h
===
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_config.h  2011-07-17 
23:26:02 UTC (rev 313346)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_config.h  2011-07-17 
23:33:22 UTC (rev 313347)
@@ -3,10 +3,6 @@

 #include php_config.h

-#ifdef FPM_AUTOCONFIG_H
-# include fpm_autoconfig.h
-#endif
-
 /* Solaris does not have it */
 #ifndef INADDR_NONE
 # define INADDR_NONE (-1)

Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_main.c
===
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_main.c2011-07-17 
23:26:02 UTC (rev 313346)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_main.c2011-07-17 
23:33:22 UTC (rev 313347)
@@ -99,11 +99,7 @@

 #include fastcgi.h

-#ifdef FPM_AUTOCONFIG_H
-#include fpm_autoconfig.h
-#else
 #include php_config.h
-#endif
 #include fpm/fpm.h
 #include fpm/fpm_request.h
 #include fpm/fpm_status.h

Modified: php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fastcgi.c
===
--- php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fastcgi.c 2011-07-17 23:26:02 UTC 
(rev 313346)
+++ php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fastcgi.c 2011-07-17 23:33:22 UTC 
(rev 313347)
@@ -28,11 +28,7 @@
 #include errno.h
 #include limits.h

-#ifdef FPM_AUTOCONFIG_H
-#include fpm_autoconfig.h
-#else
 #include php_config.h
-#endif
 #include fpm/fpm.h
 #include fpm/fpm_request.h


Modified: php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_config.h
===
--- php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_config.h  2011-07-17 
23:26:02 UTC (rev 313346)
+++ php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_config.h  2011-07-17 
23:33:22 UTC (rev 313347)
@@ -3,10 +3,6 @@

 #include php_config.h

-#ifdef FPM_AUTOCONFIG_H
-# include fpm_autoconfig.h
-#endif
-
 /* Solaris does not have it */
 #ifndef INADDR_NONE
 # define INADDR_NONE (-1)

Modified: php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_main.c
===
--- php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_main.c2011-07-17 
23:26:02 UTC (rev 313346)
+++ php/php-src/branches/PHP_5_4/sapi/fpm/fpm/fpm_main.c2011-07-17 
23:33:22 UTC (rev 313347)
@@ -99,11 +99,7 @@

 #include fastcgi.h

-#ifdef FPM_AUTOCONFIG_H
-#include fpm_autoconfig.h
-#else
 #include php_config.h
-#endif
 #include fpm/fpm.h
 #include fpm/fpm_request.h
 #include fpm/fpm_status.h

Modified: php/php-src/trunk/sapi/fpm/fpm/fastcgi.c
===
--- php/php-src/trunk/sapi/fpm/fpm/fastcgi.c2011-07-17 23:26:02 UTC (rev 
313346)
+++ php/php-src/trunk/sapi/fpm/fpm/fastcgi.c2011-07-17 23:33:22 UTC (rev 
313347)
@@ -28,11 +28,7 @@
 #include errno.h
 #include limits.h

-#ifdef FPM_AUTOCONFIG_H
-#include fpm_autoconfig.h
-#else
 #include php_config.h
-#endif
 #include fpm/fpm.h
 #include fpm/fpm_request.h


Modified: php/php-src/trunk/sapi/fpm/fpm/fpm_config.h
===
--- php/php-src/trunk/sapi/fpm/fpm/fpm_config.h 2011-07-17 23:26:02 UTC (rev 
313346)
+++