mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-02-05 19:09:58 +08:00
Fix erroneous Assert() in syslogger process start in EXEC_BACKEND case,
per ITAGAKI Takahiro. Also, rewrite syslogger_forkexec() in hopes of eliminating the confusion in the first place.
This commit is contained in:
parent
a9f08b41ac
commit
a4f72d5940
@ -18,7 +18,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.29.2.3 2007/08/02 23:17:20 adunstan Exp $
|
* $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.29.2.4 2007/09/22 18:19:24 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -584,10 +584,8 @@ static pid_t
|
|||||||
syslogger_forkexec(void)
|
syslogger_forkexec(void)
|
||||||
{
|
{
|
||||||
char *av[10];
|
char *av[10];
|
||||||
int ac = 0,
|
int ac = 0;
|
||||||
bufc = 0,
|
char filenobuf[32];
|
||||||
i;
|
|
||||||
char numbuf[2][32];
|
|
||||||
|
|
||||||
av[ac++] = "postgres";
|
av[ac++] = "postgres";
|
||||||
av[ac++] = "--forklog";
|
av[ac++] = "--forklog";
|
||||||
@ -596,21 +594,18 @@ syslogger_forkexec(void)
|
|||||||
/* static variables (those not passed by write_backend_variables) */
|
/* static variables (those not passed by write_backend_variables) */
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
if (syslogFile != NULL)
|
if (syslogFile != NULL)
|
||||||
snprintf(numbuf[bufc++], 32, "%d", fileno(syslogFile));
|
snprintf(filenobuf, sizeof(filenobuf), "%d",
|
||||||
|
fileno(syslogFile));
|
||||||
else
|
else
|
||||||
strcpy(numbuf[bufc++], "-1");
|
strcpy(filenobuf, "-1");
|
||||||
#else /* WIN32 */
|
#else /* WIN32 */
|
||||||
if (syslogFile != NULL)
|
if (syslogFile != NULL)
|
||||||
snprintf(numbuf[bufc++], 32, "%ld",
|
snprintf(filenobuf, sizeof(filenobuf), "%ld",
|
||||||
_get_osfhandle(_fileno(syslogFile)));
|
_get_osfhandle(_fileno(syslogFile)));
|
||||||
else
|
else
|
||||||
strcpy(numbuf[bufc++], "0");
|
strcpy(filenobuf, "0");
|
||||||
#endif /* WIN32 */
|
#endif /* WIN32 */
|
||||||
|
av[ac++] = filenobuf;
|
||||||
/* Add to the arg list */
|
|
||||||
Assert(bufc <= lengthof(numbuf));
|
|
||||||
for (i = 0; i < bufc; i++)
|
|
||||||
av[ac++] = numbuf[i];
|
|
||||||
|
|
||||||
av[ac] = NULL;
|
av[ac] = NULL;
|
||||||
Assert(ac < lengthof(av));
|
Assert(ac < lengthof(av));
|
||||||
@ -628,7 +623,7 @@ syslogger_parseArgs(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
Assert(argc == 5);
|
Assert(argc == 4);
|
||||||
argv += 3;
|
argv += 3;
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
|
Loading…
Reference in New Issue
Block a user