From 988413fc84244751058890aec6aa4d0c2e9cdafa Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Wed, 8 Oct 2014 19:04:44 +0200 Subject: [PATCH] flush check added --- web/Obj/sac-a-push.phh | 12 +++++++++++- web/Obj/user.phh | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/web/Obj/sac-a-push.phh b/web/Obj/sac-a-push.phh index 3f4f6c8..91012a8 100644 --- a/web/Obj/sac-a-push.phh +++ b/web/Obj/sac-a-push.phh @@ -874,6 +874,13 @@ class Sac_a_push { $id = intval($sock); if (isset($this->s2u[$id])) { $user = $this->s2u[$id]; + + if ($user->rd_toflush) { + if (fflush($sock) == FALSE) + continue; + else + $user->rd_toflush = FALSE; + } $response = $user->rd_cache_get(); $do_ping = FALSE; if (($this->curtime - $user->lacc) > (EXPIRE_TIME_RD / 3)) { @@ -911,7 +918,10 @@ class Sac_a_push { else { $user->rd_cache_set(""); } - fflush($sock); + if (fflush($sock) == FALSE) { + $user->rd_toflush = TRUE; + continue; + } $user->rd_kalive_reset($this->curtime); } diff --git a/web/Obj/user.phh b/web/Obj/user.phh index 96706b8..68b686d 100644 --- a/web/Obj/user.phh +++ b/web/Obj/user.phh @@ -129,6 +129,7 @@ class User { var $rd_scristp; // current script step (for each session) var $rd_kalive; // if no message are sent after RD_KEEPALIVE_TOUT secs we send a keepalive from server var $rd_cache; // place where store failed fwrite data + var $rd_toflush; // bool to inform about unfflushed socket var $rd_zls; // zlibstream object handle if compressed stream, else FALSE var $rd_transp; // class that define stream encapsulation type (iframe, xhr, ...) var $rd_is_chunked; // is the transport chunked or not ? @@ -190,6 +191,7 @@ class User { $thiz->rd_scristp = -1; $thiz->rd_kalive = -1; $thiz->rd_cache = ""; + $thiz->td_toflush = FALSE; $thiz->rd_zls = FALSE; $thiz->rd_transp = NULL; $thiz->rd_is_chunked = FALSE; -- 2.17.1