Bug 6466 - hung socket read causes SIP tests to fail
authorJAMES Mason <mason@kohaaloha.com>
Mon, 6 Jun 2011 04:10:39 +0000 (16:10 +1200)
committerPaul Poulain <paul.poulain@biblibre.com>
Tue, 17 Jan 2012 15:16:09 +0000 (16:16 +0100)
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
C4/SIP/t/SIPtest.pm

index 62d5646..0504d23 100644 (file)
@@ -185,10 +185,14 @@ sub one_msg {
 
     # If reading or writing fails, then the server's dead,
     # so there's no point in continuing.
-    if (!write_msg({seqno => $seqno}, $test->{msg}, $sock)) {
-               BAIL_OUT("Write failure in $test->{id}");
-    } elsif (!($resp = <$sock>)) {
-               BAIL_OUT("Read failure in $test->{id}");
+    if ( !write_msg( { seqno => $seqno }, $test->{msg}, $sock ) ) {
+        BAIL_OUT("Write failure in $test->{id}");
+    }
+
+    my $rv = sysread( $sock, $resp, 10000000 ); # 10000000 is a big number
+
+    if ( !$rv ) {
+        BAIL_OUT("Read failure in $test->{id}");
     }
 
        chomp($resp);