[lxc-devel] Bugfix for lxc-stop --nowait in 4.0 and master branches

Christian Brauner christian.brauner at ubuntu.com
Tue Jun 23 09:15:47 UTC 2020


On Tue, Jun 23, 2020 at 10:47:44AM +0200, Robert Vogelgesang wrote:
> Hello @all,
> 
> in 4.0 and master branches, the lxc-stop command is currently a
> no-op when using the --nowait flag.  Patch against current 4.0
> branch attached, should apply to master, too.
> 
> Best regards,

Hey Robert,

Thanks for the patch.
I've picked your changes up and created a PR with you as author and with
your SOB added here:
https://github.com/lxc/lxc/pull/3456

can you quickly give your ack or nack on this?

Thanks!
Christian

> 
> Robert
> 

> diff -up lxc-stable-4.0/src/lxc/lxccontainer.c.nowait lxc-stable-4.0/src/lxc/lxccontainer.c
> --- lxc-stable-4.0/src/lxc/lxccontainer.c.nowait	2020-06-15 18:52:01.000000000 +0200
> +++ lxc-stable-4.0/src/lxc/lxccontainer.c	2020-06-16 15:52:20.782513170 +0200
> @@ -2096,41 +2096,41 @@ static bool do_lxcapi_shutdown(struct lx
>  
>  		if (ret < MAX_STATE)
>  			return false;
> +	}
>  
> -		if (pidfd >= 0) {
> -			struct pollfd pidfd_poll = {
> -			    .events = POLLIN,
> -			    .fd = pidfd,
> -			};
> -
> -			killret = lxc_raw_pidfd_send_signal(pidfd, haltsignal,
> -							    NULL, 0);
> -			if (killret < 0)
> -				return log_warn(false, "Failed to send signal %d to pidfd %d",
> -						haltsignal, pidfd);
> -
> -			TRACE("Sent signal %d to pidfd %d", haltsignal, pidfd);
> -
> -			/*
> -			 * No need for going through all of the state server
> -			 * complications anymore. We can just poll on pidfds. :)
> -			 */
> -
> -			if (timeout != 0) {
> -				ret = poll(&pidfd_poll, 1, timeout * 1000);
> -				if (ret < 0 || !(pidfd_poll.revents & POLLIN))
> -					return false;
> -
> -				TRACE("Pidfd polling detected container exit");
> -			}
> -		} else {
> -			killret = kill(pid, haltsignal);
> -			if (killret < 0)
> -				return log_warn(false, "Failed to send signal %d to pid %d",
> -						haltsignal, pid);
> +	if (pidfd >= 0) {
> +		struct pollfd pidfd_poll = {
> +		    .events = POLLIN,
> +		    .fd = pidfd,
> +		};
> +
> +		killret = lxc_raw_pidfd_send_signal(pidfd, haltsignal,
> +						    NULL, 0);
> +		if (killret < 0)
> +			return log_warn(false, "Failed to send signal %d to pidfd %d",
> +					haltsignal, pidfd);
> +
> +		TRACE("Sent signal %d to pidfd %d", haltsignal, pidfd);
> +
> +		/*
> +		 * No need for going through all of the state server
> +		 * complications anymore. We can just poll on pidfds. :)
> +		 */
> +
> +		if (timeout != 0) {
> +			ret = poll(&pidfd_poll, 1, timeout * 1000);
> +			if (ret < 0 || !(pidfd_poll.revents & POLLIN))
> +				return false;
>  
> -			TRACE("Sent signal %d to pid %d", haltsignal, pid);
> +			TRACE("Pidfd polling detected container exit");
>  		}
> +	} else {
> +		killret = kill(pid, haltsignal);
> +		if (killret < 0)
> +			return log_warn(false, "Failed to send signal %d to pid %d",
> +					haltsignal, pid);
> +
> +		TRACE("Sent signal %d to pid %d", haltsignal, pid);
>  	}
>  
>  	if (timeout == 0)

> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel



More information about the lxc-devel mailing list