X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2Fportability%2FSysUio.cpp;h=62d5f2fa3fca235af3e17f026db334a5e770ece2;hb=015306906e2811cc0cf3dab0c4142d45434a2801;hp=54f7202c9fc701dc4f4168adf15efd6468dd0438;hpb=ed8c80a0e0988e4ce687f51ca832a00e4a6b7930;p=folly.git diff --git a/folly/portability/SysUio.cpp b/folly/portability/SysUio.cpp old mode 100755 new mode 100644 index 54f7202c..62d5f2fa --- a/folly/portability/SysUio.cpp +++ b/folly/portability/SysUio.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -70,10 +71,19 @@ static ssize_t doVecOperation(int fd, const iovec* iov, int count) { return -1; } - if (lockf(fd, F_LOCK, 0) == -1) { + // We only need to worry about locking if the file descriptor is + // not a socket. We have no way of locking sockets :( + // The correct way to do this for sockets is via sendmsg/recvmsg, + // but this is good enough for now. + bool shouldLock = !folly::portability::sockets::is_fh_socket(fd); + if (shouldLock && lockf(fd, F_LOCK, 0) == -1) { return -1; } - SCOPE_EXIT { lockf(fd, F_ULOCK, 0); }; + SCOPE_EXIT { + if (shouldLock) { + lockf(fd, F_ULOCK, 0); + } + }; ssize_t bytesProcessed = 0; int curIov = 0;