fat                                      Thu, 11 Nov 2010 01:01:56 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=305265

Log:
- syntax and minor optimizations

Changed paths:
    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_request.c
    U   php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_sockets.c
    U   php/php-src/trunk/sapi/fpm/fpm/fpm_conf.c
    U   php/php-src/trunk/sapi/fpm/fpm/fpm_request.c
    U   php/php-src/trunk/sapi/fpm/fpm/fpm_sockets.c

Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_conf.c
===================================================================
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_conf.c	2010-11-11 00:43:18 UTC (rev 305264)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_conf.c	2010-11-11 01:01:56 UTC (rev 305265)
@@ -52,50 +52,53 @@
 static char *fpm_conf_set_rlimit_core(zval *value, void **config, intptr_t offset);
 static char *fpm_conf_set_pm(zval *value, void **config, intptr_t offset);

-struct fpm_global_config_s fpm_global_config = { 0, 0, 0, 1, NULL, NULL};
+struct fpm_global_config_s fpm_global_config = { .daemonize = 1 };
 static struct fpm_worker_pool_s *current_wp = NULL;
 static int ini_recursion = 0;
 static char *ini_filename = NULL;
 static int ini_lineno = 0;
 static char *ini_include = NULL;

+#define GO(field) offsetof(struct fpm_global_config_s, field)
+#define WPO(field) offsetof(struct fpm_worker_pool_config_s, field)
+
 static struct ini_value_parser_s ini_fpm_global_options[] = {
-	{ "emergency_restart_threshold", 	&fpm_conf_set_integer, 	offsetof(struct fpm_global_config_s, emergency_restart_threshold) },
-	{ "emergency_restart_interval",		&fpm_conf_set_time,			offsetof(struct fpm_global_config_s, emergency_restart_interval) },
-	{ "process_control_timeout",			&fpm_conf_set_time,			offsetof(struct fpm_global_config_s, process_control_timeout) },
-	{ "daemonize",										&fpm_conf_set_boolean,	offsetof(struct fpm_global_config_s, daemonize) },
-	{ "pid",													&fpm_conf_set_string,		offsetof(struct fpm_global_config_s, pid_file) },
-	{ "error_log",										&fpm_conf_set_string,		offsetof(struct fpm_global_config_s, error_log) },
+	{ "emergency_restart_threshold", 	&fpm_conf_set_integer, 	GO(emergency_restart_threshold) },
+	{ "emergency_restart_interval",		&fpm_conf_set_time,			GO(emergency_restart_interval) },
+	{ "process_control_timeout",			&fpm_conf_set_time,			GO(process_control_timeout) },
+	{ "daemonize",										&fpm_conf_set_boolean,	GO(daemonize) },
+	{ "pid",													&fpm_conf_set_string,		GO(pid_file) },
+	{ "error_log",										&fpm_conf_set_string,		GO(error_log) },
 	{ "log_level",										&fpm_conf_set_log_level,	0 },
 	{ 0, 0, 0 }
 };

 static struct ini_value_parser_s ini_fpm_pool_options[] = {
-	{ "user", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, user) },
-	{ "group", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, group) },
-	{ "chroot", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, chroot) },
-	{ "chdir", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, chdir) },
-	{ "request_terminate_timeout", &fpm_conf_set_time, offsetof(struct fpm_worker_pool_config_s, request_terminate_timeout) },
-	{ "request_slowlog_timeout", &fpm_conf_set_time, offsetof(struct fpm_worker_pool_config_s, request_slowlog_timeout) },
-	{ "slowlog", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, slowlog) },
-	{ "rlimit_files", &fpm_conf_set_integer, offsetof(struct fpm_worker_pool_config_s, rlimit_files) },
-	{ "rlimit_core", &fpm_conf_set_rlimit_core, offsetof(struct fpm_worker_pool_config_s, rlimit_core) },
-	{ "catch_workers_output", &fpm_conf_set_boolean, offsetof(struct fpm_worker_pool_config_s, catch_workers_output) },
-	{ "listen", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, listen_address) },
-	{ "listen.owner", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, listen_owner) },
-	{ "listen.group", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, listen_group) },
-	{ "listen.mode", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, listen_mode) },
-	{ "listen.backlog", &fpm_conf_set_integer, offsetof(struct fpm_worker_pool_config_s, listen_backlog) },
-	{ "listen.allowed_clients", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, listen_allowed_clients) },
-	{ "pm", &fpm_conf_set_pm, offsetof(struct fpm_worker_pool_config_s, pm) },
-	{ "pm.max_requests", &fpm_conf_set_integer, offsetof(struct fpm_worker_pool_config_s, pm_max_requests) },
-	{ "pm.max_children", &fpm_conf_set_integer, offsetof(struct fpm_worker_pool_config_s, pm_max_children) },
-	{ "pm.start_servers", &fpm_conf_set_integer, offsetof(struct fpm_worker_pool_config_s, pm_start_servers) },
-	{ "pm.min_spare_servers", &fpm_conf_set_integer, offsetof(struct fpm_worker_pool_config_s, pm_min_spare_servers) },
-	{ "pm.max_spare_servers", &fpm_conf_set_integer, offsetof(struct fpm_worker_pool_config_s, pm_max_spare_servers) },
-	{ "pm.status_path", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, pm_status_path) },
-	{ "ping.path", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, ping_path) },
-	{ "ping.response", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, ping_response) },
+	{ "user", &fpm_conf_set_string, WPO(user) },
+	{ "group", &fpm_conf_set_string, WPO(group) },
+	{ "chroot", &fpm_conf_set_string, WPO(chroot) },
+	{ "chdir", &fpm_conf_set_string, WPO(chdir) },
+	{ "request_terminate_timeout", &fpm_conf_set_time, WPO(request_terminate_timeout) },
+	{ "request_slowlog_timeout", &fpm_conf_set_time, WPO(request_slowlog_timeout) },
+	{ "slowlog", &fpm_conf_set_string, WPO(slowlog) },
+	{ "rlimit_files", &fpm_conf_set_integer, WPO(rlimit_files) },
+	{ "rlimit_core", &fpm_conf_set_rlimit_core, WPO(rlimit_core) },
+	{ "catch_workers_output", &fpm_conf_set_boolean, WPO(catch_workers_output) },
+	{ "listen", &fpm_conf_set_string, WPO(listen_address) },
+	{ "listen.owner", &fpm_conf_set_string, WPO(listen_owner) },
+	{ "listen.group", &fpm_conf_set_string, WPO(listen_group) },
+	{ "listen.mode", &fpm_conf_set_string, WPO(listen_mode) },
+	{ "listen.backlog", &fpm_conf_set_integer, WPO(listen_backlog) },
+	{ "listen.allowed_clients", &fpm_conf_set_string, WPO(listen_allowed_clients) },
+	{ "pm", &fpm_conf_set_pm, WPO(pm) },
+	{ "pm.max_requests", &fpm_conf_set_integer, WPO(pm_max_requests) },
+	{ "pm.max_children", &fpm_conf_set_integer, WPO(pm_max_children) },
+	{ "pm.start_servers", &fpm_conf_set_integer, WPO(pm_start_servers) },
+	{ "pm.min_spare_servers", &fpm_conf_set_integer, WPO(pm_min_spare_servers) },
+	{ "pm.max_spare_servers", &fpm_conf_set_integer, WPO(pm_max_spare_servers) },
+	{ "pm.status_path", &fpm_conf_set_string, WPO(pm_status_path) },
+	{ "ping.path", &fpm_conf_set_string, WPO(ping_path) },
+	{ "ping.response", &fpm_conf_set_string, WPO(ping_response) },
 	{ 0, 0, 0 }
 };

