git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] daemon: use timeout for uninterruptible poll

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Apr 13, 2018, 12:36 UTC
Message-ID
<nycvar.QRO.7.76.6.1804131433250.65@ZVAVAG-6OXH6DA.rhebcr.pbec.zvpebfbsg.pbz>
In-Reply-To
<20180412210757.7792-2-kgybels@infogroep.be>
Hi Kim,
On Thu, 12 Apr 2018, Kim Gybels wrote:
> The poll provided in compat/poll.c is not interrupted by receiving
> SIGCHLD. Use a timeout for cleaning up dead children in a timely manner.
Maybe say "When using this poll emulation, use a timeout ..."?
Show 9 quoted lines
> diff --git a/daemon.c b/daemon.c
> index fe833ea7de..6dc95c1b2f 100644
> --- a/daemon.c
> +++ b/daemon.c
> @@ -1147,6 +1147,7 @@ static int service_loop(struct socketlist *socklist)
>  {
>  	struct pollfd *pfd;
>  	int i;
> +	int poll_timeout = -1;
Just reuse the line above:
	int poll_timeout = -1, i;
Show 13 quoted lines
> @@ -1161,8 +1162,13 @@ static int service_loop(struct socketlist *socklist)
>  		int i;
>  
>  		check_dead_children();
> -
> -		if (poll(pfd, socklist->nr, -1) < 0) {
> +#ifdef NO_POLL
> +		poll_timeout = live_children ? 100 : -1;
> +#endif
> +		int ret = poll(pfd, socklist->nr, poll_timeout);
> +		if  (ret == 0) {
> +			continue;
> +		} else if (ret < 0) {

I would find it a bit easier on the eyes if this did not use curlies, and dropped the unnecessary `else` (`continue` will take care of that):

		if (!ret)
			continue;
		if (ret < 0)
			[...]
Thank you for working on this!

Ciao, Dscho

Previous: Kim GybelsNext: Kim Gybels
Message 3 of 15 in “Fix early EOF with GfW daemon”
  1. 0/2 Fix early EOF with GfW daemonKim Gybels, Apr 12, 2018
  2. 1/2 daemon: use timeout for uninterruptible pollKim Gybels, Apr 12, 2018
  3. Johannes SchindelinApr 13, 2018
  4. Kim GybelsApr 15, 2018
  5. Johannes SchindelinApr 18, 2018
  6. Junio C HamanoApr 15, 2018
  7. Junio C HamanoApr 15, 2018
  8. Johannes SchindelinApr 18, 2018
  9. Junio C HamanoApr 18, 2018
  10. Kim GybelsApr 19, 2018
  11. Junio C HamanoApr 19, 2018
  12. 2/2 daemon: graceful shutdown of client connectionKim Gybels, Apr 12, 2018
  13. Johannes SchindelinApr 13, 2018
  14. Kim GybelsApr 15, 2018
  15. Johannes SchindelinApr 18, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.