Changeset 219 for trunk/src/sh_forward.c


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

New options SetThrottle and SetConnectionTimeout (ticket #146).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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     
Note: See TracChangeset for help on using the changeset viewer.