summaryrefslogtreecommitdiff
path: root/lib/libpthread/uthread/uthread_recvmsg.c
diff options
context:
space:
mode:
authorFederico G. Schwindt <fgsch@cvs.openbsd.org>2010-01-03 23:05:36 +0000
committerFederico G. Schwindt <fgsch@cvs.openbsd.org>2010-01-03 23:05:36 +0000
commit8028f6a67fe786e34cdc97e0f80c7fe8ce12194b (patch)
treedfd309174b9fe946bc94a645173a2e5b6bd67b6b /lib/libpthread/uthread/uthread_recvmsg.c
parent8977d0817d5af955632b410a7411fb89d1143f34 (diff)
Make SO_RCVTIMEO and SO_SNDTIMEO work with pthreads. Fixes at least some of
the issues seen with www/varnish. With input and help from guenther@ and kurt@. guenther@ ok
Diffstat (limited to 'lib/libpthread/uthread/uthread_recvmsg.c')
-rw-r--r--lib/libpthread/uthread/uthread_recvmsg.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/libpthread/uthread/uthread_recvmsg.c b/lib/libpthread/uthread/uthread_recvmsg.c
index 4e14aad4549..66de9d14998 100644
--- a/lib/libpthread/uthread/uthread_recvmsg.c
+++ b/lib/libpthread/uthread/uthread_recvmsg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uthread_recvmsg.c,v 1.9 2009/04/11 20:26:58 jakemsr Exp $ */
+/* $OpenBSD: uthread_recvmsg.c,v 1.10 2010/01/03 23:05:35 fgsch Exp $ */
/*
* Copyright (c) 1998 John Birrell <jb@cimlogic.com.au>
* All rights reserved.
@@ -57,9 +57,10 @@ recvmsg(int fd, struct msghdr *msg, int flags)
curthread->data.fd.fd = fd;
/* Set the timeout: */
- _thread_kern_set_timeout(NULL);
+ _thread_kern_set_timeout(_FD_RCVTIMEO(fd));
curthread->interrupted = 0;
curthread->closing_fd = 0;
+ curthread->timeout = 0;
_thread_kern_sched_state(PS_FDR_WAIT, __FILE__, __LINE__);
/* Check if the wait was interrupted: */
@@ -73,6 +74,11 @@ recvmsg(int fd, struct msghdr *msg, int flags)
errno = EBADF;
ret = -1;
break;
+ } else if (curthread->timeout) {
+ /* Return an error status: */
+ errno = EWOULDBLOCK;
+ ret = -1;
+ break;
}
} else {
ret = -1;