halfsies working remoteIdleTimeout, beta-ish

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Here are some patches to get remoteIdleTimeout working.  Don't bother
with them unless you are using multiple servers, as nntpc just blocks
on user input and will never notice the timeout with only one server.  So
at the moment it will only timeout the "other" servers, assuming
the user is still active.

You'd be interested in this, say, if your upstream charges you for
incoming connections and you want to timeout remote connections 
quickly.

I'm working on non-blocking I/O for the user reads, but don't have
time to finish it today.  This will make it work properly even with
one server.

Consider this "beta" quality only.  I'm not quite sure I am resetting the
idle time in enough places (or maybe too many places).

(the blank lines are other, local changes)

diff -c -r nntpcache-2.3.3b2/src/nntpcache.c nntpcache-2.3.3b2-local/src/nntpcache.c
***************
*** 825,830 ****
--- 836,852 ----
  		list->article_timeout = article_timeout;
  		list->overview_fmt_timeout = con->overviewFmtTimeout;
  		list->fd=-1;
+ 		list->last_active_time = 0;		/* -an */
+ 		list->group = NULL;			/* -an */
+ 		list->group_actual = NULL;		/* -an */
+
+
+
+
+
+
+
+
  	}
  	if (ferror(fp))
  	{
***************
*** 902,914 ****
  	time_t ti = time(NULL);
  	for (p=ServerList; p; p=p->next)
  		if (p->last_active_time &&
! 		    ti - p->last_active_time > con->remoteIdleTimeout)
  			detachServer(p);
  }
  
  static void emit_banner(bool post_ok)
  {
  	emitf ("%d %s NNTPcache server V%s [see www.nntpcache.org] (c) 1996-1998 Julian Assange <proff@iq.org> %s ready (posting %s).\r\n", post_ok? NNTP_POSTOK_VAL: NNTP_NOPOSTOK_VAL, Host, VERSION, __DATE__, post_ok? "ok": "not permitted");
  }
  
  static bool relay_unknown (char *buf)
--- 924,942 ----
  	time_t ti = time(NULL);
  	for (p=ServerList; p; p=p->next)
  		if (p->last_active_time &&
! 		    ti - p->last_active_time > con->remoteIdleTimeout) {
! 			logd (("dropping idle server %s after %d seconds idle (limit %d)", p->host, ti - p->last_active_time, con->remoteIdleTimeout));
  			detachServer(p);
+ 		    }
  }
  
  static void emit_banner(bool post_ok)
  {
+
  	emitf ("%d %s NNTPcache server V%s [see www.nntpcache.org] (c) 1996-1998 Julian Assange <proff@iq.org> %s ready (posting %s).\r\n", post_ok? NNTP_POSTOK_VAL: NNTP_NOPOSTOK_VAL, Host, VERSION, __DATE__, post_ok? "ok": "not permitted");
+
+
+
  }
  
  static bool relay_unknown (char *buf)
diff -c -r nntpcache-2.3.3b2/src/sockets.c nntpcache-2.3.3b2-local/src/sockets.c
*** nntpcache-2.3.3b2/src/sockets.c	Sun Aug 02 13:35:03 1998
--- nntpcache-2.3.3b2-local/src/sockets.c	Tue Aug 04 13:49:05 1998
***************
*** 95,100 ****
--- 95,104 ----
  	{
  		fclose(scfg->fh);
  		scfg->fd = -1;
+ #ifdef 0
+ 		/* don't need to do either of these here, both
+ 		   will get free'd before they are re-used. Also scfg->group
+ 		   needs to be set for the re-connect to work after a timeout.  -an  */
  		if (scfg->group_actual)
  		{
  			free(scfg->group_actual);
***************
*** 105,110 ****
--- 109,115 ----
  			free(scfg->group);
  			scfg->group= NULL;
  		}
+ #endif
  	}
  }
  
***************
*** 114,119 ****
--- 119,125 ----
  	char buf[MAX_LINE];
  	time_t now;
  	assert(scfg);
+ 	scfg->last_active_time = time(NULL);		/* -an */
  	/*
  	 * see if we are already attached
  	 */
***************
*** 250,255 ****
--- 279,285 ----
  			return 0;
  	}
  	buf[cc] = '\0';
+ 	scfg->last_active_time = time(NULL);		/* -an */
  	server_up (scfg);
  	scfg->share->bytes_from += cc;
  	if (con->statistics)


[Index of Archives]     [Yosemite]     [Yosemite Campsites]     [Bugtraq]     [Linux]     [Trn]

Powered by Linux