Re: lock order reversal etc.

From: Norbert Koch <nkoch_at_demig.de>
Date: Thu, 10 Sep 2009 09:45:17 +0200
John Baldwin schrieb:
> Try this patch for this one:
>
> Index: daemon_saver.c
> ===================================================================
> --- daemon_saver.c	(revision 196974)
> +++ daemon_saver.c	(working copy)
> _at__at_ -351,11 +351,23 _at__at_
>  static int
>  daemon_init(video_adapter_t *adp)
>  {
> +	size_t hostlen;
>  
>  	mtx_lock(&prison0.pr_mtx);
> -	messagelen = strlen(prison0.pr_hostname) + 3 + strlen(ostype) + 1 + 
> -	    strlen(osrelease);
> -	message = malloc(messagelen + 1, M_DEVBUF, M_WAITOK);
> +	for (;;) {
> +		hostlen = strlen(prison0.pr_hostname);
> +		mtx_unlock(&prison0.pr_mtx);
> +	
> +		messagelen = hostlen + 3 + strlen(ostype) + 1 +
> +		    strlen(osrelease);
> +		message = malloc(messagelen + 1, M_DEVBUF, M_WAITOK);
> +		mtx_lock(&prison0.pr_mtx);
> +		if (hostlen < strlen(prison0.pr_hostname)) {
> +			free(message, M_DEVBUF);
> +			continue;
> +		}
> +		break;
> +	}
>  	sprintf(message, "%s - %s %s", prison0.pr_hostname, ostype, osrelease);
>  	mtx_unlock(&prison0.pr_mtx);
>  	blanked = 0;
>   


That works for me. Thank you.
Received on Thu Sep 10 2009 - 05:45:33 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:55 UTC