On Wed, Mar 25, 2015 at 11:37:51PM -0400, Yonas Yanfa wrote:
> On 15-03-24 03:26 AM, Claudio Jeker wrote:
> > On Mon, Mar 23, 2015 at 11:54:41PM -0400, Yonas Yanfa wrote:
> >> Hi,
> >>
> >> I'm running relayd/OpenBSD 5.6-stable on a KVM virtual machine. relayd
> >> always crashes within a few hours of restarting it, but works properly
> >> before that.
> >
> > I guess you are talking about reloading relayd (as in relayctl reload)...
> >
> 
> Killing all relayd processes and then running relayd.
> 
> 
> >> When relayd stops working, sometimes the relayd process is up but
> `relayctl
> >> show summary` says that /var/run/relayd.sock doesn't exist. Other times
> none
> >> of the relayd processes are running.
> >>
> >
> > I hit similar issues and came up with the following diff against -current.
> > It may apply to 5.6 but did not test that at all. I'm not 100% sure about
> > the ca.c change since OpenSSL is a black box.
> >
> 
> Thanks for the patches.
> 
> Before I try to apply the patches, I think the issue might be caused by
> having too many CLOSE_WAIT connections. I seem to have 2,236 CLOSE_WAIT
> connections:
> 
> 
> $ netstat -n|grep CLOSE_WAIT|wc -l
>     2236
> 
> And relayd seems to have 501 active connections:
> 
> relay www, session 1806 (501 active), 0, xxx.xxx.xxx.xxx -> :0, hard timeout
> 
> 
> How can I get relayd to close these connections?
> 

Took some time to hunt down the cause of these CLOSE_WAIT sessions and
caused some sleepless nights since our loadbalancer was hitting them as
well. I think the following diff should solve the issue without causing
further regressions.

The problematic connections are HTTP session that are closed before the
backend is started. In that case we can not wait for the backend.

-- 
:wq Claudio

Index: relay.c
===================================================================
RCS file: /cvs/src/usr.sbin/relayd/relay.c,v
retrieving revision 1.191
diff -u -p -r1.191 relay.c
--- relay.c     6 Feb 2015 01:37:11 -0000       1.191
+++ relay.c     25 Apr 2015 13:11:33 -0000
@@ -988,7 +988,7 @@ relay_error(struct bufferevent *bev, sho
                        dst = EVBUFFER_OUTPUT(cre->dst->bev);
                        if (EVBUFFER_LENGTH(dst))
                                return;
-               } else
+               } else if (cre->output != NULL && EVBUFFER_LENGTH(cre->output))
                        return;
 
                relay_close(con, "done");

Reply via email to