PERFORCE change 102745 for review
John Birrell
jb at FreeBSD.org
Sat Jul 29 23:41:38 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=102745
Change 102745 by jb at jb_freebsd2 on 2006/07/29 23:41:19
Now that a mutex is used instead of an sx lock, the malloc has to
be performed without wait to avoid panicing if it tries to block.
Witness points this out.
So, loop and retry in low memory situations.
Affected files ...
.. //depot/projects/dtrace/src/sys/kern/kern_environment.c#5 edit
Differences ...
==== //depot/projects/dtrace/src/sys/kern/kern_environment.c#5 (text+ko) ====
@@ -289,17 +289,18 @@
int len;
if (dynamic_kenv) {
- mtx_lock(&kenv_lock);
- cp = _getenv_dynamic(name, NULL);
- if (cp != NULL) {
- len = strlen(cp) + 1;
- ret = malloc(len, M_KENV, M_WAITOK);
- strcpy(ret, cp);
+ do {
+ mtx_lock(&kenv_lock);
+ cp = _getenv_dynamic(name, NULL);
+ if (cp != NULL) {
+ len = strlen(cp) + 1;
+ ret = malloc(len, M_KENV, M_NOWAIT);
+ if (ret != NULL)
+ strcpy(ret, cp);
+ } else
+ ret = NULL;
mtx_unlock(&kenv_lock);
- } else {
- mtx_unlock(&kenv_lock);
- ret = NULL;
- }
+ } while (cp != NULL && ret == NULL);
} else
ret = _getenv_static(name);
return (ret);
More information about the p4-projects
mailing list