提交 86ad18ce 编写于 作者: H Heikki Linnakangas

Revert some superfluous error message changes vs. upstream.

Will make merging code to fd.c easier.
上级 64cd603a
...@@ -451,7 +451,7 @@ set_max_safe_fds(void) ...@@ -451,7 +451,7 @@ set_max_safe_fds(void)
if (max_safe_fds < FD_MINFREE) if (max_safe_fds < FD_MINFREE)
ereport(FATAL, ereport(FATAL,
(errcode(ERRCODE_INSUFFICIENT_RESOURCES), (errcode(ERRCODE_INSUFFICIENT_RESOURCES),
errmsg("insufficient file handles available to start server process"), errmsg("insufficient file descriptors available to start server process"),
errdetail("System allows %d, we need at least %d.", errdetail("System allows %d, we need at least %d.",
max_safe_fds + NUM_RESERVED_FDS, max_safe_fds + NUM_RESERVED_FDS,
FD_MINFREE + NUM_RESERVED_FDS))); FD_MINFREE + NUM_RESERVED_FDS)));
...@@ -493,7 +493,7 @@ tryAgain: ...@@ -493,7 +493,7 @@ tryAgain:
ereport(LOG, ereport(LOG,
(errcode(ERRCODE_INSUFFICIENT_RESOURCES), (errcode(ERRCODE_INSUFFICIENT_RESOURCES),
errmsg("out of file handles: %m; release and retry"))); errmsg("out of file descriptors: %m; release and retry")));
errno = 0; errno = 0;
if (ReleaseLruFile()) if (ReleaseLruFile())
goto tryAgain; goto tryAgain;
...@@ -564,8 +564,7 @@ LruDelete(File file) ...@@ -564,8 +564,7 @@ LruDelete(File file)
/* close the file */ /* close the file */
if (close(vfdP->fd)) if (close(vfdP->fd))
elog(ERROR, "could not close file \"%s\": %m", elog(ERROR, "could not close file \"%s\": %m", vfdP->fileName);
vfdP->fileName);
--nfile; --nfile;
vfdP->fd = VFD_CLOSED; vfdP->fd = VFD_CLOSED;
...@@ -1366,7 +1365,8 @@ FileSeek(File file, int64 offset, int whence) ...@@ -1366,7 +1365,8 @@ FileSeek(File file, int64 offset, int whence)
switch (whence) switch (whence)
{ {
case SEEK_SET: case SEEK_SET:
Assert(offset >= INT64CONST(0)); if (offset < 0)
elog(ERROR, "invalid seek offset: %ld", offset);
VfdCache[file].seekPos = offset; VfdCache[file].seekPos = offset;
break; break;
case SEEK_CUR: case SEEK_CUR:
...@@ -1380,7 +1380,7 @@ FileSeek(File file, int64 offset, int whence) ...@@ -1380,7 +1380,7 @@ FileSeek(File file, int64 offset, int whence)
offset, whence); offset, whence);
break; break;
default: default:
Assert(!"invalid whence"); elog(ERROR, "invalid whence: %d", whence);
break; break;
} }
} }
...@@ -1389,7 +1389,8 @@ FileSeek(File file, int64 offset, int whence) ...@@ -1389,7 +1389,8 @@ FileSeek(File file, int64 offset, int whence)
switch (whence) switch (whence)
{ {
case SEEK_SET: case SEEK_SET:
Assert(offset >= INT64CONST(0)); if (offset < 0)
elog(ERROR, "invalid seek offset: " INT64_FORMAT, offset);
if (VfdCache[file].seekPos != offset) if (VfdCache[file].seekPos != offset)
VfdCache[file].seekPos = pg_lseek64(VfdCache[file].fd, VfdCache[file].seekPos = pg_lseek64(VfdCache[file].fd,
offset, whence); offset, whence);
...@@ -1404,7 +1405,7 @@ FileSeek(File file, int64 offset, int whence) ...@@ -1404,7 +1405,7 @@ FileSeek(File file, int64 offset, int whence)
offset, whence); offset, whence);
break; break;
default: default:
Assert(!"invalid whence"); elog(ERROR, "invalid whence: %d", whence);
break; break;
} }
} }
...@@ -1506,7 +1507,7 @@ AllocateFile(const char *name, const char *mode) ...@@ -1506,7 +1507,7 @@ AllocateFile(const char *name, const char *mode)
*/ */
if (numAllocatedDescs >= MAX_ALLOCATED_DESCS || if (numAllocatedDescs >= MAX_ALLOCATED_DESCS ||
numAllocatedDescs >= max_safe_fds - 1) numAllocatedDescs >= max_safe_fds - 1)
elog(ERROR, "could not allocate file: out of file handles"); elog(ERROR, "too many private files demanded");
TryAgain: TryAgain:
if ((file = fopen(name, mode)) != NULL) if ((file = fopen(name, mode)) != NULL)
...@@ -1526,7 +1527,7 @@ TryAgain: ...@@ -1526,7 +1527,7 @@ TryAgain:
ereport(LOG, ereport(LOG,
(errcode(ERRCODE_INSUFFICIENT_RESOURCES), (errcode(ERRCODE_INSUFFICIENT_RESOURCES),
errmsg("out of file handles: %m; release and retry"))); errmsg("out of file descriptors: %m; release and retry")));
errno = 0; errno = 0;
if (ReleaseLruFile()) if (ReleaseLruFile())
goto TryAgain; goto TryAgain;
...@@ -1544,7 +1545,7 @@ TryAgain: ...@@ -1544,7 +1545,7 @@ TryAgain:
static int static int
FreeDesc(AllocateDesc *desc) FreeDesc(AllocateDesc *desc)
{ {
int result = 0; int result;
/* Close the underlying object */ /* Close the underlying object */
switch (desc->kind) switch (desc->kind)
...@@ -1556,7 +1557,8 @@ FreeDesc(AllocateDesc *desc) ...@@ -1556,7 +1557,8 @@ FreeDesc(AllocateDesc *desc)
result = closedir(desc->desc.dir); result = closedir(desc->desc.dir);
break; break;
default: default:
Assert(false); elog(ERROR, "AllocateDesc kind not recognized");
result = 0; /* keep compiler quiet */
break; break;
} }
...@@ -1590,7 +1592,7 @@ FreeFile(FILE *file) ...@@ -1590,7 +1592,7 @@ FreeFile(FILE *file)
} }
/* Only get here if someone passes us a file not in allocatedDescs */ /* Only get here if someone passes us a file not in allocatedDescs */
elog(LOG, "file to be closed was not opened through the virtual file descriptor system"); elog(WARNING, "file passed to FreeFile was not obtained from AllocateFile");
Assert(false); Assert(false);
return fclose(file); return fclose(file);
...@@ -1621,7 +1623,7 @@ AllocateDir(const char *dirname) ...@@ -1621,7 +1623,7 @@ AllocateDir(const char *dirname)
*/ */
if (numAllocatedDescs >= MAX_ALLOCATED_DESCS || if (numAllocatedDescs >= MAX_ALLOCATED_DESCS ||
numAllocatedDescs >= max_safe_fds - 1) numAllocatedDescs >= max_safe_fds - 1)
elog(ERROR, "could not allocate directory: out of file handles"); elog(ERROR, "too many private dirs demanded");
TryAgain: TryAgain:
if ((dir = opendir(dirname)) != NULL) if ((dir = opendir(dirname)) != NULL)
...@@ -1641,7 +1643,7 @@ TryAgain: ...@@ -1641,7 +1643,7 @@ TryAgain:
ereport(LOG, ereport(LOG,
(errcode(ERRCODE_INSUFFICIENT_RESOURCES), (errcode(ERRCODE_INSUFFICIENT_RESOURCES),
errmsg("out of file handles: %m; release and retry"))); errmsg("out of file descriptors: %m; release and retry")));
errno = 0; errno = 0;
if (ReleaseLruFile()) if (ReleaseLruFile())
goto TryAgain; goto TryAgain;
...@@ -1728,7 +1730,7 @@ FreeDir(DIR *dir) ...@@ -1728,7 +1730,7 @@ FreeDir(DIR *dir)
} }
/* Only get here if someone passes us a dir not in allocatedDescs */ /* Only get here if someone passes us a dir not in allocatedDescs */
elog(LOG, "directory to be closed was not opened through the virtual file descriptor system"); elog(WARNING, "dir passed to FreeDir was not obtained from AllocateDir");
Assert(false); Assert(false);
return closedir(dir); return closedir(dir);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册