mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Make uenvarea thread exclusive
This commit is contained in:
parent
41eb4fbf86
commit
5a4742a0b4
1 changed files with 32 additions and 23 deletions
|
@ -750,10 +750,13 @@ exit_handler(void)
|
||||||
DeleteCriticalSection(&select_mutex);
|
DeleteCriticalSection(&select_mutex);
|
||||||
DeleteCriticalSection(&socklist_mutex);
|
DeleteCriticalSection(&socklist_mutex);
|
||||||
DeleteCriticalSection(&conlist_mutex);
|
DeleteCriticalSection(&conlist_mutex);
|
||||||
|
thread_exclusive(uenvarea) {
|
||||||
if (uenvarea) {
|
if (uenvarea) {
|
||||||
free(uenvarea);
|
free(uenvarea);
|
||||||
uenvarea = NULL;
|
uenvarea = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
DeleteCriticalSection(&uenvarea_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* License: Ruby's */
|
/* License: Ruby's */
|
||||||
|
@ -808,6 +811,7 @@ StartSockets(void)
|
||||||
InitializeCriticalSection(&select_mutex);
|
InitializeCriticalSection(&select_mutex);
|
||||||
InitializeCriticalSection(&socklist_mutex);
|
InitializeCriticalSection(&socklist_mutex);
|
||||||
InitializeCriticalSection(&conlist_mutex);
|
InitializeCriticalSection(&conlist_mutex);
|
||||||
|
InitializeCriticalSection(&uenvarea_mutex);
|
||||||
|
|
||||||
atexit(exit_handler);
|
atexit(exit_handler);
|
||||||
}
|
}
|
||||||
|
@ -5261,11 +5265,12 @@ w32_getenv(const char *name, UINT cp)
|
||||||
{
|
{
|
||||||
WCHAR *wenvarea, *wenv;
|
WCHAR *wenvarea, *wenv;
|
||||||
int len = strlen(name);
|
int len = strlen(name);
|
||||||
char *env;
|
char *env = NULL;
|
||||||
int wlen;
|
int wlen;
|
||||||
|
|
||||||
if (len == 0) return NULL;
|
if (len == 0) return NULL;
|
||||||
|
|
||||||
|
thread_exclusive(uenvarea) {
|
||||||
if (uenvarea) {
|
if (uenvarea) {
|
||||||
free(uenvarea);
|
free(uenvarea);
|
||||||
uenvarea = NULL;
|
uenvarea = NULL;
|
||||||
|
@ -5273,20 +5278,24 @@ w32_getenv(const char *name, UINT cp)
|
||||||
wenvarea = GetEnvironmentStringsW();
|
wenvarea = GetEnvironmentStringsW();
|
||||||
if (!wenvarea) {
|
if (!wenvarea) {
|
||||||
map_errno(GetLastError());
|
map_errno(GetLastError());
|
||||||
return NULL;
|
continue;
|
||||||
}
|
}
|
||||||
for (wenv = wenvarea, wlen = 1; *wenv; wenv += lstrlenW(wenv) + 1)
|
for (wenv = wenvarea, wlen = 1; *wenv; wenv += lstrlenW(wenv) + 1)
|
||||||
wlen += lstrlenW(wenv) + 1;
|
wlen += lstrlenW(wenv) + 1;
|
||||||
uenvarea = wstr_to_mbstr(cp, wenvarea, wlen, NULL);
|
uenvarea = wstr_to_mbstr(cp, wenvarea, wlen, NULL);
|
||||||
FreeEnvironmentStringsW(wenvarea);
|
FreeEnvironmentStringsW(wenvarea);
|
||||||
if (!uenvarea)
|
if (!uenvarea)
|
||||||
return NULL;
|
continue;
|
||||||
|
|
||||||
for (env = uenvarea; *env; env += strlen(env) + 1)
|
for (env = uenvarea; *env; env += strlen(env) + 1) {
|
||||||
if (strncasecmp(env, name, len) == 0 && *(env + len) == '=')
|
if (strncasecmp(env, name, len) == 0 && *(env + len) == '=') {
|
||||||
return env + len + 1;
|
env += len + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return env;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* License: Ruby's */
|
/* License: Ruby's */
|
||||||
|
|
Loading…
Reference in a new issue