flush check added
authorMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Wed, 8 Oct 2014 17:04:44 +0000 (19:04 +0200)
committerMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Wed, 8 Oct 2014 17:04:44 +0000 (19:04 +0200)
web/Obj/sac-a-push.phh
web/Obj/user.phh

index 3f4f6c8..91012a8 100644 (file)
@@ -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);
                     }
                     
index 96706b8..68b686d 100644 (file)
@@ -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;