From 4af32591f05ce2d3237c0aeaa785799d11680152 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Wed, 23 Oct 2013 15:32:19 -0500 Subject: [PATCH] vos: Remove pthread send/receive select() Commit 65e701fee4968b17066bb81e25b7adaa4024d4f3 introduced a couple of select() calls when the pthreaded vos writes to or reads from a usd pipe, corresponding to the IOMGR_Select() calls in LWP. However, these select() calls are unnecessary, since the read() or write() calls themselves will block anyway. The reason they are there for LWP is so the IOMGR can run another process while we're waiting for the file descriptor to be ready. The select() in ReceiveFile currently incorrectly waits for the output to be ready for reading, even though we're trying to write to it. As a result, if we try to 'vos dump' to a pipe with the pthreaded vos (such as stdout), we will hang forever, since it will never be ready for reading. To fix this, just get rid of the select() calls, since they don't really do anything. FIXES 131749 Change-Id: Ibe8841e0c01f1e55ac4ca1a8a99ab71083654662 Reviewed-on: http://gerrit.openafs.org/10360 Reviewed-by: Derrick Brashear Reviewed-by: Jeffrey Altman Tested-by: BuildBot --- src/volser/vos.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/volser/vos.c b/src/volser/vos.c index 4e1a743..78b8cc4 100644 --- a/src/volser/vos.c +++ b/src/volser/vos.c @@ -290,17 +290,16 @@ SendFile(usd_handle_t ufd, struct rx_call *call, long blksize) } while (!error) { -#ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */ +#if !defined(AFS_NT40_ENV) && !defined(AFS_PTHREAD_ENV) + /* Only for this for non-NT, non-pthread. For NT, we can't select on + * non-socket FDs. For pthread environments, we don't need to select at + * all, since the following read() will block. */ fd_set in; FD_ZERO(&in); FD_SET((intptr_t)(ufd->handle), &in); /* don't timeout if read blocks */ -#if defined(AFS_PTHREAD_ENV) - select(((intptr_t)(ufd->handle)) + 1, &in, 0, 0, 0); -#else IOMGR_Select(((intptr_t)(ufd->handle)) + 1, &in, 0, 0, 0); #endif -#endif error = USD_READ(ufd, buffer, blksize, &nbytes); if (error) { fprintf(STDERR, "File system read failed: %s\n", @@ -401,17 +400,16 @@ ReceiveFile(usd_handle_t ufd, struct rx_call *call, long blksize) while ((bytesread = rx_Read(call, buffer, blksize)) > 0) { for (bytesleft = bytesread; bytesleft; bytesleft -= w) { -#ifndef AFS_NT40_ENV /* NT csn't select on non-socket fd's */ +#if !defined(AFS_NT40_ENV) && !defined(AFS_PTHREAD_ENV) + /* Only for this for non-NT, non-pthread. For NT, we can't select + * on non-socket FDs. For pthread environments, we don't need to + * select at all, since the following write() will block. */ fd_set out; FD_ZERO(&out); FD_SET((intptr_t)(ufd->handle), &out); /* don't timeout if write blocks */ -#if defined(AFS_PTHREAD_ENV) - select(((intptr_t)(ufd->handle)) + 1, &out, 0, 0, 0); -#else IOMGR_Select(((intptr_t)(ufd->handle)) + 1, 0, &out, 0, 0); #endif -#endif error = USD_WRITE(ufd, &buffer[bytesread - bytesleft], bytesleft, &w); if (error) { -- 1.9.4