Branch: Tag:

2005-03-29

2005-03-29 17:59:31 by Martin Stjernholm <mast@lysator.liu.se>

Added get_last_io_time.

Rev: lib/modules/Protocols.pmod/LDAP.pmod/protocol.pike:1.17

2:      // LDAP client protocol implementation for Pike.   // - // $Id: protocol.pike,v 1.16 2005/03/11 16:49:57 mast Exp $ + // $Id: protocol.pike,v 1.17 2005/03/29 17:59:31 mast Exp $   //   // Honza Petrous, hop@unibase.cz   //
47:    object low_fd = Stdio.File(); // helper fd    object ldapfd; // helper fd    + static int last_io_time; // Timestamp when I/O on the fd was made last. +     int seterr(int errno) {    // Sets ldap_err* variables and returns errno   
72:    array error() { return ({error_number(), error_string()}); }       + //! Returns when I/O was made last. Useful to find out whether it's + //! safe to continue using a connection that has been idle for some + //! time. + int get_last_io_time() {return last_io_time;} +     static void read_answer() {    // ----------------------    // Reads LDAP PDU (with defined msgid) from the server
137:    DWRITE("protocol.read_answer: ok=1.\n");    ok = 1;    +  last_io_time = time(); +     if(con_ok)    con_ok(this, @extra_args);    }
178:    void create(object fd) {    // -------------------    ldapfd = fd; +  last_io_time = time();    }      
219:    writebuf= "";    readbuf= ""; // !!! NEni to pozde ?    +  last_io_time = time(); +     //`()();       read_answer();
280:    return -ldap_errno;    }    retv += s; +  last_io_time = time();    DWRITE(sprintf("protocol.readmsg: %s\n", .ldap_privates.ldap_der_decode(retv)->debug_string()));    return retv;    }
313:    }    DWRITE(sprintf("protocol.writemsg: write OK [%d bytes].\n",rv));    msgval = 0; msgid = 0; +  last_io_time = time();    return msgnum;    }      #else   constant this_program_does_not_exist=1;   #endif