@@ -146,17 +149,17 @@

 static char *fpm_conf_set_integer(zval *value, void **config, intptr_t offset) /* {{{ */
 {
-	int i;
 	char *val = Z_STRVAL_P(value);
+	char *p;

-	for (i=0; i<strlen(val); i++) {
-		if ( i == 0 && val[i] == '-' ) continue;
-		if (val[i] < '0' || val[i] > '9') {
-			return("is not a valid number (greater or equal than zero");
+	for(p=val; *p; p++) {
+		if ( p == val && *p == '-' ) continue;
+		if (*p < '0' || *p > '9') {
+			return "is not a valid number (greater or equal than zero)";
 		}
 	}
 	* (int *) ((char *) *config + offset) = atoi(val);
-	return(NULL);
+	return NULL;
 }
 /* }}} */

@@ -288,7 +291,7 @@

 	if (convert_to_bool) {
 		char *err = fpm_conf_set_boolean(value, &subconf, 0);
-		if (err) return(err);
+		if (err) return err;
 		kv->value = strdup(b ? "On" : "Off");
 	} else {
 		kv->value = strdup(Z_STRVAL_P(value));
@@ -870,7 +873,7 @@
 			*error = 1;
 			return;
 		}
-		config = (char *)current_wp->config + offsetof(struct fpm_worker_pool_config_s, env);
+		config = (char *)current_wp->config + WPO(env);
 		err = fpm_conf_set_array(key, value, &config, 0);

 	} else if (!strcmp("php_value", Z_STRVAL_P(name))) {
@@ -879,7 +882,7 @@
 			*error = 1;
 			return;
 		}
-		config = (char *)current_wp->config + offsetof(struct fpm_worker_pool_config_s, php_values);
+		config = (char *)current_wp->config + WPO(php_values);
 		err = fpm_conf_set_array(key, value, &config, 0);

 	} else if (!strcmp("php_admin_value", Z_STRVAL_P(name))) {
@@ -888,15 +891,15 @@
 			*error = 1;
 			return;
 		}
