fix nptl/tst-cancel4 for 64-bit systems

Richard Henderson rth@twiddle.net
Sat May 28 19:01:00 GMT 2005


There was a thread about this in relation to linuxthreads a month
or so ago.  The same problem affects nptl, obviously.

  http://sourceware.org/ml/libc-alpha/2005-04/msg00056.html

I tried Roland's suggestion of using socketpair+setsockopt, but
that didn't work.  According to strace, with SO_SNDBUF set to 100,
a 100,000 byte write still succeeds immediately.  Perhaps I did
something wrong setting it up, but I wouldn't have thought there
would be much room to do so.

So I've taken a different tack: continue writing until the pipe
fills up.  There's an outside chance this won't test what we wanted,
in that we'll get the cancel signal on the way in to the call and
not test unwinding through the actual write syscall.  But in
practice it seems that the nanosleep on the killing side gives us
plenty of time to issue enough writes to fill the buffer and begin
waiting.


r~


2005-05-28  Richard Henderson  <rth@redhat.com>

	* tst-cancel4.c (tf_write): Continue writing to fill the buffer.
	(tf_writev): Likewise.

Index: nptl/tst-cancel4.c
===================================================================
RCS file: /cvs/glibc/libc/nptl/tst-cancel4.c,v
retrieving revision 1.18
diff -u -p -d -r1.18 tst-cancel4.c
--- nptl/tst-cancel4.c	6 Oct 2004 08:53:01 -0000	1.18
+++ nptl/tst-cancel4.c	28 May 2005 18:47:40 -0000
@@ -220,9 +220,13 @@ tf_write  (void *arg)
   ssize_t s;
   pthread_cleanup_push (cl, NULL);
 
-  char buf[100000];
+  char buf[8192];
   memset (buf, '\0', sizeof (buf));
-  s = write (fd, buf, sizeof (buf));
+  do
+    {
+      s = write (fd, buf, sizeof (buf));
+    }
+  while (s == sizeof(buf));
 
   pthread_cleanup_pop (0);
 
@@ -266,10 +270,15 @@ tf_writev  (void *arg)
   ssize_t s;
   pthread_cleanup_push (cl, NULL);
 
-  char buf[100000];
+  char buf[8192];
   memset (buf, '\0', sizeof (buf));
   struct iovec iov[1] = { [0] = { .iov_base = buf, .iov_len = sizeof (buf) } };
-  s = writev (fd, iov, 1);
+
+  do
+    {
+      s = writev (fd, iov, 1);
+    }
+  while (s == sizeof(buf));
 
   pthread_cleanup_pop (0);
 



More information about the Libc-alpha mailing list