Commits

jhwoodyatt  committed 4db4b88

Fix minor typographical errors. In T11 and T12, shutdown the send side of
the socket before trying to read.

  • Participants
  • Parent commits 90b5cd7

Comments (0)

Files changed (1)

File cf/t/t_cf.ml

 end
 
 module T11 = struct
-    let len = 100
+    let len = 10
 
     let test () =
         try
             let lhost, lport = laddr in
             let rhost, rport = raddr in
             if lhost <> rhost then
-                failwith "T12 error: host a#getpeername <> b#getsockname";
+                failwith "T11 error: host a#getpeername <> b#getsockname";
             if lport <> rport then
-                failwith "T12 error: port a#getpeername <> b#getsockname";
+                failwith "T11 error: port a#getpeername <> b#getsockname";
             let laddr = a#getsockname and raddr = b#getpeername in
             let lhost, lport = laddr in
             let rhost, rport = raddr in
             if lhost <> rhost then
-                failwith "T12 error: host a#getsockname <> b#getpeername";
+                failwith "T11 error: host a#getsockname <> b#getpeername";
             if lport <> rport then
-                failwith "T12 error: port a#getsockname <> b#getpeername";
+                failwith "T11 error: port a#getsockname <> b#getpeername";
             let tx = String.make len 'x' and rx = String.create len in
             let n = a#send tx 0 len in
-            if n <> len then failwith "T12 error: tx incomplete!";
+            if n <> len then failwith "T11 error: tx incomplete!";
+            a#shutdown Unix.SHUTDOWN_SEND;
             let n = b#recv rx 0 len in
-            if n <> len then failwith "T12 error: rx incomplete!";
-            if tx <> rx then failwith "T12 error: tx <> rx!";
+            if n <> len then failwith "T11 error: rx incomplete!";
+            if tx <> rx then failwith "T11 error: tx <> rx!";
             a#close;
             b#close;
             listen#close
         with
         | Unix.Unix_error (e, fn, _) ->
-            failwith (Printf.sprintf "T12 error: %s in %s.\n"
+            failwith (Printf.sprintf "T11 error: %s in %s.\n"
                 (Unix.error_message e) fn)
 end
 
 module T12 = struct
-    let len = 100
+    let len = 10
 
     let test () =
         try
             let bind = listen#getsockname in
             let active = new Cf_tcp6_socket.initiator bind in
             active#connect;
-            let a, _ = listen#accept in
-            let a = new Cf_tcp6_socket.endpoint a in
-            let b = new Cf_tcp6_socket.endpoint (active#socket) in
-            a#setsockopt Cf_ip_common.tcp_nodelay true;
-            b#setsockopt Cf_ip_common.tcp_nodelay true;
+            let a = new Cf_tcp6_socket.endpoint (active#socket) in
+            let b, _ = listen#accept in
+            let b = new Cf_tcp6_socket.endpoint b in
             let laddr = a#getpeername and raddr = b#getsockname in
             let lhost, lport, lscope = laddr in
             let rhost, rport, rscope = raddr in
             if lhost <> rhost then
-                failwith "T13 error: host a#getpeername <> b#getsockname";
+                failwith "T12 error: host a#getpeername <> b#getsockname";
             if lport <> rport then
-                failwith "T13 error: port a#getpeername <> b#getsockname";
+                failwith "T12 error: port a#getpeername <> b#getsockname";
             if lscope <> rscope then
-                failwith "T13 error: port a#getpeername <> b#getsockname";
+                failwith "T12 error: port a#getpeername <> b#getsockname";
             let laddr = a#getsockname and raddr = b#getpeername in
             let lhost, lport, lscope = laddr in
             let rhost, rport, rscope = raddr in
             if lhost <> rhost then
-                failwith "T13 error: host a#getsockname <> b#getpeername";
+                failwith "T12 error: host a#getsockname <> b#getpeername";
             if lport <> rport then
-                failwith "T13 error: port a#getsockname <> b#getpeername";
+                failwith "T12 error: port a#getsockname <> b#getpeername";
             if lscope <> rscope then
-                failwith "T13 error: port a#getsockname <> b#getpeername";
+                failwith "T12 error: port a#getsockname <> b#getpeername";
             let tx = String.make len 'x' and rx = String.create len in
             let n = a#send tx 0 len in
-            if n <> len then failwith "T13 error: tx incomplete!";
+            if n <> len then failwith "T12 error: tx incomplete!";
+            a#shutdown Unix.SHUTDOWN_SEND;
             let n = b#recv rx 0 len in
-            if n <> len then failwith "T13 error: rx incomplete!";
-            if tx <> rx then failwith "T13 error: tx <> rx!";
+            if n <> len then failwith "T12 error: rx incomplete!";
+            if tx <> rx then failwith "T12 error: tx <> rx!";
             a#close;
             b#close;
             listen#close
         with
         | Unix.Unix_error (e, fn, _) ->
-            failwith (Printf.sprintf "T13 error: %s in %s.\n"
+            failwith (Printf.sprintf "T12 error: %s in %s.\n"
                 (Unix.error_message e) fn)
 end