From 7548c9f1368f0f413bedfb1a2ac7cb43540e56bf Mon Sep 17 00:00:00 2001 From: fritzy Date: Wed, 2 Apr 2008 20:12:15 +0000 Subject: [PATCH] * disconnect fixes * set blocking explicitely git-svn-id: svn://netflint.net/xmpphp@12 ef36c318-a008-4979-b6e8-6b496270793b --- xmlstream.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/xmlstream.php b/xmlstream.php index 1090dfa..8982f77 100644 --- a/xmlstream.php +++ b/xmlstream.php @@ -31,6 +31,7 @@ class XMLStream { var $stream_start = ''; var $stream_end = 'disconnected = False; + $this->sent_disconnect = False; if($persistent) { $conflag = STREAM_CLIENT_PERSISTENT; } else { @@ -83,6 +85,7 @@ class XMLStream { } $this->log->log("Connecting to tcp://{$this->host}:{$this->port}"); $this->socket = stream_socket_client("tcp://{$this->host}:{$this->port}", $flags=$conflag); + stream_set_blocking($this-socket, 1); if($sendinit) $this->send($this->stream_start); } @@ -230,8 +233,11 @@ class XMLStream { } if($this->xml_depth == 0 and !$this->been_reset) { if(!$this->disconnected) { - $this->send($this->stream_end); + if(!$this->sent_disconnect) { + $this->send($this->stream_end); + } $this->disconnected = True; + $this->sent_disconnect = True; fclose($this->socket); if($this->reconnect) { $this->doReconnect(); @@ -249,6 +255,7 @@ class XMLStream { function disconnect() { $this->reconnect = False; $this->send($this->stream_end); + $this->sent_disconnect = True; $this->processUntil('end_stream', 5); $this->disconnected = True; }