improved remoteIdleTimeout handling

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

 




  remoteIdleTimeout handling in nntpcache was never really implemented.
This patch adds code to make it work.  This is a bit cleaner than that
posted by Aaron Nabil in that it doesn't include any local changes, and
moves some updates to a more appropiate layer.

  Basically, last_active_time is never updated, so the drop_idle_servers()
function doesn't do anything.  I've added updates in the server_up and
server_down functions.  I've also fixed detachServer() (it is only called
from drop_idle_servers()) to only de-allocate group_actual, and to set
last_active to zero.

  Patch is below.  Put in base of nntpcache source, and do a "patch <
mypatch" to apply it.

Tom Samplonius
SDF Systems


*** src/nntpcache.c.orig	Tue Aug  4 11:56:04 1998
--- src/nntpcache.c	Tue Aug  4 12:00:48 1998
***************
*** 903,909 ****
--- 903,912 ----
  	for (p=ServerList; p; p=p->next)
  		if (p->last_active_time &&
  		    ti - p->last_active_time > con->remoteIdleTimeout)
+ 		    {
  			detachServer(p);
+ 			logd(("disconnected idle NNTP server '%s'", p->host));
+ 		    }
  }
  
  static void emit_banner(bool post_ok)
*** src/sockets.c.orig	Tue Aug  4 11:57:37 1998
--- src/sockets.c	Tue Aug  4 13:07:15 1998
***************
*** 30,42 ****
  
  static void server_up (struct server_cfg *scfg)
  {
          if (scfg->share->server_up <= scfg->share->server_down)
  	{
- 	        time_t now = time(NULL);
  	    	if (scfg->share->server_down != 0)
  			scfg->share->server_down_time += now - scfg->share->server_down;
  		scfg->share->server_up = now;
  	}
  }
  
  static void server_down (struct server_cfg *scfg)
--- 30,43 ----
  
  static void server_up (struct server_cfg *scfg)
  {
+ 	time_t now = time(NULL);
          if (scfg->share->server_up <= scfg->share->server_down)
  	{
  	    	if (scfg->share->server_down != 0)
  			scfg->share->server_down_time += now - scfg->share->server_down;
  		scfg->share->server_up = now;
  	}
+ 	scfg->last_active_time = now;
  }
  
  static void server_down (struct server_cfg *scfg)
***************
*** 48,53 ****
--- 49,55 ----
  			scfg->share->server_up_time += now - scfg->share->server_up;
  		scfg->share->server_down = now;
  	}
+ 	scfg->last_active_time = 0;
  }
  
  static int scfg_connect (struct server_cfg *scfg)
***************
*** 100,111 ****
--- 102,116 ----
  			free(scfg->group_actual);
  			scfg->group_actual = NULL;
  		}
+ #ifdef 0
  		if (scfg->group)
  		{
  			free(scfg->group);
  			scfg->group= NULL;
  		}
+ #endif
  	}
+ 	scfg->last_active_time = 0;
  }
  
  EXPORT struct server_cfg *attachServer (struct server_cfg *scfg)




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

Powered by Linux