Index | Thread | Search

From:
Claudio Jeker <cjeker@diehard.n-r-g.com>
Subject:
Re: relayd: log errors before dropping a control connection
To:
Rafael Sadowski <rafael@sizeofvoid.org>
Cc:
tech@openbsd.org
Date:
Sun, 2 Aug 2026 22:45:59 +0200

Download raw body.

Thread
On Sun, Aug 02, 2026 at 09:32:20PM +0200, Rafael Sadowski wrote:
> The control dispatcher silently closed the client connection when
> imsgbuf_write or imsgbuf_get failed. A relayctl user then saw the
> command break with no hint why, and nothing in the server log if we want
> to debug it.
> 
> OK?
 
I don't think this is very helpful. It does not add any actionable value
to the debug output.

imsgbuf_get() should simply never fail. It only fails if imsgbuf_read very
much fucked up big time and returned an imsg that is shorter than the imsg
header. imsgbuf_get() returns the failure since it can not do anything
else (apart from ignoring errors which probably sucks more).

imsgbuf_write() mostly fails if the connection is closed. This is normally
when the client (relayctl) is killed or exits. I doubt you gain much from
such an error. Now doing something similar in the ctl program is a
different story.

> diff --git a/control.c b/control.c
> index fb64608..5cff2c8 100644
> --- a/control.c
> +++ b/control.c
> @@ -250,6 +250,8 @@ control_dispatch_imsg(int fd, short event, void *arg)
>  
>  	if (event & EV_WRITE) {
>  		if (imsgbuf_write(&c->iev.ibuf) == -1) {
> +			log_debug("%s: imsgbuf_write: %s", __func__,
> +			    strerror(errno));
>  			control_close(fd, cs);
>  			return;
>  		}
> @@ -257,6 +259,7 @@ control_dispatch_imsg(int fd, short event, void *arg)
>  
>  	for (;;) {
>  		if ((n = imsgbuf_get(&c->iev.ibuf, &imsg)) == -1) {
> +			log_debug("%s: imsgbuf_get", __func__);
>  			control_close(fd, cs);
>  			return;
>  		}
> 

-- 
:wq Claudio