Changeset 219


Ignore:
Timestamp:
Feb 24, 2009, 8:02:21 PM (16 years ago)
Author:
katerina
Message:

New options SetThrottle and SetConnectionTimeout (ticket #146).

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/docs/Changelog

    r218 r219  
    112.5.3:
     2        * Option SetThrottle to throttle throughput for db download
     3        * Option SetConnectionTimeout to configure the client connection
     4          timeout configurable
    25        * Provide getrpcbynumber, getservbyname implementations
    36          to avoid dependencies with static linkage
  • trunk/include/sh_forward.h

    r170 r219  
    3030int sh_forward_create_password (const char * dummy);
    3131
    32 /* set time limit
     32/* set timeout for active client connections
     33 */
     34int sh_forward_set_timeout (const char * c);
     35
     36/* set time limit after which client is reported dead
    3337 */
    3438int sh_forward_set_time_limit(const char * str);
     
    108112#ifdef SH_WITH_CLIENT
    109113
     114/* Throttle file download
     115 */
     116int sh_forward_set_throttle_delay (const char * c);
     117
    110118/* request file from server. file may be "CONF" or "DATA".
    111119 */
  • trunk/src/sh_forward.c

    r215 r219  
    842842  SL_RETURN(i, _("sh_forward_req_file"));
    843843}
     844
     845static unsigned long sh_throttle_delay = 0;
     846
     847int sh_forward_set_throttle_delay (const char * c)
     848{
     849  long val;
     850
     851  SL_ENTER(_("sh_forward_set_throttle_delay"));
     852
     853  val = strtol (c, (char **)NULL, 10);
     854  if (val < 0)
     855    SL_RETURN( (-1), _("sh_forward_set_throttle_delay"));
     856
     857  val = (val > 1000) ? 1000 : val;
     858
     859  sh_throttle_delay = (unsigned long) val;
     860  SL_RETURN( (0), _("sh_forward_set_throttle_delay"));
     861}
     862
    844863
    845864static  long sh_forward_try_impl (char * errmsg, char what)
     
    16821701                                        flag_err-KEY_LEN);
    16831702                        ++transfercount;
     1703                        /***
     1704                         ***  --- Delay for throughput throttling ---
     1705                         ***/
     1706                        if (sh_throttle_delay > 0)
     1707                          retry_msleep(sh_throttle_delay/1000, sh_throttle_delay % 1000);
     1708                        /***
     1709                         ***  --- End delay                       ---
     1710                         ***/
    16841711                        flag_err =
    16851712                          sh_forward_send_crypt (sockfd, (char) theProto,
     
    47924819}
    47934820
     4821#define  TIME_OUT_DEF 900
     4822static   unsigned long  time_out_val = TIME_OUT_DEF;
     4823
     4824int sh_forward_set_timeout (const char * c)
     4825{
     4826  long val;
     4827
     4828  SL_ENTER(_("sh_forward_set_time_out"));
     4829
     4830  val = strtol (c, (char **)NULL, 10);
     4831
     4832  if (val == 0)
     4833    {
     4834      val = TIME_OUT_DEF;
     4835    }
     4836  else if (val < 0)
     4837    {
     4838      time_out_val = TIME_OUT_DEF;
     4839      SL_RETURN( (-1), _("sh_forward_set_time_out"));
     4840    }
     4841
     4842  time_out_val = (unsigned long) val;
     4843  SL_RETURN( (0), _("sh_forward_set_time_out"));
     4844}
     4845
     4846
    47944847static   sh_conn_t        * conns = NULL;
    4795 #define  TIME_OUT_DEF 900
    47964848static   int  maxconn = 0;  /* maximum number of simultaneous connections */
    47974849
     
    49064958  unsigned long      time_now;
    49074959  unsigned long      time_last = 0;
    4908   unsigned long      time_out = TIME_OUT_DEF
     4960  unsigned long      time_out = time_out_val
    49094961 
    49104962  time_t told;
     
    51985250      /* -- Exponentially reduce timeout limit if more than 1/2 full. --
    51995251       */
     5252      /* Eliminate this, will cause problems when too much clients are
     5253       * starting up. */
     5254#if 0
    52005255      if (nowconn > (maxconn/2))
    52015256        time_out = ( (time_out/2) > 1) ? (time_out/2) : 1;
    52025257      else
    5203         time_out = TIME_OUT_DEF;
    5204      
     5258        time_out = time_out_val;
     5259#endif
    52055260     
    52065261     
  • trunk/src/sh_readconf.c

    r216 r219  
    10561056  { N_("setclienttimelimit"),  SH_SECTION_SRV,  SH_SECTION_MISC,
    10571057    sh_forward_set_time_limit },
     1058  { N_("setconnectiontimeout"),SH_SECTION_SRV,  SH_SECTION_MISC,
     1059    sh_forward_set_timeout },
    10581060  { N_("useclientseverity"),   SH_SECTION_SRV,  SH_SECTION_MISC,
    10591061  sh_forward_use_clt_sev },
     
    10831085  { N_("setlogserver"),        SH_SECTION_CLT,  SH_SECTION_MISC,
    10841086    sh_forward_setlogserver },
     1087  { N_("setthrottle"),         SH_SECTION_CLT,  SH_SECTION_MISC,
     1088    sh_forward_set_throttle_delay},
    10851089#endif
    10861090#endif
Note: See TracChangeset for help on using the changeset viewer.