-		config = (char *)current_wp->config + offsetof(struct fpm_worker_pool_config_s, php_admin_values);
+		config = (char *)current_wp->config + WPO(php_admin_values);
 		err = fpm_conf_set_array(key, value, &config, 0);

 	} else if (!strcmp("php_flag", Z_STRVAL_P(name))) {
-		config = (char *)current_wp->config + offsetof(struct fpm_worker_pool_config_s, php_values);
+		config = (char *)current_wp->config + WPO(php_values);
 		err = fpm_conf_set_array(key, value, &config, 1);

 	} else if (!strcmp("php_admin_flag", Z_STRVAL_P(name))) {
-		config = (char *)current_wp->config + offsetof(struct fpm_worker_pool_config_s, php_admin_values);
+		config = (char *)current_wp->config + WPO(php_admin_values);
 		err = fpm_conf_set_array(key, value, &config, 1);

 	} else {

Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_request.c
===================================================================
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_request.c	2010-11-11 00:43:18 UTC (rev 305264)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_request.c	2010-11-11 01:01:56 UTC (rev 305265)
@@ -154,16 +154,11 @@

 int fpm_request_is_idle(struct fpm_child_s *child) /* {{{ */
 {
-	struct fpm_shm_slot_s *slot;
-	struct fpm_shm_slot_s slot_c;
+	struct fpm_shm_slot_s slot;

-	slot = fpm_shm_slot(child);
-	if (!fpm_shm_slots_acquire(slot, 1)) {
-		return -1;
-	}
+	/* no need in atomicity here */
+	slot = *fpm_shm_slot(child);

-	slot_c = *slot;
-	fpm_shm_slots_release(slot);
-	return(!slot_c.accepted.tv_sec && !slot_c.accepted.tv_usec ? 1 : 0);
+	return slot.request_stage == FPM_REQUEST_ACCEPTING;
 }
 /* }}} */

Modified: php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_sockets.c
===================================================================
--- php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_sockets.c	2010-11-11 00:43:18 UTC (rev 305264)
+++ php/php-src/branches/PHP_5_3/sapi/fpm/fpm/fpm_sockets.c	2010-11-11 01:01:56 UTC (rev 305265)
@@ -65,7 +65,7 @@

 static void fpm_sockets_cleanup(int which, void *arg) /* {{{ */
 {
-	int i;
+	unsigned i;
 	char *env_value = 0;
 	int p = 0;
 	struct listening_socket_s *ls = sockets_list.data;
@@ -124,7 +124,7 @@

 		case FPM_GET_USE_SOCKET :
 		{
-			int i;
+			unsigned i;
 			struct listening_socket_s *ls = sockets_list.data;

 			for (i = 0; i < sockets_list.used; i++, ls++) {
@@ -179,17 +179,22 @@

 	if (wp->listen_address_domain == FPM_AF_UNIX) {
 		unlink( ((struct sockaddr_un *) sa)->sun_path);
+		saved_umask = umask(0777 ^ wp->socket_mode);
 	}

-	saved_umask = umask(0777 ^ wp->socket_mode);
-
 	if (0 > bind(sock, sa, socklen)) {
 		zlog(ZLOG_STUFF, ZLOG_SYSERROR, "bind() for address '%s' failed", wp->config->listen_address);
+		if (wp->listen_address_domain == FPM_AF_UNIX) {
+			umask(saved_umask);
+		}
 		return -1;
 	}

 	if (wp->listen_address_domain == FPM_AF_UNIX) {
 		char *path = ((struct sockaddr_un *) sa)->sun_path;
+
+		umask(saved_umask);
+
 		if (wp->socket_uid != -1 || wp->socket_gid != -1) {
 			if (0 > chown(path, wp->socket_uid, wp->socket_gid)) {
 				zlog(ZLOG_STUFF, ZLOG_SYSERROR, "chown() for address '%s' failed", wp->config->listen_address);
@@ -197,7 +202,6 @@
 			}
 		}
 	}
-	umask(saved_umask);

 	if (0 > listen(sock, wp->config->listen_backlog)) {
 		zlog(ZLOG_STUFF, ZLOG_SYSERROR, "listen() for address '%s' failed", wp->config->listen_address);
@@ -290,7 +294,7 @@

 int fpm_sockets_init_main() /* {{{ */
 {
-	int i;
+	unsigned i;
 	struct fpm_worker_pool_s *wp;
 	char *inherited = getenv("FPM_SOCKETS");
 	struct listening_socket_s *ls;

Modified: php/php-src/trunk/sapi/fpm/fpm/fpm_conf.c
===================================================================
--- php/php-src/trunk/sapi/fpm/fpm/fpm_conf.c	2010-11-11 00:43:18 UTC (rev 305264)
+++ php/php-src/trunk/sapi/fpm/fpm/fpm_conf.c	2010-11-11 01:01:56 UTC (rev 305265)
@@ -52,50 +52,53 @@
 static char *fpm_conf_set_rlimit_core(zval *value, void **config, intptr_t offset);
 static char *fpm_conf_set_pm(zval *value, void **config, intptr_t offset);

-struct fpm_global_config_s fpm_global_config = { 0, 0, 0, 1, NULL, NULL};
+struct fpm_global_config_s fpm_global_config = { .daemonize = 1 };
 static struct fpm_worker_pool_s *current_wp = NULL;
 static int ini_recursion = 0;
 static char *ini_filename = NULL;
 static int ini_lineno = 0;
 static char *ini_include = NULL;

+#define GO(field) offsetof(struct fpm_global_config_s, field)
+#define WPO(field) offsetof(struct fpm_worker_pool_config_s, field)
+
 static struct ini_value_parser_s ini_fpm_global_options[] = {
-	{ "emergency_restart_threshold", 	&fpm_conf_set_integer, 	offsetof(struct fpm_global_config_s, emergency_restart_threshold) },
-	{ "emergency_restart_interval",		&fpm_conf_set_time,			offsetof(struct fpm_global_config_s, emergency_restart_interval) },
-	{ "process_control_timeout",			&fpm_conf_set_time,			offsetof(struct fpm_global_config_s, process_control_timeout) },
-	{ "daemonize",										&fpm_conf_set_boolean,	offsetof(struct fpm_global_config_s, daemonize) },
-	{ "pid",													&fpm_conf_set_string,		offsetof(struct fpm_global_config_s, pid_file) },
-	{ "error_log",										&fpm_conf_set_string,		offsetof(struct fpm_global_config_s, error_log) },
+	{ "emergency_restart_threshold", 	&fpm_conf_set_integer, 	GO(emergency_restart_threshold) },
+	{ "emergency_restart_interval",		&fpm_conf_set_time,			GO(emergency_restart_interval) },
+	{ "process_control_timeout",			&fpm_conf_set_time,			GO(process_control_timeout) },
+	{ "daemonize",										&fpm_conf_set_boolean,	GO(daemonize) },
+	{ "pid",													&fpm_conf_set_string,		GO(pid_file) },
+	{ "error_log",										&fpm_conf_set_string,		GO(error_log) },
 	{ "log_level",										&fpm_conf_set_log_level,	0 },
 	{ 0, 0, 0 }
 };

 static struct ini_value_parser_s ini_fpm_pool_options[] = {
-	{ "user", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, user) },
-	{ "group", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, group) },
-	{ "chroot", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, chroot) },
-	{ "chdir", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, chdir) },
-	{ "request_terminate_timeout", &fpm_conf_set_time, offsetof(struct fpm_worker_pool_config_s, request_terminate_timeout) },
-	{ "request_slowlog_timeout", &fpm_conf_set_time, offsetof(struct fpm_worker_pool_config_s, request_slowlog_timeout) },
-	{ "slowlog", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, slowlog) },
-	{ "rlimit_files", &fpm_conf_set_integer, offsetof(struct fpm_worker_pool_config_s, rlimit_files) },
-	{ "rlimit_core", &fpm_conf_set_rlimit_core, offsetof(struct fpm_worker_pool_config_s, rlimit_core) },
-	{ "catch_workers_output", &fpm_conf_set_boolean, offsetof(struct fpm_worker_pool_config_s, catch_workers_output) },
-	{ "listen", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, listen_address) },
-	{ "listen.owner", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, listen_owner) },
-	{ "listen.group", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, listen_group) },
-	{ "listen.mode", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, listen_mode) },
-	{ "listen.backlog", &fpm_conf_set_integer, offsetof(struct fpm_worker_pool_config_s, listen_backlog) },
-	{ "listen.allowed_clients", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, listen_allowed_clients) },
-	{ "pm", &fpm_conf_set_pm, offsetof(struct fpm_worker_pool_config_s, pm) },
-	{ "pm.max_requests", &fpm_conf_set_integer, offsetof(struct fpm_worker_pool_config_s, pm_max_requests) },
-	{ "pm.max_children", &fpm_conf_set_integer, offsetof(struct fpm_worker_pool_config_s, pm_max_children) },
-	{ "pm.start_servers", &fpm_conf_set_integer, offsetof(struct fpm_worker_pool_config_s, pm_start_servers) },
-	{ "pm.min_spare_servers", &fpm_conf_set_integer, offsetof(struct fpm_worker_pool_config_s, pm_min_spare_servers) },
-	{ "pm.max_spare_servers", &fpm_conf_set_integer, offsetof(struct fpm_worker_pool_config_s, pm_max_spare_servers) },
-	{ "pm.status_path", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, pm_status_path) },
-	{ "ping.path", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, ping_path) },
-	{ "ping.response", &fpm_conf_set_string, offsetof(struct fpm_worker_pool_config_s, ping_response) },
+	{ "user", &fpm_conf_set_string, WPO(user) },
+	{ "group", &fpm_conf_set_string, WPO(group) },
+	{ "chroot", &fpm_conf_set_string, WPO(chroot) },
+	{ "chdir", &fpm_conf_set_string, WPO(chdir) },
+	{ "request_terminate_timeout", &fpm_conf_set_time, WPO(request_terminate_timeout) },
+	{ "request_slowlog_timeout", &fpm_conf_set_time, WPO(request_slowlog_timeout) },
+	{ "slowlog", &fpm_conf_set_string, WPO(slowlog) },
+	{ "rlimit_files", &fpm_conf_set_integer, WPO(rlimit_files) },
+	{ "rlimit_core", &fpm_conf_set_rlimit_core, WPO(rlimit_core) },
+	{ "catch_workers_output", &fpm_conf_set_boolean, WPO(catch_workers_output) },
+	{ "listen", &fpm_conf_set_string, WPO(listen_address) },
+	{ "listen.owner", &fpm_conf_set_string, WPO(listen_owner) },
+	{ "listen.group", &fpm_conf_set_string, WPO(listen_group) },
+	{ "listen.mode", &fpm_conf_set_string, WPO(listen_mode) },
+	{ "listen.backlog", &fpm_conf_set_integer, WPO(listen_backlog) },
+	{ "listen.allowed_clients", &fpm_conf_set_string, WPO(listen_allowed_clients) },
+	{ "pm", &fpm_conf_set_pm, WPO(pm) },
+	{ "pm.max_requests", &fpm_conf_set_integer, WPO(pm_max_requests) },
+	{ "pm.max_children", &fpm_conf_set_integer, WPO(pm_max_children) },
+	{ "pm.start_servers", &fpm_conf_set_integer, WPO(pm_start_servers) },
+	{ "pm.min_spare_servers", &fpm_conf_set_integer, WPO(pm_min_spare_servers) },
+	{ "pm.max_spare_servers", &fpm_conf_set_integer, WPO(pm_max_spare_servers) },
+	{ "pm.status_path", &fpm_conf_set_string, WPO(pm_status_path) },
+	{ "ping.path", &fpm_conf_set_string, WPO(ping_path) },
+	{ "ping.response", &fpm_conf_set_string, WPO(ping_response) },
 	{ 0, 0, 0 }
 };

