Commits

Mechiel Lukkien committed 5787fb5 Draft

when mlock() fails (as it does on openbsd/i386 pre-4.5), don't error out, but warn (only once). idea from cinap, during iwp9.

Comments (0)

Files changed (1)

 {
 	void *p, *alignedp;
 	long pagesize;
+	static int mlockwarn = 0;
 
 	pagesize = sysconf(_SC_PAGESIZE);
 	if(pagesize == -1)
 	if(p == nil)
 		return nil;
 	alignedp = (void*)(((uintptr_t)p + pagesize - 1)&~(pagesize-1));
-	if(mlock(alignedp, len) != 0) {
+	if(mlock(alignedp, len) != 0 && mlockwarn == 0) {
 		syslog(LOG_WARNING, "mlock failed on memory of len=%lu", len);
-		free(p);
-		return nil;
+		mlockwarn++;
 	}
 	debug(LOG_DEBUG, "lockedmalloc, %lu bytes allocated", len);
 	return alignedp;