Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd9250da

Browse files
committed
Fixups for dsm.c's file descriptor handling.
Per complaint from Tom Lane.
1 parent33d3f55 commitd9250da

File tree

1 file changed

+7
-4
lines changed
  • src/backend/storage/ipc

1 file changed

+7
-4
lines changed

‎src/backend/storage/ipc/dsm.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,14 +301,14 @@ dsm_cleanup_for_mmap(void)
301301
structdirent*dent;
302302

303303
/* Open the directory; can't use AllocateDir in postmaster. */
304-
if ((dir=opendir(PG_DYNSHMEM_DIR))==NULL)
304+
if ((dir=AllocateDir(PG_DYNSHMEM_DIR))==NULL)
305305
ereport(ERROR,
306306
(errcode_for_file_access(),
307307
errmsg("could not open directory \"%s\": %m",
308308
PG_DYNSHMEM_DIR)));
309309

310310
/* Scan for something with a name of the correct format. */
311-
while ((dent=readdir(dir))!=NULL)
311+
while ((dent=ReadDir(dir,PG_DYNSHMEM_DIR))!=NULL)
312312
{
313313
if (strncmp(dent->d_name,PG_DYNSHMEM_MMAP_FILE_PREFIX,
314314
strlen(PG_DYNSHMEM_MMAP_FILE_PREFIX))==0)
@@ -335,7 +335,7 @@ dsm_cleanup_for_mmap(void)
335335
}
336336

337337
/* Cleanup complete. */
338-
closedir(dir);
338+
FreeDir(dir);
339339
}
340340

341341
/*
@@ -357,7 +357,7 @@ dsm_read_state_file(dsm_handle *h)
357357
dsm_handlehandle;
358358

359359
/* Read the state file to get the ID of the old control segment. */
360-
statefd=open(PG_DYNSHMEM_STATE_FILE,O_RDONLY |PG_BINARY,0);
360+
statefd=BasicOpenFile(PG_DYNSHMEM_STATE_FILE,O_RDONLY |PG_BINARY,0);
361361
if (statefd<0)
362362
{
363363
if (errno==ENOENT)
@@ -369,10 +369,13 @@ dsm_read_state_file(dsm_handle *h)
369369
}
370370
nbytes=read(statefd,statebuf,PG_DYNSHMEM_STATE_BUFSIZ-1);
371371
if (nbytes<0)
372+
{
373+
close(statefd);
372374
ereport(ERROR,
373375
(errcode_for_file_access(),
374376
errmsg("could not read file \"%s\": %m",
375377
PG_DYNSHMEM_STATE_FILE)));
378+
}
376379
/* make sure buffer is NUL terminated */
377380
statebuf[nbytes]='\0';
378381
close(statefd);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp