mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-03-02 02:06:59 +08:00
This improves on commit bbfd7edae5aa5ad5553d3c7e102f2e450d4380d4 by making two simple changes: * pg_attribute_noreturn now takes parentheses, ie pg_attribute_noreturn(). Likewise pg_attribute_unused(), pg_attribute_packed(). This reduces pgindent's tendency to misformat declarations involving them. * attributes are now always attached to function declarations, not definitions. Previously some places were taking creative shortcuts, which were not merely candidates for bad misformatting by pgindent but often were outright wrong anyway. (It does little good to put a noreturn annotation where callers can't see it.) In any case, if we would like to believe that these macros can be used with non-gcc compilers, we should avoid gratuitous variance in usage patterns. I also went through and manually improved the formatting of a lot of declarations, and got rid of excessively repetitive (and now obsolete anyway) comments informing the reader what pg_attribute_printf is for.
91 lines
2.6 KiB
C
91 lines
2.6 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* syslogger.h
|
|
* Exports from postmaster/syslogger.c.
|
|
*
|
|
* Copyright (c) 2004-2015, PostgreSQL Global Development Group
|
|
*
|
|
* src/include/postmaster/syslogger.h
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef _SYSLOGGER_H
|
|
#define _SYSLOGGER_H
|
|
|
|
#include <limits.h> /* for PIPE_BUF */
|
|
|
|
|
|
/*
|
|
* Primitive protocol structure for writing to syslogger pipe(s). The idea
|
|
* here is to divide long messages into chunks that are not more than
|
|
* PIPE_BUF bytes long, which according to POSIX spec must be written into
|
|
* the pipe atomically. The pipe reader then uses the protocol headers to
|
|
* reassemble the parts of a message into a single string. The reader can
|
|
* also cope with non-protocol data coming down the pipe, though we cannot
|
|
* guarantee long strings won't get split apart.
|
|
*
|
|
* We use non-nul bytes in is_last to make the protocol a tiny bit
|
|
* more robust against finding a false double nul byte prologue. But
|
|
* we still might find it in the len and/or pid bytes unless we're careful.
|
|
*/
|
|
|
|
#ifdef PIPE_BUF
|
|
/* Are there any systems with PIPE_BUF > 64K? Unlikely, but ... */
|
|
#if PIPE_BUF > 65536
|
|
#define PIPE_CHUNK_SIZE 65536
|
|
#else
|
|
#define PIPE_CHUNK_SIZE ((int) PIPE_BUF)
|
|
#endif
|
|
#else /* not defined */
|
|
/* POSIX says the value of PIPE_BUF must be at least 512, so use that */
|
|
#define PIPE_CHUNK_SIZE 512
|
|
#endif
|
|
|
|
typedef struct
|
|
{
|
|
char nuls[2]; /* always \0\0 */
|
|
uint16 len; /* size of this chunk (counts data only) */
|
|
int32 pid; /* writer's pid */
|
|
char is_last; /* last chunk of message? 't' or 'f' ('T' or
|
|
* 'F' for CSV case) */
|
|
char data[FLEXIBLE_ARRAY_MEMBER]; /* data payload starts here */
|
|
} PipeProtoHeader;
|
|
|
|
typedef union
|
|
{
|
|
PipeProtoHeader proto;
|
|
char filler[PIPE_CHUNK_SIZE];
|
|
} PipeProtoChunk;
|
|
|
|
#define PIPE_HEADER_SIZE offsetof(PipeProtoHeader, data)
|
|
#define PIPE_MAX_PAYLOAD ((int) (PIPE_CHUNK_SIZE - PIPE_HEADER_SIZE))
|
|
|
|
|
|
/* GUC options */
|
|
extern bool Logging_collector;
|
|
extern int Log_RotationAge;
|
|
extern int Log_RotationSize;
|
|
extern PGDLLIMPORT char *Log_directory;
|
|
extern PGDLLIMPORT char *Log_filename;
|
|
extern bool Log_truncate_on_rotation;
|
|
extern int Log_file_mode;
|
|
|
|
extern bool am_syslogger;
|
|
|
|
#ifndef WIN32
|
|
extern int syslogPipe[2];
|
|
#else
|
|
extern HANDLE syslogPipe[2];
|
|
#endif
|
|
|
|
|
|
extern int SysLogger_Start(void);
|
|
|
|
extern void write_syslogger_file(const char *buffer, int count, int dest);
|
|
|
|
#ifdef EXEC_BACKEND
|
|
extern void SysLoggerMain(int argc, char *argv[]) pg_attribute_noreturn();
|
|
#endif
|
|
|
|
#endif /* _SYSLOGGER_H */
|