Branch: Tag:

2018-12-07

2018-12-07 09:10:50 by Stephen R. van den Berg <srb@cuci.nl>

pgsql: Avoid excessive latency on frequent ping()s.

80:   private int timeout = QUERYTIMEOUT;   private array connparmcache;   private int reconnected; + private int lastping = time(1);      protected string _sprintf(int type) {    string res;
253:   //! @seealso   //! @[is_open()]   /*semi*/final int ping() { +  int t, ret;    waitauthready(); -  return is_open() -  && !catch(proxy.c->start()->sendcmd(FLUSHSEND)) ? !!reconnected : -1; +  if ((ret = is_open()) +  // Pinging more frequently than MINPINGINTERVAL seconds +  // is suppressed to avoid artificial TCP-ACK latency +  && (t = time(1)) - lastping > MINPINGINTERVAL +  && (ret = !catch(proxy.c->start()->sendcmd(FLUSHSEND)))) +  lastping = t; +  return ret ? !!reconnected : -1;   }      //! Cancels all currently running queries in this session.