From 5270f051ec92e4db7a68de1ec21e15172c2d6e8c Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Wed, 24 Oct 2012 07:32:36 +0200 Subject: [PATCH] improved fread return value management --- web/Obj/sac-a-push.phh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/web/Obj/sac-a-push.phh b/web/Obj/sac-a-push.phh index 8f0dbc3..8da22fd 100644 --- a/web/Obj/sac-a-push.phh +++ b/web/Obj/sac-a-push.phh @@ -368,10 +368,11 @@ 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)); } @@ -385,9 +386,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); -- 2.17.1