Skip to content

Commit 55f8fc3

Browse files
committed
portability enhancements
1 parent 2ab0f11 commit 55f8fc3

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/backend/postmaster/pgstat.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
*
2020
* Copyright (c) 2001, PostgreSQL Global Development Group
2121
*
22-
* $Id: pgstat.c,v 1.2 2001/06/29 16:29:37 wieck Exp $
22+
* $Id: pgstat.c,v 1.3 2001/06/30 19:01:27 petere Exp $
2323
* ----------
2424
*/
25-
#include <stdio.h>
26-
#include <stdlib.h>
25+
#include "postgres.h"
26+
2727
#include <unistd.h>
2828
#include <fcntl.h>
2929

@@ -37,8 +37,6 @@
3737
#include <errno.h>
3838
#include <signal.h>
3939

40-
#include "postgres.h"
41-
4240
#include "miscadmin.h"
4341
#include "utils/memutils.h"
4442
#include "storage/backendid.h"
@@ -88,8 +86,8 @@ static HTAB *pgStatBeDead = NULL;
8886
static PgStat_StatBeEntry *pgStatBeTable = NULL;
8987
static int pgStatNumBackends = 0;
9088

91-
static char pgStat_tmpfname[PATH_MAX];
92-
static char pgStat_fname[PATH_MAX];
89+
static char pgStat_tmpfname[MAXPGPATH];
90+
static char pgStat_fname[MAXPGPATH];
9391

9492

9593
/* ----------
@@ -140,9 +138,9 @@ pgstat_init(void)
140138
/*
141139
* Initialize the filenames for the status reports.
142140
*/
143-
snprintf(pgStat_tmpfname, PATH_MAX - 1,
141+
snprintf(pgStat_tmpfname, MAXPGPATH,
144142
PGSTAT_STAT_TMPFILE, DataDir, getpid());
145-
snprintf(pgStat_fname, PATH_MAX - 1,
143+
snprintf(pgStat_fname, MAXPGPATH,
146144
PGSTAT_STAT_FILENAME, DataDir);
147145

148146
/*
@@ -1696,7 +1694,7 @@ pgstat_write_statsfile(void)
16961694
* Open the statistics temp file to write out
16971695
* the current values.
16981696
*/
1699-
fpout = fopen(pgStat_tmpfname, "w");
1697+
fpout = fopen(pgStat_tmpfname, PG_BINARY_W);
17001698
if (fpout == NULL)
17011699
{
17021700
fprintf(stderr, "PGSTAT: cannot open temp stats file\nPGSTAT: ");
@@ -1954,7 +1952,7 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb,
19541952
* simply return zero for anything and the collector simply
19551953
* starts from scratch with empty counters.
19561954
*/
1957-
if ((fpin = fopen(pgStat_fname, "r")) == NULL)
1955+
if ((fpin = fopen(pgStat_fname, PG_BINARY_R)) == NULL)
19581956
return;
19591957

19601958
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy