Thread

  1. connection timeout?

    pierre@desertmoon.com — 1999-02-13T01:03:42Z

    All,
      
    
        Is there a connection timeout on the client code? That is if I were
        to leave the client running but idle for a period of time I'd like
        the client to time out and quit....is there anything like that
        in PostgreSQL, can it be added?
    
        -=pierre
    
    
  2. Re: [SQL] connection timeout?

    Sascha Schumann <sas@schell.de> — 1999-02-13T14:55:35Z

    On Fri, Feb 12, 1999 at 06:03:42PM -0700, pierre@desertmoon.com wrote:
    > All,
    >   
    > 
    >     Is there a connection timeout on the client code? That is if I were
    >     to leave the client running but idle for a period of time I'd like
    >     the client to time out and quit....is there anything like that
    >     in PostgreSQL, can it be added?
    > 
    >     -=pierre
    
    I've employed the following method in one program (it's a CGI which may stay
    longer around without using the database connection):
    
    -----
    PGconn *conn;
    
    void sig_alrm(int nr)
    {
    	signal(SIGALRM, SIG_DEF);
    	if(conn)
    		PQfinish(conn);
    	conn = NULL;
    }
    
    void use_pgsql(void)
    {
    	if(!conn) {
    		conn = PQconnectdb(...);
    		signal(SIGALRM, sig_alrm);
    	}
    	alarm(60);
    }
    -----
    
    Before you use any database action now, you call use_pgsql() which will start
    the counter and set up the connection.
    
    -- 
                         
              Regards,
    						                                
                                Sascha Schumann | 
                                     Consultant | finger sas@schell.de
                                                | for PGP public key