@@ -146,17 +149,17 @@

 static char *fpm_conf_set_integer(zval *value, void **config, intptr_t offset) /* {{{ */
 {
-	int i;
 	char *val = Z_STRVAL_P(value);
+	char *p;

-	for (i=0; i<strlen(val); i++) {
-		if ( i == 0 && val[i] == '-' ) continue;
-		if (val[i] < '0' || val[i] > '9') {
-			return("is not a valid number (greater or equal than zero");
+	for(p=val; *p; p++) {
+		if ( p == val && *p == '-' ) continue;
+		if (*p < '0' || *p > '9') {
+			return "is not a valid number (greater or equal than zero)";
 		}
 	}
 	* (int *) ((char *) *config + offset) = atoi(val);
-	return(NULL);
+	return NULL;
 }
 /* }}} */

@@ -288,7 +291,7 @@

 	if (convert_to_bool) {
 		char *err = fpm_conf_set_boolean(value, &subconf, 0);
-		if (err) return(err);
+		if (err) return err;
 		kv->value = strdup(b ? "On" : "Off");
 	} else {
 		kv->value = strdup(Z_STRVAL_P(value));
@@ -870,7 +873,7 @@
 			*error = 1;
 			return;
 		}
-		config = (char *)current_wp->config + offsetof(struct fpm_worker_pool_config_s, env);
+		config = (char *)current_wp->config + WPO(env);
 		err = fpm_conf_set_array(key, value, &config, 0);

 	} else if (!strcmp("php_value", Z_STRVAL_P(name))) {
@@ -879,7 +882,7 @@
 			*error = 1;
 			return;
 		}
-		config = (char *)current_wp->config + offsetof(struct fpm_worker_pool_config_s, php_values);
+		config = (char *)current_wp->config + WPO(php_values);
 		err = fpm_conf_set_array(key, value, &config, 0);

 	} else if (!strcmp("php_admin_value", Z_STRVAL_P(name))) {
@@ -888,15 +891,15 @@
 			*error = 1;
 			return;
 		}
