diff options
author | blu <none@none> | 2006-05-23 09:24:17 -0700 |
---|---|---|
committer | blu <none@none> | 2006-05-23 09:24:17 -0700 |
commit | 9760e1c48d45ca95f530c947bf07c62061b86c18 (patch) | |
tree | 9cfc6a0f7b9615671aee4c02bb4a86bf7bef6679 /usr/src | |
parent | fd93bfc32e86a61b0e7f02057aac2979479364e3 (diff) | |
download | illumos-joyent-9760e1c48d45ca95f530c947bf07c62061b86c18.tar.gz |
6381275 rcp hanging when sendfile() gets EINTR
6408517 sendfile should only return EINTR if no bytes have been transferred.
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/cmd/cmd-inet/usr.bin/rcp.c | 9 | ||||
-rw-r--r-- | usr/src/lib/libsendfile/common/sendfile.c | 44 |
2 files changed, 39 insertions, 14 deletions
diff --git a/usr/src/cmd/cmd-inet/usr.bin/rcp.c b/usr/src/cmd/cmd-inet/usr.bin/rcp.c index 057a0c7f1c..f91ffc6d27 100644 --- a/usr/src/cmd/cmd-inet/usr.bin/rcp.c +++ b/usr/src/cmd/cmd-inet/usr.bin/rcp.c @@ -1197,8 +1197,13 @@ notreg: while (size != 0) { amt = MIN(size, SENDFILE_SIZE); cnt = sendfile(rem, f, &off, amt); - if (cnt == -1) - break; + if (cnt == -1) { + if (errno == EINTR) { + continue; + } else { + break; + } + } size -= cnt; } if (cnt == -1) { diff --git a/usr/src/lib/libsendfile/common/sendfile.c b/usr/src/lib/libsendfile/common/sendfile.c index b7ed7fdca5..f4f7724843 100644 --- a/usr/src/lib/libsendfile/common/sendfile.c +++ b/usr/src/lib/libsendfile/common/sendfile.c @@ -1,10 +1,10 @@ + /* * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -20,7 +20,7 @@ * CDDL HEADER END */ /* - * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -49,8 +49,13 @@ _sendfilev(int sock, const struct sendfilevec *vec, int sfvcnt, size_t *xferred) error = __systemcall(&rval, SYS_sendfilev, SENDFILEV, sock, vec, sfvcnt, xferred); - if (error != 0) - (void) __set_errno(error); + if (error != 0) { + if (error == EINTR && *xferred != 0) { + rval.sys_rval1 = *xferred; + } else { + (void) __set_errno(error); + } + } return ((ssize_t)rval.sys_rval1); } @@ -69,8 +74,13 @@ _sendfile(int sock, int fd, off_t *off, size_t len) error = __systemcall(&rval, SYS_sendfilev, SENDFILEV, sock, &sfv, 1, &xferred); *off += xferred; - if (error != 0) - (void) __set_errno(error); + if (error != 0) { + if (error == EINTR && xferred != 0) { + rval.sys_rval1 = xferred; + } else { + (void) __set_errno(error); + } + } return ((ssize_t)rval.sys_rval1); } @@ -88,8 +98,13 @@ _sendfilev64(int sock, const struct sendfilevec64 *vec, int sfvcnt, error = __systemcall(&rval, SYS_sendfilev, SENDFILEV64, sock, vec, sfvcnt, xferred); - if (error != 0) - (void) __set_errno(error); + if (error != 0) { + if (error == EINTR && *xferred != 0) { + rval.sys_rval1 = *xferred; + } else { + (void) __set_errno(error); + } + } return ((ssize_t)rval.sys_rval1); } @@ -108,8 +123,13 @@ _sendfile64(int sock, int fd, off64_t *off, size_t len) error = __systemcall(&rval, SYS_sendfilev, SENDFILEV64, sock, &sfv, 1, &xferred); *off += xferred; - if (error != 0) - (void) __set_errno(error); + if (error != 0) { + if (error == EINTR && xferred != 0) { + rval.sys_rval1 = xferred; + } else { + (void) __set_errno(error); + } + } return ((ssize_t)rval.sys_rval1); } #endif |