Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 29 Jul 2006 23:41:37 GMT
From:      John Birrell <jb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 102745 for review
Message-ID:  <200607292341.k6TNfbFN068833@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=102745

Change 102745 by jb@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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200607292341.k6TNfbFN068833>