From 9db56888ee9b958ee8384d665da0fb9dd640b94b Mon Sep 17 00:00:00 2001 From: John Birrell Date: Fri, 22 Feb 2002 04:26:54 +0000 Subject: [PATCH] Fix a bug where a short write to a non-blocking socket would leave the descriptor locked, causing other threads to hang if they happened to access the socket. MFC after: 5 days --- lib/libc_r/uthread/uthread_sendfile.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/libc_r/uthread/uthread_sendfile.c b/lib/libc_r/uthread/uthread_sendfile.c index 901d523abf8a..81dcf63283c5 100644 --- a/lib/libc_r/uthread/uthread_sendfile.c +++ b/lib/libc_r/uthread/uthread_sendfile.c @@ -139,8 +139,11 @@ _sendfile(int fd, int s, off_t offset, size_t nbytes, struct sf_hdtr *hdtr, /* * If we're not blocking then return. */ - if (!blocking) + if (!blocking) { + _FD_UNLOCK(s, FD_WRITE); + _FD_UNLOCK(fd, FD_READ); goto SHORT_WRITE; + } /* * Otherwise wait on the fd.