From 120079666f1d63ad69ae55eebc1896d53d6480c0 Mon Sep 17 00:00:00 2001 From: Jim Date: Thu, 27 Feb 2020 11:53:07 -0500 Subject: [PATCH] devpnc.h: expand listen backlog for big rings, use TCP_DEFER_ACCEPT so Linux holds onto connections until the uid is sent. Otherwise, the delay between making a connection and sending the uid will be larger than MAXACCCEPTTIME, causing large rings to fail --- devpnc.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/devpnc.h b/devpnc.h index 34db687..74bbc7c 100644 --- a/devpnc.h +++ b/devpnc.h @@ -295,7 +295,7 @@ static struct { /* node info for each node in my network */ #define PNCCSNONE 0 /* not configured in ring.cfg */ #define PNCCSDISC 1 /* not connected */ -#define PNCCSCONN 2 /* connected */ +#define PNCCSCONN 2 /* connecting */ #define PNCCSAUTH 3 /* unique ID / password sent */ /* xmit/recv buffer states and buffers. These must be static because @@ -983,10 +983,22 @@ int devpnc (int class, int func, int device) { perror("bind: unable to bind for PNC"); fatal(NULL); } - if (listen(pncfd, 10)) { + if (listen(pncfd, MAXNODEID)) { perror("listen failed for PNC"); fatal(NULL); } + + /* a uid is always sent after a connect, so don't bother with the + accept until the uid is received. This is Linux-specific and + can be disabled, though that may cause problems for rings where + the max node id > MAXACCEPTTIME because of connect delays */ + + optval = MAXNODEID; + if (setsockopt(pncfd, IPPROTO_TCP, TCP_DEFER_ACCEPT, &optval, sizeof(optval))) { + perror("setsockopt TCP_DEFER_ACCEPT failed for PNC"); + fatal(NULL); + } + TRACE(T_RIO, "PNC configured\n"); devpoll[device] = PNCPOLL*gvp->instpermsec;