-		config = (char *)current_wp->config + offsetof(struct fpm_worker_pool_config_s, php_admin_values);
+		config = (char *)current_wp->config + WPO(php_admin_values);
 		err = fpm_conf_set_array(key, value, &config, 0);

 	} else if (!strcmp("php_flag", Z_STRVAL_P(name))) {
-		config = (char *)current_wp->config + offsetof(struct fpm_worker_pool_config_s, php_values);
+		config = (char *)current_wp->config + WPO(php_values);
 		err = fpm_conf_set_array(key, value, &config, 1);

 	} else if (!strcmp("php_admin_flag", Z_STRVAL_P(name))) {
-		config = (char *)current_wp->config + offsetof(struct fpm_worker_pool_config_s, php_admin_values);
+		config = (char *)current_wp->config + WPO(php_admin_values);
 		err = fpm_conf_set_array(key, value, &config, 1);

 	} else {

Modified: php/php-src/trunk/sapi/fpm/fpm/fpm_request.c
===================================================================
--- php/php-src/trunk/sapi/fpm/fpm/fpm_request.c	2010-11-11 00:43:18 UTC (rev 305264)
+++ php/php-src/trunk/sapi/fpm/fpm/fpm_request.c	2010-11-11 01:01:56 UTC (rev 305265)
@@ -154,16 +154,11 @@

 int fpm_request_is_idle(struct fpm_child_s *child) /* {{{ */
 {
-	struct fpm_shm_slot_s *slot;
-	struct fpm_shm_slot_s slot_c;
+	struct fpm_shm_slot_s slot;

-	slot = fpm_shm_slot(child);
-	if (!fpm_shm_slots_acquire(slot, 1)) {
-		return -1;
-	}
+	/* no need in atomicity here */
+	slot = *fpm_shm_slot(child);

-	slot_c = *slot;
-	fpm_shm_slots_release(slot);
-	return(!slot_c.accepted.tv_sec && !slot_c.accepted.tv_usec ? 1 : 0);
+	return slot.request_stage == FPM_REQUEST_ACCEPTING;
 }
 /* }}} */

Modified: php/php-src/trunk/sapi/fpm/fpm/fpm_sockets.c
===================================================================
--- php/php-src/trunk/sapi/fpm/fpm/fpm_sockets.c	2010-11-11 00:43:18 UTC (rev 305264)
+++ php/php-src/trunk/sapi/fpm/fpm/fpm_sockets.c	2010-11-11 01:01:56 UTC (rev 305265)
@@ -65,7 +65,7 @@

 static void fpm_sockets_cleanup(int which, void *arg) /* {{{ */
 {
-	int i;
+	unsigned i;
 	char *env_value = 0;
 	int p = 0;
 	struct listening_socket_s *ls = sockets_list.data;
@@ -124,7 +124,7 @@

 		case FPM_GET_USE_SOCKET :
 		{
-			int i;
+			unsigned i;
 			struct listening_socket_s *ls = sockets_list.data;

 			for (i = 0; i < sockets_list.used; i++, ls++) {
@@ -179,17 +179,22 @@

 	if (wp->listen_address_domain == FPM_AF_UNIX) {
 		unlink( ((struct sockaddr_un *) sa)->sun_path);
+		saved_umask = umask(0777 ^ wp->socket_mode);
 	}

-	saved_umask = umask(0777 ^ wp->socket_mode);
-
 	if (0 > bind(sock, sa, socklen)) {
 		zlog(ZLOG_STUFF, ZLOG_SYSERROR, "bind() for address '%s' failed", wp->config->listen_address);
+		if (wp->listen_address_domain == FPM_AF_UNIX) {
+			umask(saved_umask);
+		}
 		return -1;
 	}

 	if (wp->listen_address_domain == FPM_AF_UNIX) {
 		char *path = ((struct sockaddr_un *) sa)->sun_path;
+
+		umask(saved_umask);
+
 		if (wp->socket_uid != -1 || wp->socket_gid != -1) {
 			if (0 > chown(path, wp->socket_uid, wp->socket_gid)) {
 				zlog(ZLOG_STUFF, ZLOG_SYSERROR, "chown() for address '%s' failed", wp->config->listen_address);
@@ -197,7 +202,6 @@
 			}
 		}
 	}
-	umask(saved_umask);

 	if (0 > listen(sock, wp->config->listen_backlog)) {
 		zlog(ZLOG_STUFF, ZLOG_SYSERROR, "listen() for address '%s' failed", wp->config->listen_address);
@@ -290,7 +294,7 @@

 int fpm_sockets_init_main() /* {{{ */
 {
-	int i;
+	unsigned i;
 	struct fpm_worker_pool_s *wp;
 	char *inherited = getenv("FPM_SOCKETS");
 	struct listening_socket_s *ls;
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to