X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2FObj%2Fsac-a-push.phh;h=af056d590ba8494047d3c81ca8a4302cebee926d;hb=c75db73487fbf95bd83d842b60827573ff30cfc7;hp=a06ef405e6caaa6c114d141ec345b5960bb97701;hpb=33e39c735545e6f855eac0ec8c57c407f7918ae1;p=brisk.git diff --git a/web/Obj/sac-a-push.phh b/web/Obj/sac-a-push.phh index a06ef40..af056d5 100644 --- a/web/Obj/sac-a-push.phh +++ b/web/Obj/sac-a-push.phh @@ -305,7 +305,7 @@ class Sac_a_push { } $write = NULL; $except = NULL; - $num_changed_sockets = stream_select($read, $write, $except, 5, 0); + $num_changed_sockets = stream_select($read, $write, $except, 0, 100000); if ($num_changed_sockets == 0) { printf(" no data in 5 secs "); @@ -324,7 +324,10 @@ class Sac_a_push { } if ($sock === $this->list) { printf("NUOVA CONNEX\n"); - $new_unix = stream_socket_accept($this->list); + if (($new_unix = stream_socket_accept($this->list)) == FALSE) { + printf("SOCKET_ACCEPT FAILED\n"); + continue; + } $stream_info = ""; $method = ""; $get = array(); @@ -365,15 +368,18 @@ class Sac_a_push { } } else { - if (($buf = fread($sock, 512)) === FALSE) { - printf("error read\n"); - } - else if (strlen($buf) === 0) { + $buf = fread($sock, 512); + if ($buf == FALSE || strlen($buf) == 0) { + if ($buf == FALSE) { + printf("ERROR READING\n"); + } if ($sock === $this->list) { printf("Arrivati %d bytes da list\n", strlen($buf)); + exit(21); } else if ($sock === $this->in) { printf("Arrivati %d bytes da stdin\n", strlen($buf)); + exit(22); } else { // $user_a[$s2u[intval($sock)]]->disable(); @@ -382,9 +388,10 @@ class Sac_a_push { } unset($this->socks[intval($sock)]); unset($this->s2u[intval($sock)]); - fclose($sock); - printf("CLOSE ON READ\n"); } + fclose($sock); + printf("CLOSE ON READ\n"); + if ($this->debug > 1) { printf("post unset\n"); print_r($this->socks); @@ -429,15 +436,19 @@ class Sac_a_push { if (isset($this->s2u[intval($sock)])) { $user = $this->s2u[intval($sock)]; $response = $user->rd_cache_get(); - if (($this->curtime - $user->lacc) <= (EXPIRE_TIME_RD / 2)) { + $do_ping = FALSE; + if (($this->curtime - $user->lacc) > (EXPIRE_TIME_RD / 3)) { + $do_ping = TRUE; + } + else { $user->ping_req = FALSE; } + if ($response == "") { $content = ""; $user->stream_main($content, $get, $post, $cookie); printf("[%s] [%d] [%d]\n", $user->name, $user->lacc, $this->curtime); - if ($user->ping_req == FALSE - && (($this->curtime - $user->lacc) > (EXPIRE_TIME_RD / 2))) { + if ($do_ping && $user->ping_req == FALSE) { $content .= $user->stream_keepalive(TRUE); $user->ping_req = TRUE; } @@ -451,7 +462,7 @@ class Sac_a_push { if ($response != "") { // echo "SPIA: [".substr($response, 0, 60)."...]\n"; - echo "SPIA: [".$response."...]\n"; + echo "SPIA: [".$response."]\n"; $response_l = mb_strlen($response, "ASCII"); $wret = @fwrite($sock, $response); if ($wret < $response_l) { @@ -482,4 +493,4 @@ class Sac_a_push { } // function run(... } -?> \ No newline at end of file +?>