Re: [INTERNALS-WIN] end of support for VC6 in trunk

[email protected] (Pierre Joye)
Newsgroups php.internals.win
Message-ID <[email protected]>
hi William,

On Tue, Sep 22, 2009 at 11:07 PM, William A. Rowe, Jr.
<[email protected]> wrote:
> William A. Rowe, Jr. wrote:
>> Pierre Joye wrote:
>>>> Since the whole mod_php SetIni is not threadsafe,
>>> What are you refering to here? :)
>>
>> Just looking at sapi/apache_hooks, it
>> seems that ini processing changed significantly between 5.2 and 5.3.
>
> I'm evaluating this, it may take a couple days to get my head around
> the code since I had a couple other urgent items on my plate right now.
> If I see any issues, I'll sound off this coming week.

I may have found something that could cause issues in TS SAPI, inside
the php.ini management code.

We were initializing a static point to the GetSystemWindowsDirectory
function, without worrying about concurrent access (init time). As
this function is available now in our minimal windows versions, I
simply use GetSystemWindowsDirectory directly instead of using
LoadLibrary and GetProcAddress.

Patch attached.

Cheers,
-- 
Pierre

http://blog.thepimp.net | http://www.libgd.org
ini_ts_fix_no_loadlib.txt (text/plain, 1.9 KB)
Index: main/php_ini.c
===================================================================
--- main/php_ini.c	(revision 288722)
+++ main/php_ini.c	(working copy)
@@ -488,33 +488,20 @@
 			}
 			strlcat(php_ini_search_path, default_location, search_path_size);
 		}
-		efree(default_location);
 
-		{
-			/* For people running under terminal services, GetWindowsDirectory will
-			 * return their personal Windows directory, so lets add the system
-			 * windows directory too */
-			typedef UINT (WINAPI *get_system_windows_directory_func)(char *buffer, UINT size);
-			static get_system_windows_directory_func get_system_windows_directory = NULL;
-			HMODULE kern;
-
-			if (get_system_windows_directory == NULL) {
-				kern = LoadLibrary("kernel32.dll");
-				if (kern) {
-					get_system_windows_directory = (get_system_windows_directory_func)GetProcAddress(kern, "GetSystemWindowsDirectoryA");
-				}
+		/* For people running under terminal services, GetWindowsDirectory will
+		 * return their personal Windows directory, so lets add the system
+		 * windows directory too */
+		default_location = (char *) emalloc(MAXPATHLEN + 1);
+		
+		if (0 < GetSystemWindowsDirectory(default_location, MAXPATHLEN)) {
+			if (*php_ini_search_path) {
+				strlcat(php_ini_search_path, paths_separator, search_path_size);
 			}
-			if (get_system_windows_directory != NULL) {
-				default_location = (char *) emalloc(MAXPATHLEN + 1);
-				if (0 < get_system_windows_directory(default_location, MAXPATHLEN)) {
-					if (*php_ini_search_path) {
-						strlcat(php_ini_search_path, paths_separator, search_path_size);
-					}
-					strlcat(php_ini_search_path, default_location, search_path_size);
-				}
-				efree(default_location);
-			}
+			strlcat(php_ini_search_path, default_location, search_path_size);
 		}
+		efree(default_location);
+
 #else
 		default_location = PHP_CONFIG_FILE_PATH;
 		if (*php_ini_search_path) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.