Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 209aa77

Browse files
committed
New ps display code, works on more platforms.
Install a default configuration file. Clean up some funny business in the config file code.
1 parent 2ea370a commit 209aa77

File tree

20 files changed

+978
-815
lines changed

20 files changed

+978
-815
lines changed

src/backend/Makefile

+5-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#
3535
#
3636
# IDENTIFICATION
37-
# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.52 2000/05/31 00:28:13 petere Exp $
37+
# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.53 2000/06/04 01:44:28 petere Exp $
3838
#
3939
#-------------------------------------------------------------------------
4040

@@ -205,7 +205,8 @@ endif
205205
install-templates: $(TEMPLATEDIR) \
206206
global1.bki.source local1_template1.bki.source \
207207
global1.description local1_template1.description \
208-
libpq/pg_hba.conf.sample libpq/pg_ident.conf.sample
208+
libpq/pg_hba.conf.sample libpq/pg_ident.conf.sample \
209+
utils/misc/postgresql.conf.sample
209210
$(INSTALL) $(INSTLOPTS) global1.bki.source \
210211
$(TEMPLATEDIR)/global1.bki.source
211212
$(INSTALL) $(INSTLOPTS) global1.description \
@@ -218,6 +219,8 @@ install-templates: $(TEMPLATEDIR) \
218219
$(TEMPLATEDIR)/pg_hba.conf.sample
219220
$(INSTALL) $(INSTLOPTS) libpq/pg_ident.conf.sample \
220221
$(TEMPLATEDIR)/pg_ident.conf.sample
222+
$(INSTALL) $(INSTLOPTS) utils/misc/postgresql.conf.sample \
223+
$(TEMPLATEDIR)/postgresql.conf.sample
221224

222225
install-headers: prebuildheaders $(SRCDIR)/include/config.h
223226
-@if [ ! -d $(HEADERDIR) ]; then mkdir $(HEADERDIR); fi

src/backend/commands/async.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.62 2000/05/31 00:28:15 petere Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.63 2000/06/04 01:44:29 petere Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -771,7 +771,7 @@ ProcessIncomingNotify(void)
771771
if (Trace_notify)
772772
elog(DEBUG, "ProcessIncomingNotify");
773773

774-
PS_SET_STATUS("async_notify");
774+
set_ps_display("async_notify");
775775

776776
notifyInterruptOccurred = 0;
777777

@@ -841,7 +841,7 @@ ProcessIncomingNotify(void)
841841
*/
842842
pq_flush();
843843

844-
PS_SET_STATUS("idle");
844+
set_ps_display("idle");
845845

846846
if (Trace_notify)
847847
elog(DEBUG, "ProcessIncomingNotify: done");

src/backend/libpq/pqcomm.c

+4-5
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
3030
* Portions Copyright (c) 1994, Regents of the University of California
3131
*
32-
* $Id: pqcomm.c,v 1.94 2000/06/02 15:57:21 momjian Exp $
32+
* $Id: pqcomm.c,v 1.95 2000/06/04 01:44:30 petere Exp $
3333
*
3434
*-------------------------------------------------------------------------
3535
*/
@@ -182,12 +182,11 @@ StreamDoUnlink()
182182
*/
183183

