Re: Auth_Container_IMAP causing load ?

From: Date: Tue, 14 Oct 2003 11:27:19 +0000
Subject: Re: Auth_Container_IMAP causing load ?
References: 1  Groups: php.pear.dev php.pear.general 
Request: Send a blank email to pear-dev+get-22680@lists.php.net to get a copy of this message
Birgir Stefansson wrote:
Hey everyone. I've been using Auth and Auth_Container_IMAP for quite some time now and I have been experiencing some problems lately. The thing is that the imap server I am connecting to has a constant high load and it seems to be dropping some of my connections. I see that the constructor for Auth_Container_IMAP has a call to $this->_checkServer(); in the constructor which in turn checks to see if the imap server is up. Why is this ? Should I care weather or not the imap server is up or not after the user has successfully logged in ? Running the constructor for Auth_Container_IMAP and therefore the _checkServer() function on every page for every user probably generates some load on the imap server does it not ? Wouldn't I just want to check if the server is up when i want to authenticate a user ? Can anyone elaborate on this, please? TIA Birgir Hi,
I wrote the original version of the IMAP container. I think you are absolutely right, it should not check if the server is up when the object is created. I don't have CVS access, but I would like suggest someone moves the function call to the fetchData() method. See example below. Thanks for your comment! jeroen /** * Try to open a IMAP stream using $username / $password * * @param string Username * @param string Password * @return boolean */ function fetchData($username, $password) { $this->_checkServer(); $conn = @imap_open ('{'.$this->options['host'].':'.$this->options['port'].'}', $username, $password, OP_HALFOPEN); if ($conn) {
       $this->activeUser = $username;
       @imap_close($conn);
       return true;
} else {
       $this->activeUser = '';
       return false;
} }

« previous php.pear.dev (#22680) next »