diff options
Diffstat (limited to 'src/os_posix')
-rw-r--r-- | src/os_posix/os_dir.c | 12 | ||||
-rw-r--r-- | src/os_posix/os_errno.c | 71 | ||||
-rw-r--r-- | src/os_posix/os_fs.c | 20 | ||||
-rw-r--r-- | src/os_posix/os_map.c | 4 | ||||
-rw-r--r-- | src/os_posix/os_thread.c | 2 | ||||
-rw-r--r-- | src/os_posix/os_time.c | 4 |
6 files changed, 25 insertions, 88 deletions
diff --git a/src/os_posix/os_dir.c b/src/os_posix/os_dir.c index ea0ca11fa54..768a1324cd8 100644 --- a/src/os_posix/os_dir.c +++ b/src/os_posix/os_dir.c @@ -25,6 +25,7 @@ __wt_posix_directory_list(WT_FILE_SYSTEM *file_system, WT_SESSION_IMPL *session; size_t dirallocsz; uint32_t count; + int tret; char **entries; WT_UNUSED(file_system); @@ -64,8 +65,15 @@ __wt_posix_directory_list(WT_FILE_SYSTEM *file_system, *dirlistp = entries; *countp = count; -err: if (dirp != NULL) - (void)closedir(dirp); +err: if (dirp != NULL) { + WT_SYSCALL(closedir(dirp), tret); + if (tret != 0) { + __wt_err(session, tret, + "%s: directory-list: closedir", directory); + if (ret == 0) + ret = tret; + } + } if (ret == 0) return (0); diff --git a/src/os_posix/os_errno.c b/src/os_posix/os_errno.c deleted file mode 100644 index a0f1202c6ef..00000000000 --- a/src/os_posix/os_errno.c +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * Copyright (c) 2014-2016 MongoDB, Inc. - * Copyright (c) 2008-2014 WiredTiger, Inc. - * All rights reserved. - * - * See the file LICENSE for redistribution information. - */ - -#include "wt_internal.h" - -/* - * __wt_errno -- - * Return errno, or WT_ERROR if errno not set. - */ -int -__wt_errno(void) -{ - /* - * Called when we know an error occurred, and we want the system - * error code, but there's some chance it's not set. - */ - return (errno == 0 ? WT_ERROR : errno); -} - -/* - * __wt_map_error_rdonly -- - * Map an error into a WiredTiger error code specific for - * read-only operation which intercepts based on certain types - * of failures. - */ -int -__wt_map_error_rdonly(int error) -{ - if (error == ENOENT) - return (WT_NOTFOUND); - else if (error == EACCES) - return (WT_PERM_DENIED); - return (error); -} - -/* - * __wt_strerror -- - * POSIX implementation of WT_SESSION.strerror and wiredtiger_strerror. - */ -const char * -__wt_strerror(WT_SESSION_IMPL *session, int error, char *errbuf, size_t errlen) -{ - const char *p; - - /* - * Check for a WiredTiger or POSIX constant string, no buffer needed. - */ - if ((p = __wt_wiredtiger_error(error)) != NULL) - return (p); - - /* - * When called from wiredtiger_strerror, write a passed-in buffer. - * When called from WT_SESSION.strerror, write the session's buffer. - * - * Fallback to a generic message. - */ - if (session == NULL && - snprintf(errbuf, errlen, "error return: %d", error) > 0) - return (errbuf); - if (session != NULL && __wt_buf_fmt( - session, &session->err, "error return: %d", error) == 0) - return (session->err.data); - - /* Defeated. */ - return ("Unable to return error string"); -} diff --git a/src/os_posix/os_fs.c b/src/os_posix/os_fs.c index 1cfa8fd2d2d..86fa2e8f117 100644 --- a/src/os_posix/os_fs.c +++ b/src/os_posix/os_fs.c @@ -98,7 +98,7 @@ __posix_directory_sync( ret = __posix_sync(session, fd, path, "directory-sync"); - WT_SYSCALL_RETRY(close(fd), tret); + WT_SYSCALL(close(fd), tret); if (tret != 0) { __wt_err(session, tret, "%s: directory-sync: close", path); if (ret == 0) @@ -124,7 +124,7 @@ __posix_fs_exist(WT_FILE_SYSTEM *file_system, session = (WT_SESSION_IMPL *)wt_session; - WT_SYSCALL_RETRY(stat(name, &sb), ret); + WT_SYSCALL(stat(name, &sb), ret); if (ret == 0) { *existp = true; return (0); @@ -158,7 +158,7 @@ __posix_fs_remove( * where we're not doing any special checking for standards compliance, * using unlink may be marginally safer. */ - WT_SYSCALL_RETRY(unlink(name), ret); + WT_SYSCALL(unlink(name), ret); if (ret == 0) return (0); WT_RET_MSG(session, ret, "%s: file-remove: unlink", name); @@ -186,7 +186,7 @@ __posix_fs_rename(WT_FILE_SYSTEM *file_system, * with the wrong errno (if errno is garbage), or the generic WT_ERROR * return (if errno is 0), but we've done the best we can. */ - WT_SYSCALL_RETRY(rename(from, to) != 0 ? -1 : 0, ret); + WT_SYSCALL(rename(from, to) != 0 ? -1 : 0, ret); if (ret == 0) return (0); WT_RET_MSG(session, ret, "%s to %s: file-rename: rename", from, to); @@ -208,7 +208,7 @@ __posix_fs_size(WT_FILE_SYSTEM *file_system, session = (WT_SESSION_IMPL *)wt_session; - WT_SYSCALL_RETRY(stat(name, &sb), ret); + WT_SYSCALL(stat(name, &sb), ret); if (ret == 0) { *sizep = sb.st_size; return (0); @@ -232,7 +232,7 @@ __posix_file_advise(WT_FILE_HANDLE *file_handle, WT_SESSION *wt_session, session = (WT_SESSION_IMPL *)wt_session; pfh = (WT_FILE_HANDLE_POSIX *)file_handle; - WT_SYSCALL_RETRY(posix_fadvise(pfh->fd, offset, len, advice), ret); + WT_SYSCALL(posix_fadvise(pfh->fd, offset, len, advice), ret); if (ret == 0) return (0); @@ -268,7 +268,7 @@ __posix_file_close(WT_FILE_HANDLE *file_handle, WT_SESSION *wt_session) /* Close the file handle. */ if (pfh->fd != -1) { - WT_SYSCALL_RETRY(close(pfh->fd), ret); + WT_SYSCALL(close(pfh->fd), ret); if (ret != 0) __wt_err(session, ret, "%s: handle-close: close", file_handle->name); @@ -309,7 +309,7 @@ __posix_file_lock( fl.l_type = lock ? F_WRLCK : F_UNLCK; fl.l_whence = SEEK_SET; - WT_SYSCALL_RETRY(fcntl(pfh->fd, F_SETLK, &fl) == -1 ? -1 : 0, ret); + WT_SYSCALL(fcntl(pfh->fd, F_SETLK, &fl) == -1 ? -1 : 0, ret); if (ret == 0) return (0); WT_RET_MSG(session, ret, "%s: handle-lock: fcntl", file_handle->name); @@ -369,7 +369,7 @@ __posix_file_size( session = (WT_SESSION_IMPL *)wt_session; pfh = (WT_FILE_HANDLE_POSIX *)file_handle; - WT_SYSCALL_RETRY(fstat(pfh->fd, &sb), ret); + WT_SYSCALL(fstat(pfh->fd, &sb), ret); if (ret == 0) { *sizep = sb.st_size; return (0); @@ -617,7 +617,7 @@ __posix_open_file(WT_FILE_SYSTEM *file_system, WT_SESSION *wt_session, * interesting. */ if (!pfh->direct_io && file_type == WT_OPEN_FILE_TYPE_DATA) { - WT_SYSCALL_RETRY( + WT_SYSCALL( posix_fadvise(pfh->fd, 0, 0, POSIX_FADV_RANDOM), ret); if (ret != 0) WT_ERR_MSG(session, ret, diff --git a/src/os_posix/os_map.c b/src/os_posix/os_map.c index d89ba4d7c26..b33f6d82e34 100644 --- a/src/os_posix/os_map.c +++ b/src/os_posix/os_map.c @@ -105,7 +105,7 @@ __wt_posix_map_preload(WT_FILE_HANDLE *fh, if (length <= (size_t)conn->page_size) return (0); - WT_SYSCALL_RETRY(posix_madvise(blk, length, POSIX_MADV_WILLNEED), ret); + WT_SYSCALL(posix_madvise(blk, length, POSIX_MADV_WILLNEED), ret); if (ret == 0) return (0); @@ -138,7 +138,7 @@ __wt_posix_map_discard(WT_FILE_HANDLE *fh, blk = (void *)((uintptr_t)map & ~(uintptr_t)(conn->page_size - 1)); length += WT_PTRDIFF(map, blk); - WT_SYSCALL_RETRY(posix_madvise(blk, length, POSIX_MADV_DONTNEED), ret); + WT_SYSCALL(posix_madvise(blk, length, POSIX_MADV_DONTNEED), ret); if (ret == 0) return (0); diff --git a/src/os_posix/os_thread.c b/src/os_posix/os_thread.c index 35a23622ddc..e57a308c9b0 100644 --- a/src/os_posix/os_thread.c +++ b/src/os_posix/os_thread.c @@ -34,7 +34,7 @@ __wt_thread_join(WT_SESSION_IMPL *session, wt_thread_t tid) { WT_DECL_RET; - WT_SYSCALL_RETRY(pthread_join(tid, NULL), ret); + WT_SYSCALL(pthread_join(tid, NULL), ret); if (ret == 0) return (0); diff --git a/src/os_posix/os_time.c b/src/os_posix/os_time.c index 0e5a1cdadfb..b1b22a8e684 100644 --- a/src/os_posix/os_time.c +++ b/src/os_posix/os_time.c @@ -18,14 +18,14 @@ __wt_epoch(WT_SESSION_IMPL *session, struct timespec *tsp) WT_DECL_RET; #if defined(HAVE_CLOCK_GETTIME) - WT_SYSCALL_RETRY(clock_gettime(CLOCK_REALTIME, tsp), ret); + WT_SYSCALL(clock_gettime(CLOCK_REALTIME, tsp), ret); if (ret == 0) return (0); WT_RET_MSG(session, ret, "clock_gettime"); #elif defined(HAVE_GETTIMEOFDAY) struct timeval v; - WT_SYSCALL_RETRY(gettimeofday(&v, NULL), ret); + WT_SYSCALL(gettimeofday(&v, NULL), ret); if (ret == 0) { tsp->tv_sec = v.tv_sec; tsp->tv_nsec = v.tv_usec * WT_THOUSAND; |