[PHP-CVS] svn: /php/php-src/trunk/ Zend/zend_stack.c main/output.c main/php_output.h
dmitry Fri, 27 Aug 2010 06:09:18 + Revision: http://svn.php.net/viewvc?view=revisionrevision=302841 Log: Preallocate zend_hash instead of allocation/deallocation it on each request Changed paths: U php/php-src/trunk/Zend/zend_stack.c U php/php-src/trunk/main/output.c U php/php-src/trunk/main/php_output.h Modified: php/php-src/trunk/Zend/zend_stack.c === --- php/php-src/trunk/Zend/zend_stack.c 2010-08-27 05:15:03 UTC (rev 302840) +++ php/php-src/trunk/Zend/zend_stack.c 2010-08-27 06:09:18 UTC (rev 302841) @@ -96,8 +96,8 @@ for (i = 0; i stack-top; i++) { efree(stack-elements[i]); } - efree(stack-elements); + stack-elements = NULL; } return SUCCESS; Modified: php/php-src/trunk/main/output.c === --- php/php-src/trunk/main/output.c 2010-08-27 05:15:03 UTC (rev 302840) +++ php/php-src/trunk/main/output.c 2010-08-27 06:09:18 UTC (rev 302841) @@ -116,10 +116,7 @@ memset(output_globals, 0, sizeof(zend_output_globals)); #endif - OG(handlers) = emalloc(sizeof(zend_stack)); - if (SUCCESS != zend_stack_init(OG(handlers))) { - return FAILURE; - } + zend_stack_init(OG(handlers)); return SUCCESS; } @@ -135,14 +132,12 @@ OG(running) = NULL; /* release all output handlers */ - if (OG(handlers)) { - while (SUCCESS == zend_stack_top(OG(handlers), (void *) handler)) { + if (OG(handlers).elements) { + while (SUCCESS == zend_stack_top(OG(handlers), (void *) handler)) { php_output_handler_free(handler TSRMLS_CC); - zend_stack_del_top(OG(handlers)); + zend_stack_del_top(OG(handlers)); } - zend_stack_destroy(OG(handlers)); - efree(OG(handlers)); - OG(handlers) = NULL; + zend_stack_destroy(OG(handlers)); } } /* }}} */ @@ -218,9 +213,9 @@ php_output_context_init(context, PHP_OUTPUT_HANDLER_FLUSH TSRMLS_CC); php_output_handler_op(OG(active), context); if (context.out.data context.out.used) { - zend_stack_del_top(OG(handlers)); + zend_stack_del_top(OG(handlers)); php_output_write(context.out.data, context.out.used TSRMLS_CC); - zend_stack_push(OG(handlers), OG(active), sizeof(php_output_handler *)); + zend_stack_push(OG(handlers), OG(active), sizeof(php_output_handler *)); } php_output_context_dtor(context); return SUCCESS; @@ -264,7 +259,7 @@ if (OG(active)) { php_output_context_init(context, PHP_OUTPUT_HANDLER_CLEAN TSRMLS_CC); - zend_stack_apply_with_argument(OG(handlers), ZEND_STACK_APPLY_TOPDOWN, php_output_stack_apply_clean, context); + zend_stack_apply_with_argument(OG(handlers), ZEND_STACK_APPLY_TOPDOWN, php_output_stack_apply_clean, context); } } @@ -312,7 +307,7 @@ Get output buffering level, ie. how many output handlers the stack contains */ PHPAPI int php_output_get_level(TSRMLS_D) { - return OG(active) ? zend_stack_count(OG(handlers)) : 0; + return OG(active) ? zend_stack_count(OG(handlers)) : 0; } /* }}} */ @@ -500,7 +495,7 @@ } } /* zend_stack_push never returns SUCCESS but FAILURE or stack level */ - if (FAILURE == (handler-level = zend_stack_push(OG(handlers), handler, sizeof(php_output_handler * { + if (FAILURE == (handler-level = zend_stack_push(OG(handlers), handler, sizeof(php_output_handler * { return FAILURE; } OG(active) = handler; @@ -516,7 +511,7 @@ int i, count = php_output_get_level(TSRMLS_C); if (count) { - handlers = *(php_output_handler ***) zend_stack_base(OG(handlers)); + handlers = *(php_output_handler ***) zend_stack_base(OG(handlers)); for (i = 0; i count; ++i) { if (name_len == handlers[i]-name_len !memcmp(handlers[i]-name, name, name_len)) { @@ -977,13 +972,13 @@ * - apply op to the one active handler; note that OG(active) might be popped off the stack on a flush * - or apply op to the handler stack */ - if (OG(active) (obh_cnt = zend_stack_count(OG(handlers { + if (OG(active) (obh_cnt = zend_stack_count(OG(handlers { context.in.data = (char *) str; context.in.used = len; if (obh_cnt 1) { - zend_stack_apply_with_argument(OG(handlers),
[PHP-CVS] svn: /php/php-src/trunk/sapi/cgi/ fastcgi.c
dmitry Fri, 27 Aug 2010 08:50:32 + Revision: http://svn.php.net/viewvc?view=revisionrevision=302845 Log: Don't check FCGI_WEB_SERVER_ADDRS for UNIX sockets Changed paths: U php/php-src/trunk/sapi/cgi/fastcgi.c Modified: php/php-src/trunk/sapi/cgi/fastcgi.c === --- php/php-src/trunk/sapi/cgi/fastcgi.c2010-08-27 08:49:21 UTC (rev 302844) +++ php/php-src/trunk/sapi/cgi/fastcgi.c2010-08-27 08:50:32 UTC (rev 302845) @@ -1157,17 +1157,19 @@ FCGI_LOCK(req-listen_socket); req-fd = accept(listen_socket, (struct sockaddr *)sa, len); FCGI_UNLOCK(req-listen_socket); - if (req-fd = 0 allowed_clients) { + if (req-fd = 0 + allowed_clients + ((struct sockaddr *)sa)-sa_family == AF_INET) { int n = 0; int allowed = 0; - while (allowed_clients[n] != INADDR_NONE) { - if (allowed_clients[n] == sa.sa_inet.sin_addr.s_addr) { - allowed = 1; - break; - } - n++; + while (allowed_clients[n] != INADDR_NONE) { + if (allowed_clients[n] == sa.sa_inet.sin_addr.s_addr) { + allowed = 1; + break; } + n++; + } if (!allowed) { fprintf(stderr, Connection from disallowed IP address '%s' is dropped.\n, inet_ntoa(sa.sa_inet.sin_addr)); closesocket(req-fd); -- 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/TSRM/tsrm_virtual_cwd.c trunk/TSRM/tsrm_virtual_cwd.c
pajoye Fri, 27 Aug 2010 10:09:52 + Revision: http://svn.php.net/viewvc?view=revisionrevision=302847 Log: - WS Changed paths: U php/php-src/branches/PHP_5_3/TSRM/tsrm_virtual_cwd.c U php/php-src/trunk/TSRM/tsrm_virtual_cwd.c Modified: php/php-src/branches/PHP_5_3/TSRM/tsrm_virtual_cwd.c === --- php/php-src/branches/PHP_5_3/TSRM/tsrm_virtual_cwd.c 2010-08-27 09:07:36 UTC (rev 302846) +++ php/php-src/branches/PHP_5_3/TSRM/tsrm_virtual_cwd.c 2010-08-27 10:09:52 UTC (rev 302847) @@ -245,7 +245,7 @@ } if (tmp != cur_path) { free(tmp); - } + } } buf-st_uid = buf-st_gid = buf-st_ino = 0; buf-st_mode = (data.dwFileAttributes FILE_ATTRIBUTE_DIRECTORY) ? (S_IFDIR|S_IEXEC|(S_IEXEC3)|(S_IEXEC6)) : S_IFREG; @@ -255,9 +255,9 @@ if (path[len-4] == '.') { if (_memicmp(path+len-3, exe, 3) == 0 || - _memicmp(path+len-3, com, 3) == 0 || - _memicmp(path+len-3, bat, 3) == 0 || - _memicmp(path+len-3, cmd, 3) == 0) { +_memicmp(path+len-3, com, 3) == 0 || +_memicmp(path+len-3, bat, 3) == 0 || +_memicmp(path+len-3, cmd, 3) == 0) { buf-st_mode |= (S_IEXEC|(S_IEXEC3)|(S_IEXEC6)); } } @@ -493,7 +493,7 @@ while (*bucket != NULL) { if (key == (*bucket)-key path_len == (*bucket)-path_len - memcmp(path, (*bucket)-path, path_len) == 0) { + memcmp(path, (*bucket)-path, path_len) == 0) { realpath_cache_bucket *r = *bucket; *bucket = (*bucket)-next; CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r-path_len + 1 + r-realpath_len + 1; @@ -512,7 +512,7 @@ int same = 1; if (realpath_len != path_len || - memcmp(path, realpath, path_len) != 0) { + memcmp(path, realpath, path_len) != 0) { size += realpath_len + 1; same = 0; } @@ -570,7 +570,7 @@ CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r-path_len + 1 + r-realpath_len + 1; free(r); } else if (key == (*bucket)-key path_len == (*bucket)-path_len - memcmp(path, (*bucket)-path, path_len) == 0) { + memcmp(path, (*bucket)-path, path_len) == 0) { return *bucket; } else { bucket = (*bucket)-next; @@ -582,7 +582,7 @@ CWD_API realpath_cache_bucket* realpath_cache_lookup(const char *path, int path_len, time_t t TSRMLS_DC) /* {{{ */ { -return realpath_cache_find(path, path_len, t TSRMLS_CC); + return realpath_cache_find(path, path_len, t TSRMLS_CC); } /* }}} */ @@ -650,14 +650,14 @@ if (!start) { /* leading '..' must not be removed in case of relative path */ if (j == 0 path[0] == '.' path[1] == '.' - IS_SLASH(path[2])) { + IS_SLASH(path[2])) { path[3] = '.'; path[4] = '.'; path[5] = DEFAULT_SLASH; j = 5; } else if (j 0 - path[j+1] == '.' path[j+2] == '.' - IS_SLASH(path[j+3])) { + path[j+1] == '.' path[j+2] == '.' + IS_SLASH(path[j+3])) { j += 4; path[j++] = '.'; path[j++] = '.'; @@ -683,18 +683,18 @@ if (!*t) { *t = time(0); } - if ((bucket = realpath_cache_find(path, len, *t TSRMLS_CC)) != NULL) { - if (is_dir !bucket-is_dir) { + if ((bucket = realpath_cache_find(path, len, *t TSRMLS_CC)) != NULL) { +if (is_dir !bucket-is_dir) { /* not a directory */ return -1; - } else { - if (link_is_dir) { - *link_is_dir = bucket-is_dir; - } +} else { + if (link_is_dir) { + *link_is_dir = bucket-is_dir; + } memcpy(path, bucket-realpath, bucket-realpath_len + 1); -return bucket-realpath_len; + return bucket-realpath_len; } - } + } } #ifdef TSRM_WIN32 @@ -903,7 +903,7 @@ if (save S_ISLNK(st.st_mode)) { if (++(*ll) LINK_MAX || (j = readlink(tmp, path, MAXPATHLEN)) 0) { - /* too many links or broken symlinks */ +/* too many links or broken symlinks */ tsrm_free_alloca(tmp, use_heap); return -1; } @@ -915,10 +915,10 @@ return -1; } } else { - if (i + j = MAXPATHLEN-1) { +if (i + j = MAXPATHLEN-1) { tsrm_free_alloca(tmp, use_heap); return -1; /* buffer overflow */ - } +} memmove(path+i, path, j+1); memcpy(path, tmp, i-1); path[i-1] = DEFAULT_SLASH; @@ -1042,14 +1042,14 @@ state_cwd_length++; } while (state-cwd[state_cwd_length] - !IS_SLASH(state-cwd[state_cwd_length])) { + !IS_SLASH(state-cwd[state_cwd_length])) { state_cwd_length++; } while (IS_SLASH(state-cwd[state_cwd_length])) { state_cwd_length++; } while (state-cwd[state_cwd_length] - !IS_SLASH(state-cwd[state_cwd_length])) { + !IS_SLASH(state-cwd[state_cwd_length])) { state_cwd_length++; } } @@ -1078,7 +1078,7 @@ #ifdef TSRM_WIN32 if (memchr(resolved_path, '*', path_length) || -
[PHP-CVS] svn: /php/php-src/ branches/PHP_5_3/ext/session/session.c trunk/ext/session/session.c
iliaaFri, 27 Aug 2010 19:43:08 + Revision: http://svn.php.net/viewvc?view=revisionrevision=302851 Log: Fixed a compiler warning Changed paths: U php/php-src/branches/PHP_5_3/ext/session/session.c U php/php-src/trunk/ext/session/session.c Modified: php/php-src/branches/PHP_5_3/ext/session/session.c === --- php/php-src/branches/PHP_5_3/ext/session/session.c 2010-08-27 12:45:36 UTC (rev 302850) +++ php/php-src/branches/PHP_5_3/ext/session/session.c 2010-08-27 19:43:08 UTC (rev 302851) @@ -403,9 +403,8 @@ efree(buf); if (PS(entropy_length) 0) { - unsigned char rbuf[2048]; - #ifdef PHP_WIN32 + unsigned char rbuf[2048]; size_t toread = PS(entropy_length); if (php_win32_get_random_bytes(rbuf, (size_t) toread) == SUCCESS){ Modified: php/php-src/trunk/ext/session/session.c === --- php/php-src/trunk/ext/session/session.c 2010-08-27 12:45:36 UTC (rev 302850) +++ php/php-src/trunk/ext/session/session.c 2010-08-27 19:43:08 UTC (rev 302851) @@ -329,9 +329,8 @@ efree(buf); if (PS(entropy_length) 0) { - unsigned char rbuf[2048]; - #ifdef PHP_WIN32 + unsigned char rbuf[2048]; size_t toread = PS(entropy_length); if (php_win32_get_random_bytes(rbuf, (size_t) toread) == SUCCESS){ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php