Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 May 2002 11:40:05 -0700 (PDT)
From:      Archie Cobbs <archie@packetdesign.com>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/37658: libc_r: poll(2) does not wake up when thread canceled
Message-ID:  <200205021840.g42Ie5S83289@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/37658; it has been noted by GNATS.

From: Archie Cobbs <archie@packetdesign.com>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: bin/37658: libc_r: poll(2) does not wake up when thread canceled
Date: Thu, 2 May 2002 11:38:59 -0700 (PDT)

 Below is a patch that fixes the problem for me. It also fixes
 the same problem for these functions: select, readv, wait4, writev.
 
 -Archie
 
 __________________________________________________________________________
 Archie Cobbs     *     Packet Design     *     http://www.packetdesign.com
 
 
 Index: uthread_poll.c
 ===================================================================
 RCS file: /home/cvs/freebsd/src/lib/libc_r/uthread/uthread_poll.c,v
 retrieving revision 1.9
 diff -u -r1.9 uthread_poll.c
 --- uthread_poll.c	29 Jan 2000 22:53:49 -0000	1.9
 +++ uthread_poll.c	2 May 2002 18:38:30 -0000
 @@ -97,5 +97,15 @@
  	return (ret);
  }
  
 -__strong_reference(_poll, poll);
 +int
 +poll(struct pollfd *fds, unsigned int nfds, int timeout)
 +{
 +	int ret;
 +
 +	_thread_enter_cancellation_point();
 +	ret = _poll(fds, nfds, timeout);
 +	_thread_leave_cancellation_point();
 +
 +	return ret;
 +}
  #endif
 Index: uthread_readv.c
 ===================================================================
 RCS file: /home/cvs/freebsd/src/lib/libc_r/uthread/uthread_readv.c,v
 retrieving revision 1.11
 diff -u -r1.11 uthread_readv.c
 --- uthread_readv.c	29 Jan 2000 22:53:49 -0000	1.11
 +++ uthread_readv.c	2 May 2002 18:38:30 -0000
 @@ -91,5 +91,15 @@
  	return (ret);
  }
  
 -__strong_reference(_readv, readv);
 +ssize_t
 +readv(int fd, const struct iovec *iov, int iovcnt)
 +{
 +	ssize_t ret;
 +
 +	_thread_enter_cancellation_point();
 +	ret = _readv(fd, iov, iovcnt);
 +	_thread_leave_cancellation_point();
 +
 +	return ret;
 +}
  #endif
 Index: uthread_select.c
 ===================================================================
 RCS file: /home/cvs/freebsd/src/lib/libc_r/uthread/uthread_select.c,v
 retrieving revision 1.16
 diff -u -r1.16 uthread_select.c
 --- uthread_select.c	29 Jan 2000 22:53:50 -0000	1.16
 +++ uthread_select.c	2 May 2002 18:38:30 -0000
 @@ -204,5 +204,16 @@
  	return (ret);
  }
  
 -__strong_reference(_select, select);
 +int 
 +select(int numfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
 +	struct timeval *timeout)
 +{
 +	int ret;
 +
 +	_thread_enter_cancellation_point();
 +	ret = _select(numfds, readfds, writefds, exceptfds, timeout);
 +	_thread_leave_cancellation_point();
 +
 +	return ret;
 +}
  #endif
 Index: uthread_wait4.c
 ===================================================================
 RCS file: /home/cvs/freebsd/src/lib/libc_r/uthread/uthread_wait4.c,v
 retrieving revision 1.10.2.1
 diff -u -r1.10.2.1 uthread_wait4.c
 --- uthread_wait4.c	9 Nov 2000 23:46:04 -0000	1.10.2.1
 +++ uthread_wait4.c	2 May 2002 18:38:30 -0000
 @@ -67,5 +67,15 @@
  	return (ret);
  }
  
 -__strong_reference(_wait4, wait4);
 +pid_t
 +wait4(pid_t pid, int *istat, int options, struct rusage *rusage)
 +{
 +	pid_t ret;
 +
 +	_thread_enter_cancellation_point();
 +	ret = _wait4(pid, istat, options, rusage);
 +	_thread_leave_cancellation_point();
 +
 +	return ret;
 +}
  #endif
 Index: uthread_writev.c
 ===================================================================
 RCS file: /home/cvs/freebsd/src/lib/libc_r/uthread/uthread_writev.c,v
 retrieving revision 1.16
 diff -u -r1.16 uthread_writev.c
 --- uthread_writev.c	29 Jan 2000 22:53:55 -0000	1.16
 +++ uthread_writev.c	2 May 2002 18:38:31 -0000
 @@ -201,5 +201,15 @@
  	return (ret);
  }
  
 -__strong_reference(_writev, writev);
 +ssize_t
 +writev(int fd, const struct iovec *iov, int iovcnt)
 +{
 +	ssize_t ret;
 +
 +	_thread_enter_cancellation_point();
 +	ret = _writev(fd, iov, iovcnt);
 +	_thread_leave_cancellation_point();
 +
 +	return ret;
 +}
  #endif

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200205021840.g42Ie5S83289>