unix: suppress EINTR/EINPROGRESS in uv_fs_close()
close() is interruptible, meaning that a signal delivered when the close() system call is executing, can result in a return value of -1 with errno set to EINTR or EINPROGRESS. A survey of supported Unices suggests the file descriptor is in fact closed and so there is nothing to do except ignore the error. Libuv already handled it correctly for internal file descriptors throug uv__close() and uv__close_nocheckstdio() but uv_fs_close() did not until now. PR-URL: https://github.com/libuv/libuv/pull/2236 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Jameson Nash <vtjnash@gmail.com> Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This commit is contained in:
parent
fd67cd538c
commit
a40a5e897d
@ -142,6 +142,18 @@ extern char *mkdtemp(char *template); /* See issue #740 on AIX < 7 */
|
||||
while (0)
|
||||
|
||||
|
||||
static int uv__fs_close(int fd) {
|
||||
int rc;
|
||||
|
||||
rc = close(fd);
|
||||
if (rc == -1)
|
||||
if (errno == EINTR || errno == EINPROGRESS)
|
||||
rc = 0; /* The close is in progress, not an error. */
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
static ssize_t uv__fs_fsync(uv_fs_t* req) {
|
||||
#if defined(__APPLE__)
|
||||
/* Apple's fdatasync and fsync explicitly do NOT flush the drive write cache
|
||||
@ -1289,7 +1301,7 @@ static void uv__fs_work(struct uv__work* w) {
|
||||
X(ACCESS, access(req->path, req->flags));
|
||||
X(CHMOD, chmod(req->path, req->mode));
|
||||
X(CHOWN, chown(req->path, req->uid, req->gid));
|
||||
X(CLOSE, close(req->file));
|
||||
X(CLOSE, uv__fs_close(req->file));
|
||||
X(COPYFILE, uv__fs_copyfile(req));
|
||||
X(FCHMOD, fchmod(req->file, req->mode));
|
||||
X(FCHOWN, fchown(req->file, req->uid, req->gid));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user