184184
int
185-
StreamServerPort(char *hostName, unsigned short portName, int *fdP)
185+
StreamServerPort(int family, unsigned short portName, int *fdP)
186186
{
187187
SockAddr saddr;
188188
int fd,
189-
err,
190-
family;
189+
err;
191190
size_t len;
192191
int one = 1;
193192

@@ -196,7 +195,7 @@ StreamServerPort(char *hostName, unsigned short portName, int *fdP)
196195

197196
#endif
198197

199-
family = ((hostName != NULL) ? AF_INET : AF_UNIX);
198+
Assert(family == AF_INET || family == AF_UNIX);
200199

201200
if ((fd = socket(family, SOCK_STREAM, 0)) < 0)
202201
{

src/backend/postmaster/postmaster.c

+13-112
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.145 2000/06/02 15:57:22 momjian Exp $
14+
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.146 2000/06/04 01:44:31 petere Exp $
1515
*
1616
* NOTES
1717
*
@@ -33,6 +33,8 @@
3333
*
3434
*-------------------------------------------------------------------------
3535
*/
36+
#include "postgres.h"
37+
3638
#include <unistd.h>
3739
#include <signal.h>
3840
#include <sys/wait.h>
@@ -46,16 +48,11 @@
4648
#include <time.h>
4749
#include <sys/param.h>
4850

49-
#include "postgres.h"
5051
/* moved here to prevent double define */
5152
#ifdef HAVE_NETDB_H
5253
#include <netdb.h>
5354
#endif
5455

55-
#ifndef MAXHOSTNAMELEN
56-
#define MAXHOSTNAMELEN 256
57-
#endif
58-
5956
#ifdef HAVE_LIMITS_H
6057
#include <limits.h>
6158
#else
@@ -72,10 +69,6 @@
7269
#include "getopt.h"
7370
#endif
7471

75-
#ifndef HAVE_GETHOSTNAME
76-
#include "port-protos.h"
77-
#endif
78-
7972
#include "commands/async.h"
8073
#include "lib/dllist.h"
8174
#include "libpq/auth.h"
@@ -191,8 +184,6 @@ static volatile bool got_SIGHUP = false;
191184
/*
192185
* Default Values
193186
*/
194-
static char Execfile[MAXPGPATH];
195-
196187
static int ServerSock_INET = INVALID_SOCK; /* stream socket server */
197188

198189
#if !defined(__CYGWIN32__) && !defined(__QNX__)
@@ -278,7 +269,7 @@ static void SignalChildren(SIGNAL_ARGS);
278269
static int CountChildren(void);
279270
static int
280271
SetOptsFile(char *progname, int port, char *datadir,
281-
int assert, int nbuf, char *execfile,
272+
int assert, int nbuf,
282273
int debuglvl, int netserver,
283274
#ifdef USE_SSL
284275
int securenetserver,
@@ -368,61 +359,17 @@ int
368359
PostmasterMain(int argc, char *argv[])
369360
{
370361
int opt;
371-
char *hostName;
372362
int status;
373363
int silentflag = 0;
374364
bool DataDirOK; /* We have a usable PGDATA value */
375-
char hostbuf[MAXHOSTNAMELEN];
376-
int nonblank_argc;
377365
char original_extraoptions[MAXPGPATH];
378366

379367
*original_extraoptions = '\0';
380368

381-
#ifndef HAVE_SETPROCTITLE
382-
/*
383-
* We need four params so we can display status. If we don't get
384-
* them from the user, let's make them ourselves.
385-
*/
386-
if (argc < 5)
387-
{
388-
int i;
389-
char *new_argv[6];
390-
391-
for (i = 0; i < argc; i++)
392-
new_argv[i] = argv[i];
393-
for (; i < 5; i++)
394-
new_argv[i] = "";
395-
new_argv[5] = NULL;
396-
397-
if (!Execfile[0] && FindExec(Execfile, argv[0], "postmaster") < 0)
398-
{
399-
fprintf(stderr, "%s: could not find postmaster to execute...\n",
400-
argv[0]);
401-
exit(1);
402-
}
403-
new_argv[0] = Execfile;
404-
405-
execv(new_argv[0], new_argv);
406-
407-
/* How did we get here? Error! */
408-
perror(new_argv[0]);
409-
fprintf(stderr, "PostmasterMain execv failed on %s\n", argv[0]);
410-
exit(1);
411-
}
412-
#endif
413-
414369
progname = argv[0];
415370
real_argv = argv;
416371
real_argc = argc;
417372

418-
/*
419-
* don't process any dummy args we placed at the end for status
420-
* display
421-
*/
422-
for (nonblank_argc = argc; nonblank_argc > 0; nonblank_argc--)
423-
if (argv[nonblank_argc - 1] != NULL && argv[nonblank_argc - 1][0] != '\0')
424-
break;
425-
426373
/*
427374
* for security, no dir or file created can be group or other
428375
* accessible
@@ -431,13 +378,6 @@ PostmasterMain(int argc, char *argv[])
431378

432379
ResetAllOptions();
433380

434-
if (!(hostName = getenv("PGHOST")))
435-
{
436-
if (gethostname(hostbuf, MAXHOSTNAMELEN) < 0)
437-
strcpy(hostbuf, "localhost");
438-
hostName = hostbuf;
439-
}
440-
441381
MyProcPid = getpid();
442382
DataDir = getenv("PGDATA"); /* default value */
443383

@@ -455,7 +395,7 @@ PostmasterMain(int argc, char *argv[])
455395
* will occur.
456396
*/
457397
opterr = 1;
458-
while ((opt = getopt(nonblank_argc, argv, "A:a:B:b:D:d:Film:MN:no:p:Ss-:")) != EOF)
398+
while ((opt = getopt(argc, argv, "A:a:B:b:D:d:Film:MN:no:p:Ss-:")) != EOF)
459399
{
460400
if (opt == 'D')
461401
DataDir = optarg;
@@ -472,7 +412,7 @@ PostmasterMain(int argc, char *argv[])
472412
ProcessConfigFile(PGC_POSTMASTER);
473413

474414
IgnoreSystemIndexes(false);
475-
while ((opt = getopt(nonblank_argc, argv, "A:a:B:b:D:d:Film:MN:no:p:Ss-:")) != EOF)
415+
while ((opt = getopt(argc, argv, "A:a:B:b:D:d:Film:MN:no:p:Ss-:")) != EOF)
476416
{
477417
switch (opt)
478418
{
@@ -496,15 +436,7 @@ PostmasterMain(int argc, char *argv[])
496436
NBuffers = atoi(optarg);
497437
break;
498438
case 'b':
499-
/* Set the backend executable file to use. */
500-
if (!ValidateBinary(optarg))
501-
StrNCpy(Execfile, optarg, MAXPGPATH);
502-
else
503-
{
504-
fprintf(stderr, "%s: invalid backend \"%s\"\n",
505-
progname, optarg);
506-
exit(2);
507-
}
439+
/* Can no longer set the backend executable file to use. */
508440
break;
509441
case 'D':
510442
/* already done above */
@@ -630,13 +562,6 @@ PostmasterMain(int argc, char *argv[])
630562
exit(1);
631563
}
632564

633-
if (!Execfile[0] && FindExec(Execfile, argv[0], "postgres") < 0)
634-
{
635-
fprintf(stderr, "%s: could not find backend to execute...\n",
636-
argv[0]);
637-
exit(1);
638-
}
639-
640565
#ifdef USE_SSL
641566
if (!NetServer && SecureNetServer)
642567
{
@@ -649,7 +574,7 @@ PostmasterMain(int argc, char *argv[])
649574

650575
if (NetServer)
651576
{
652-
status = StreamServerPort(hostName, (unsigned short)PostPortName, &ServerSock_INET);
577+
status = StreamServerPort(AF_INET, (unsigned short)PostPortName, &ServerSock_INET);
653578
if (status != STATUS_OK)
654579
{
655580
fprintf(stderr, "%s: cannot create INET stream port\n",
@@ -659,7 +584,7 @@ PostmasterMain(int argc, char *argv[])
659584
}
660585

661586
#if !defined(__CYGWIN32__) && !defined(__QNX__)
662-
status = StreamServerPort(NULL, (unsigned short)PostPortName, &ServerSock_UNIX);
587+
status = StreamServerPort(AF_UNIX, (unsigned short)PostPortName, &ServerSock_UNIX);
663588
if (status != STATUS_OK)
664589
{
665590
fprintf(stderr, "%s: cannot create UNIX stream port\n",
@@ -696,7 +621,6 @@ PostmasterMain(int argc, char *argv[])
696621
assert_enabled, /* whether -A is specified
697622
* or not */
698623
NBuffers, /* -B: number of shared buffers */
699-
Execfile, /* -b: postgres executable file */
700624
DebugLvl, /* -d: debug level */
701625
NetServer, /* -i: accept connection from INET */
702626
#ifdef USE_SSL
@@ -785,7 +709,6 @@ pmdaemonize(char *extraoptions)
785709
assert_enabled, /* whether -A is specified
786710
* or not */
787711
NBuffers, /* -B: number of shared buffers */
788-
Execfile, /* -b: postgres executable file */
789712
DebugLvl, /* -d: debug level */
790713
NetServer, /* -i: accept connection from INET */
791714
#ifdef USE_SSL
@@ -1905,7 +1828,6 @@ DoBackend(Port *port)
19051828
{
19061829
char *av[ARGV_SIZE * 2];
19071830
int ac = 0;
1908-
char execbuf[MAXPGPATH];
19091831
char debugbuf[ARGV_SIZE];
19101832
char protobuf[ARGV_SIZE];
19111833
char dbbuf[ARGV_SIZE];
@@ -1958,26 +1880,7 @@ DoBackend(Port *port)
19581880
* ----------------
19591881
*/
19601882

1961-
StrNCpy(execbuf, Execfile, MAXPGPATH);
1962-
av[ac++] = execbuf;
1963-
1964-
/*
1965-
* We need to set our argv[0] to an absolute path name because some
1966-
* OS's use this for dynamic loading, like BSDI. Without it, when we
1967-
* change directories to the database dir, the dynamic loader can't
1968-
* find the base executable and fails. Another advantage is that this
1969-
* changes the 'ps' displayed process name on some platforms. It does
1970-
* on BSDI. That's a big win.
1971-
*/
1972-
1973-
#ifndef linux
1974-
1975-
/*
1976-
* This doesn't work on linux and overwrites the only valid pointer to
1977-
* the argv buffer. See PS_INIT_STATUS macro.
1978-
*/
1979-
real_argv[0] = Execfile;
1980-
#endif
1883+
av[ac++] = "postgres";
19811884

19821885
/*
19831886
* Pass the requested debugging level along to the backend. Level one
@@ -2229,7 +2132,6 @@ SSDataBase(bool startup)
22292132
{
22302133
char *av[ARGV_SIZE * 2];
22312134
int ac = 0;
2232-
char execbuf[MAXPGPATH];
22332135
char nbbuf[ARGV_SIZE];
22342136
char dbbuf[ARGV_SIZE];
22352137

@@ -2244,8 +2146,7 @@ SSDataBase(bool startup)
22442146
ServerSock_UNIX = INVALID_SOCK;
22452147
#endif
22462148

2247-
StrNCpy(execbuf, Execfile, MAXPGPATH);
2248-
av[ac++] = execbuf;
2149+
av[ac++] = "postgres";
22492150

22502151
av[ac++] = "-d";
22512152

@@ -2294,7 +2195,7 @@ SSDataBase(bool startup)
22942195
*/
22952196
static int
22962197
SetOptsFile(char *progname, int port, char *datadir,
2297-
int assert, int nbuf, char *execfile,
2198+
int assert, int nbuf,
22982199
int debuglvl, int netserver,
22992200
#ifdef USE_SSL
23002201
int securenetserver,
@@ -2324,7 +2225,7 @@ SetOptsFile(char *progname, int port, char *datadir,
23242225
strcat(opts, buf);
23252226
}
23262227

2327-
snprintf(buf, sizeof(buf), "-B %d\n-b %s\n", nbuf, execfile);
2228+
snprintf(buf, sizeof(buf), "-B %d\n", nbuf);
23282229
strcat(opts, buf);
23292230

23302231
if (debuglvl)

0 commit comments

Comments
 (0)