Req #21764 [Opn->Csd]: imap_close() does not close a a stream immediately

From: Date: Tue, 24 Oct 2017 02:05:35 +0000
Subject: Req #21764 [Opn->Csd]: imap_close() does not close a a stream immediately
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-211879@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=21764&edit=1

 ID:                 21764
 Updated by:         kalle@php.net
 Reported by:        mikael dot suvi at trigger dot ee
 Summary:            imap_close() does not close a a stream immediately
-Status:             Open
+Status:             Closed
 Type:               Feature/Change Request
 Package:            IMAP related
 Operating System:   Linux 2.4.18-SMP
 PHP Version:        4.2.3
-Assigned To:        
+Assigned To:        kalle
 Block user comment: N
 Private report:     N

 New Comment:

Please try with PHP7 and report back if this is still an issue in a new report


Previous Comments:
------------------------------------------------------------------------
[2003-08-21 03:35:46] mikael dot suvi at trigger dot ee

Using version php4-STABLE-200308180730
The script still produces the same results.

------------------------------------------------------------------------
[2003-08-15 08:20:19] sniper@php.net

Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip



------------------------------------------------------------------------
[2003-01-20 05:05:14] mikael dot suvi at trigger dot ee

It works if I return by refrence. 
But still, if call imap_close() I'm expecting it to close my stream.

It will make some bugs things _very hard_ to track. 
For example: if I delete a message before closing stream and  after closing I open a new stream to
the same mailserver, I still get the same number of messages in my mailbox.

<?

$MailStream = 0;
function foo()
{
        global $MailStream;
        $ar1 = imap_open("{some.server/pop3:110}", "user", "pass");
        $MailStream = $ar1;

        return $ar1;
}

$arr = foo();
imap_delete($arr, 1);
imap_expunge($arr);
print imap_num_msg($arr) . " message(s) in your INBOX<br>";
imap_close($arr);

$arr1 = foo();
print imap_num_msg($arr1) . " message(s) in your INBOX";

?>

Output:
7 message(s) in your INBOX
8 message(s) in your INBOX

------------------------------------------------------------------------
[2003-01-20 02:58:59] derick@php.net

I think this is expected though, and I dont really consider it as a bug. Try returning the resource
by reference, or not using that global. Does it work then?

------------------------------------------------------------------------
[2003-01-20 02:45:07] mikael dot suvi at trigger dot ee

Script:
<?

$MailStream = 0;
function foo()
{
        global $MailStream;
        $ar = imap_open("{some.host/pop3:110}", "user", "pass");
        $MailStream = $ar;

        return $ar;
}

$arr = foo();
imap_close($arr);
sleep(4);
die();

?>

will not close my connection to mailserver when calling function imap_close. 
In mailserver log the following lines indicate that the stream is not closed:

Jan 20 10:28:46 mail-fe73 pop3d: LOGIN, user=suurjuht, ip=[::ffff:xxx.xxx.xxx.xxx]
Jan 20 10:28:50 mail-fe73 pop3d: LOGOUT, user=suurjuht, ip=[::ffff:xxx.xxx.xxx.xxx], top=0, retr=0

Notice the 4 second delay when user is logged out. In closes the connection when script terminates.
I guess the problem is when assigning the resource value to global variable the resources reference
count is increased by one. When calling imap_close the reference value is checked and internal
pop3_close is called only when reference count is 1.

c-client version is 2001

I think this behaviour is not good.

------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=21764&edit=1


Thread (7 messages)

« previous php.bugs (#211879) next »