PostgreSQL Source Code  git master
win32_port.h File Reference
#include <winsock2.h>
#include <ws2tcpip.h>
#include <windows.h>
#include <process.h>
#include <signal.h>
#include <direct.h>
#include <sys/stat.h>
Include dependency graph for win32_port.h:

Go to the source code of this file.

Data Structures

struct  timezone
 
struct  itimerval
 
struct  stat
 

Macros

#define ENABLE_SSPI   1
 
#define _WINSOCKAPI_
 
#define fstat   microsoft_native_fstat
 
#define stat   microsoft_native_stat
 
#define mkdir(a, b)   mkdir(a)
 
#define ftruncate(a, b)   chsize(a,b)
 
#define fsync(fd)   _commit(fd)
 
#define HAVE_FSYNC_WRITETHROUGH
 
#define FSYNC_WRITETHROUGH_IS_FSYNC
 
#define USES_WINSOCK
 
#define HAVE_UNION_SEMUN   1
 
#define IPC_RMID   256
 
#define IPC_CREAT   512
 
#define IPC_EXCL   1024
 
#define IPC_PRIVATE   234564
 
#define IPC_NOWAIT   2048
 
#define IPC_STAT   4096
 
#define EACCESS   2048
 
#define EIDRM   4096
 
#define SETALL   8192
 
#define GETNCNT   16384
 
#define GETVAL   65536
 
#define SETVAL   131072
 
#define GETPID   262144
 
#define WIFEXITED(w)   (((w) & 0XFFFFFF00) == 0)
 
#define WIFSIGNALED(w)   (!WIFEXITED(w))
 
#define WEXITSTATUS(w)   (w)
 
#define WTERMSIG(w)   (w)
 
#define sigmask(sig)   ( 1 << ((sig)-1) )
 
#define SIG_DFL   ((pqsigfunc)0)
 
#define SIG_ERR   ((pqsigfunc)-1)
 
#define SIG_IGN   ((pqsigfunc)1)
 
#define SIGHUP   1
 
#define SIGQUIT   3
 
#define SIGTRAP   5
 
#define SIGABRT   22 /* Set to match W32 value -- not UNIX value */
 
#define SIGKILL   9
 
#define SIGPIPE   13
 
#define SIGALRM   14
 
#define SIGSTOP   17
 
#define SIGTSTP   18
 
#define SIGCONT   19
 
#define SIGCHLD   20
 
#define SIGWINCH   28
 
#define SIGUSR1   30
 
#define SIGUSR2   31
 
#define ITIMER_REAL   0
 
#define pgoff_t   __int64
 
#define fseeko(stream, offset, origin)   fseeko64(stream, offset, origin)
 
#define ftello(stream)   ftello64(stream)
 
#define symlink(oldpath, newpath)   pgsymlink(oldpath, newpath)
 
#define readlink(path, buf, size)   pgreadlink(path, buf, size)
 
#define fstat(fileno, sb)   _pgfstat64(fileno, sb)
 
#define stat(path, sb)   _pgstat64(path, sb)
 
#define lstat(path, sb)   _pgstat64(path, sb)
 
#define S_IRUSR   _S_IREAD
 
#define S_IWUSR   _S_IWRITE
 
#define S_IXUSR   _S_IEXEC
 
#define S_IRWXU   (S_IRUSR | S_IWUSR | S_IXUSR)
 
#define S_IRGRP   0
 
#define S_IWGRP   0
 
#define S_IXGRP   0
 
#define S_IRWXG   0
 
#define S_IROTH   0
 
#define S_IWOTH   0
 
#define S_IXOTH   0
 
#define S_IRWXO   0
 
#define S_ISDIR(m)   (((m) & S_IFMT) == S_IFDIR)
 
#define S_ISREG(m)   (((m) & S_IFMT) == S_IFREG)
 
#define O_DSYNC   0x0080
 
#define EAGAIN   WSAEWOULDBLOCK
 
#define EINTR   WSAEINTR
 
#define EMSGSIZE   WSAEMSGSIZE
 
#define EAFNOSUPPORT   WSAEAFNOSUPPORT
 
#define EWOULDBLOCK   WSAEWOULDBLOCK
 
#define ECONNABORTED   WSAECONNABORTED
 
#define ECONNRESET   WSAECONNRESET
 
#define EINPROGRESS   WSAEINPROGRESS
 
#define EISCONN   WSAEISCONN
 
#define ENOBUFS   WSAENOBUFS
 
#define EPROTONOSUPPORT   WSAEPROTONOSUPPORT
 
#define ECONNREFUSED   WSAECONNREFUSED
 
#define ENOTSOCK   WSAENOTSOCK
 
#define EOPNOTSUPP   WSAEOPNOTSUPP
 
#define EADDRINUSE   WSAEADDRINUSE
 
#define EADDRNOTAVAIL   WSAEADDRNOTAVAIL
 
#define EHOSTDOWN   WSAEHOSTDOWN
 
#define EHOSTUNREACH   WSAEHOSTUNREACH
 
#define ENETDOWN   WSAENETDOWN
 
#define ENETRESET   WSAENETRESET
 
#define ENETUNREACH   WSAENETUNREACH
 
#define ENOTCONN   WSAENOTCONN
 
#define locale_t   _locale_t
 
#define tolower_l   _tolower_l
 
#define toupper_l   _toupper_l
 
#define towlower_l   _towlower_l
 
#define towupper_l   _towupper_l
 
#define isdigit_l   _isdigit_l
 
#define iswdigit_l   _iswdigit_l
 
#define isalpha_l   _isalpha_l
 
#define iswalpha_l   _iswalpha_l
 
#define isalnum_l   _isalnum_l
 
#define iswalnum_l   _iswalnum_l
 
#define isupper_l   _isupper_l
 
#define iswupper_l   _iswupper_l
 
#define islower_l   _islower_l
 
#define iswlower_l   _iswlower_l
 
#define isgraph_l   _isgraph_l
 
#define iswgraph_l   _iswgraph_l
 
#define isprint_l   _isprint_l
 
#define iswprint_l   _iswprint_l
 
#define ispunct_l   _ispunct_l
 
#define iswpunct_l   _iswpunct_l
 
#define isspace_l   _isspace_l
 
#define iswspace_l   _iswspace_l
 
#define strcoll_l   _strcoll_l
 
#define strxfrm_l   _strxfrm_l
 
#define wcscoll_l   _wcscoll_l
 
#define wcstombs_l   _wcstombs_l
 
#define mbstowcs_l   _mbstowcs_l
 
#define setlocale(a, b)   pgwin32_setlocale(a,b)
 
#define UNBLOCKED_SIGNAL_QUEUE()   (pg_signal_queue & ~pg_signal_mask)
 
#define PG_SIGNAL_COUNT   32
 
#define kill(pid, sig)   pgkill(pid,sig)
 
#define socket(af, type, protocol)   pgwin32_socket(af, type, protocol)
 
#define bind(s, addr, addrlen)   pgwin32_bind(s, addr, addrlen)
 
#define listen(s, backlog)   pgwin32_listen(s, backlog)
 
#define accept(s, addr, addrlen)   pgwin32_accept(s, addr, addrlen)
 
#define connect(s, name, namelen)   pgwin32_connect(s, name, namelen)
 
#define select(n, r, w, e, timeout)   pgwin32_select(n, r, w, e, timeout)
 
#define recv(s, buf, len, flags)   pgwin32_recv(s, buf, len, flags)
 
#define send(s, buf, len, flags)   pgwin32_send(s, buf, len, flags)
 
#define putenv(x)   pgwin32_putenv(x)
 
#define setenv(x, y, z)   pgwin32_setenv(x,y,z)
 
#define unsetenv(x)   pgwin32_unsetenv(x)
 

Typedefs

typedef int uid_t
 
typedef int gid_t
 
typedef long key_t
 

Functions

int setitimer (int which, const struct itimerval *value, struct itimerval *ovalue)
 
int pgsymlink (const char *oldpath, const char *newpath)
 
int pgreadlink (const char *path, char *buf, size_t size)
 
bool pgwin32_is_junction (const char *path)
 
int _pgfstat64 (int fileno, struct stat *buf)
 
int _pgstat64 (const char *name, struct stat *buf)
 
char * pgwin32_setlocale (int category, const char *locale)
 
void pgwin32_signal_initialize (void)
 
HANDLE pgwin32_create_signal_listener (pid_t pid)
 
void pgwin32_dispatch_queued_signals (void)
 
void pg_queue_signal (int signum)
 
int pgkill (int pid, int sig)
 
SOCKET pgwin32_socket (int af, int type, int protocol)
 
int pgwin32_bind (SOCKET s, struct sockaddr *addr, int addrlen)
 
int pgwin32_listen (SOCKET s, int backlog)
 
SOCKET pgwin32_accept (SOCKET s, struct sockaddr *addr, int *addrlen)
 
int pgwin32_connect (SOCKET s, const struct sockaddr *name, int namelen)
 
int pgwin32_select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const struct timeval *timeout)
 
int pgwin32_recv (SOCKET s, char *buf, int len, int flags)
 
int pgwin32_send (SOCKET s, const void *buf, int len, int flags)
 
int pgwin32_waitforsinglesocket (SOCKET s, int what, int timeout)
 
int pgwin32_ReserveSharedMemoryRegion (HANDLE)
 
void pgwin32_install_crashdump_handler (void)
 
void _dosmaperr (unsigned long)
 
int pgwin32_putenv (const char *)
 
int pgwin32_setenv (const char *name, const char *value, int overwrite)
 
int pgwin32_unsetenv (const char *name)
 
int pgwin32_is_service (void)
 
int pgwin32_is_admin (void)
 
BOOL AddUserToTokenDacl (HANDLE hToken)
 

Variables

PGDLLIMPORT volatile int pg_signal_queue
 
PGDLLIMPORT int pg_signal_mask
 
HANDLE pgwin32_signal_event
 
HANDLE pgwin32_initial_signal_pipe
 
int pgwin32_noblock
 

Macro Definition Documentation

◆ _WINSOCKAPI_

#define _WINSOCKAPI_

Definition at line 43 of file win32_port.h.

◆ accept

#define accept (   s,
  addr,
  addrlen 
)    pgwin32_accept(s, addr, addrlen)

Definition at line 462 of file win32_port.h.

Referenced by readMessageFromPipe(), and StreamConnection().

◆ bind

#define bind (   s,
  addr,
  addrlen 
)    pgwin32_bind(s, addr, addrlen)

◆ connect

#define connect (   s,
  name,
  namelen 
)    pgwin32_connect(s, name, namelen)

◆ EACCESS

#define EACCESS   2048

Definition at line 93 of file win32_port.h.

◆ EADDRINUSE

#define EADDRINUSE   WSAEADDRINUSE

Definition at line 369 of file win32_port.h.

Referenced by get_errno_symbol(), StreamServerPort(), and TranslateSocketError().

◆ EADDRNOTAVAIL

#define EADDRNOTAVAIL   WSAEADDRNOTAVAIL

Definition at line 371 of file win32_port.h.

Referenced by get_errno_symbol(), and TranslateSocketError().

◆ EAFNOSUPPORT

#define EAFNOSUPPORT   WSAEAFNOSUPPORT

◆ EAGAIN

◆ ECONNABORTED

#define ECONNABORTED   WSAECONNABORTED

Definition at line 351 of file win32_port.h.

Referenced by get_errno_symbol(), and TranslateSocketError().

◆ ECONNREFUSED

#define ECONNREFUSED   WSAECONNREFUSED

Definition at line 363 of file win32_port.h.

Referenced by get_errno_symbol(), and TranslateSocketError().

◆ ECONNRESET

◆ EHOSTDOWN

#define EHOSTDOWN   WSAEHOSTDOWN

Definition at line 373 of file win32_port.h.

Referenced by get_errno_symbol(), and TranslateSocketError().

◆ EHOSTUNREACH

#define EHOSTUNREACH   WSAEHOSTUNREACH

Definition at line 375 of file win32_port.h.

Referenced by get_errno_symbol(), and TranslateSocketError().

◆ EIDRM

#define EIDRM   4096

◆ EINPROGRESS

#define EINPROGRESS   WSAEINPROGRESS

Definition at line 355 of file win32_port.h.

Referenced by get_errno_symbol(), PQconnectPoll(), and TranslateSocketError().

◆ EINTR

◆ EISCONN

#define EISCONN   WSAEISCONN

Definition at line 357 of file win32_port.h.

Referenced by get_errno_symbol(), and TranslateSocketError().

◆ EMSGSIZE

◆ ENABLE_SSPI

#define ENABLE_SSPI   1

Definition at line 23 of file win32_port.h.

◆ ENETDOWN

#define ENETDOWN   WSAENETDOWN

Definition at line 377 of file win32_port.h.

Referenced by get_errno_symbol(), and TranslateSocketError().

◆ ENETRESET

#define ENETRESET   WSAENETRESET

Definition at line 379 of file win32_port.h.

Referenced by get_errno_symbol(), and TranslateSocketError().

◆ ENETUNREACH

#define ENETUNREACH   WSAENETUNREACH

Definition at line 381 of file win32_port.h.

Referenced by get_errno_symbol(), and TranslateSocketError().

◆ ENOBUFS

#define ENOBUFS   WSAENOBUFS

Definition at line 359 of file win32_port.h.

Referenced by get_errno_symbol(), and TranslateSocketError().

◆ ENOTCONN

#define ENOTCONN   WSAENOTCONN

Definition at line 383 of file win32_port.h.

Referenced by get_errno_symbol(), and TranslateSocketError().

◆ ENOTSOCK

#define ENOTSOCK   WSAENOTSOCK

Definition at line 365 of file win32_port.h.

Referenced by get_errno_symbol(), and TranslateSocketError().

◆ EOPNOTSUPP

#define EOPNOTSUPP   WSAEOPNOTSUPP

Definition at line 367 of file win32_port.h.

Referenced by get_errno_symbol(), and TranslateSocketError().

◆ EPROTONOSUPPORT

#define EPROTONOSUPPORT   WSAEPROTONOSUPPORT

Definition at line 361 of file win32_port.h.

Referenced by get_errno_symbol(), and TranslateSocketError().

◆ EWOULDBLOCK

◆ fseeko

#define fseeko (   stream,
  offset,
  origin 
)    fseeko64(stream, offset, origin)

◆ fstat [1/2]

◆ fstat [2/2]

#define fstat (   fileno,
  sb 
)    _pgfstat64(fileno, sb)

Definition at line 274 of file win32_port.h.

◆ fsync

◆ FSYNC_WRITETHROUGH_IS_FSYNC

#define FSYNC_WRITETHROUGH_IS_FSYNC

Definition at line 76 of file win32_port.h.

◆ ftello

#define ftello (   stream)    ftello64(stream)

◆ ftruncate

#define ftruncate (   a,
 
)    chsize(a,b)

◆ GETNCNT

#define GETNCNT   16384

Definition at line 99 of file win32_port.h.

◆ GETPID

#define GETPID   262144

Definition at line 102 of file win32_port.h.

Referenced by IpcSemaphoreGetLastPID().

◆ GETVAL

#define GETVAL   65536

Definition at line 100 of file win32_port.h.

Referenced by IpcSemaphoreGetValue().

◆ HAVE_FSYNC_WRITETHROUGH

#define HAVE_FSYNC_WRITETHROUGH

Definition at line 75 of file win32_port.h.

◆ HAVE_UNION_SEMUN

#define HAVE_UNION_SEMUN   1

Definition at line 84 of file win32_port.h.

◆ IPC_CREAT

#define IPC_CREAT   512

Definition at line 87 of file win32_port.h.

Referenced by dsm_impl_sysv(), InternalIpcMemoryCreate(), and InternalIpcSemaphoreCreate().

◆ IPC_EXCL

#define IPC_EXCL   1024

Definition at line 88 of file win32_port.h.

Referenced by dsm_impl_sysv(), InternalIpcMemoryCreate(), and InternalIpcSemaphoreCreate().

◆ IPC_NOWAIT

#define IPC_NOWAIT   2048

Definition at line 90 of file win32_port.h.

Referenced by PGSemaphoreTryLock().

◆ IPC_PRIVATE

#define IPC_PRIVATE   234564

Definition at line 89 of file win32_port.h.

Referenced by dsm_impl_sysv().

◆ IPC_RMID

◆ IPC_STAT

#define IPC_STAT   4096

Definition at line 91 of file win32_port.h.

Referenced by dsm_impl_sysv(), and PGSharedMemoryAttach().

◆ isalnum_l

#define isalnum_l   _isalnum_l

Definition at line 400 of file win32_port.h.

Referenced by pg_wc_isalnum(), and str_initcap().

◆ isalpha_l

#define isalpha_l   _isalpha_l

Definition at line 398 of file win32_port.h.

Referenced by pattern_char_isalpha(), and pg_wc_isalpha().

◆ isdigit_l

#define isdigit_l   _isdigit_l

Definition at line 396 of file win32_port.h.

Referenced by pg_wc_isdigit().

◆ isgraph_l

#define isgraph_l   _isgraph_l

Definition at line 406 of file win32_port.h.

Referenced by pg_wc_isgraph().

◆ islower_l

#define islower_l   _islower_l

Definition at line 404 of file win32_port.h.

Referenced by pg_wc_islower().

◆ isprint_l

#define isprint_l   _isprint_l

Definition at line 408 of file win32_port.h.

Referenced by pg_wc_isprint().

◆ ispunct_l

#define ispunct_l   _ispunct_l

Definition at line 410 of file win32_port.h.

Referenced by pg_wc_ispunct().

◆ isspace_l

#define isspace_l   _isspace_l

Definition at line 412 of file win32_port.h.

Referenced by pg_wc_isspace().

◆ isupper_l

#define isupper_l   _isupper_l

Definition at line 402 of file win32_port.h.

Referenced by pg_wc_isupper().

◆ iswalnum_l

#define iswalnum_l   _iswalnum_l

Definition at line 401 of file win32_port.h.

Referenced by pg_wc_isalnum(), and str_initcap().

◆ iswalpha_l

#define iswalpha_l   _iswalpha_l

Definition at line 399 of file win32_port.h.

Referenced by pg_wc_isalpha().

◆ iswdigit_l

#define iswdigit_l   _iswdigit_l

Definition at line 397 of file win32_port.h.

Referenced by pg_wc_isdigit().

◆ iswgraph_l

#define iswgraph_l   _iswgraph_l

Definition at line 407 of file win32_port.h.

Referenced by pg_wc_isgraph().

◆ iswlower_l

#define iswlower_l   _iswlower_l

Definition at line 405 of file win32_port.h.

Referenced by pg_wc_islower().

◆ iswprint_l

#define iswprint_l   _iswprint_l

Definition at line 409 of file win32_port.h.

Referenced by pg_wc_isprint().

◆ iswpunct_l

#define iswpunct_l   _iswpunct_l

Definition at line 411 of file win32_port.h.

Referenced by pg_wc_ispunct().

◆ iswspace_l

#define iswspace_l   _iswspace_l

Definition at line 413 of file win32_port.h.

Referenced by pg_wc_isspace().

◆ iswupper_l

#define iswupper_l   _iswupper_l

Definition at line 403 of file win32_port.h.

Referenced by pg_wc_isupper().

◆ ITIMER_REAL

#define ITIMER_REAL   0

Definition at line 187 of file win32_port.h.

Referenced by schedule_alarm(), and setitimer().

◆ kill

◆ listen

#define listen (   s,
  backlog 
)    pgwin32_listen(s, backlog)

Definition at line 461 of file win32_port.h.

Referenced by pgwin32_listen(), readMessageFromPipe(), and StreamServerPort().

◆ locale_t

◆ lstat

◆ mbstowcs_l

#define mbstowcs_l   _mbstowcs_l

Definition at line 418 of file win32_port.h.

Referenced by char2wchar().

◆ mkdir

◆ O_DSYNC

#define O_DSYNC   0x0080

Definition at line 328 of file win32_port.h.

Referenced by test_sync().

◆ PG_SIGNAL_COUNT

#define PG_SIGNAL_COUNT   32

◆ pgoff_t

◆ putenv

#define putenv (   x)    pgwin32_putenv(x)

Definition at line 496 of file win32_port.h.

Referenced by setenv(), and unsetenv().

◆ readlink

#define readlink (   path,
  buf,
  size 
)    pgreadlink(path, buf, size)

◆ recv

#define recv (   s,
  buf,
  len,
  flags 
)    pgwin32_recv(s, buf, len, flags)

◆ S_IRGRP

#define S_IRGRP   0

Definition at line 292 of file win32_port.h.

Referenced by be_lo_export(), and PostmasterMain().

◆ S_IROTH

#define S_IROTH   0

Definition at line 304 of file win32_port.h.

Referenced by be_lo_export(), and PostmasterMain().

◆ S_IRUSR

◆ S_IRWXG

◆ S_IRWXO

◆ S_IRWXU

#define S_IRWXU   (S_IRUSR | S_IWUSR | S_IXUSR)

◆ S_ISDIR

◆ S_ISREG

◆ S_IWGRP

#define S_IWGRP   0

Definition at line 295 of file win32_port.h.

Referenced by be_lo_export(), BeginCopyTo(), check_ssl_key_file_permissions(), and main().

◆ S_IWOTH

#define S_IWOTH   0

Definition at line 307 of file win32_port.h.

Referenced by be_lo_export(), BeginCopyTo(), and main().

◆ S_IWUSR

◆ S_IXGRP

#define S_IXGRP   0

Definition at line 298 of file win32_port.h.

Referenced by check_ssl_key_file_permissions().

◆ S_IXOTH

#define S_IXOTH   0

Definition at line 310 of file win32_port.h.

◆ S_IXUSR

#define S_IXUSR   _S_IEXEC

Definition at line 286 of file win32_port.h.

Referenced by pg_mkdir_p(), and validate_exec().

◆ select

◆ send

#define send (   s,
  buf,
  len,
  flags 
)    pgwin32_send(s, buf, len, flags)

◆ SETALL

#define SETALL   8192

Definition at line 98 of file win32_port.h.

◆ setenv

◆ setlocale

◆ SETVAL

#define SETVAL   131072

Definition at line 101 of file win32_port.h.

Referenced by IpcSemaphoreInitialize().

◆ SIG_DFL

◆ SIG_ERR

#define SIG_ERR   ((pqsigfunc)-1)

Definition at line 155 of file win32_port.h.

Referenced by pgwin32_dispatch_queued_signals(), pqsignal(), and pqsignal_pm().

◆ SIG_IGN

◆ SIGABRT

#define SIGABRT   22 /* Set to match W32 value -- not UNIX value */

Definition at line 162 of file win32_port.h.

Referenced by pqinitmask(), and set_sig().

◆ SIGALRM

◆ SIGCHLD

◆ SIGCONT

#define SIGCONT   19

Definition at line 168 of file win32_port.h.

Referenced by pqinitmask().

◆ SIGHUP

◆ SIGKILL

#define SIGKILL   9

Definition at line 163 of file win32_port.h.

Referenced by regression_main(), ServerLoop(), set_sig(), signal_child(), and TerminateChildren().

◆ sigmask

#define sigmask (   sig)    ( 1 << ((sig)-1) )

Definition at line 148 of file win32_port.h.

Referenced by pg_queue_signal(), and pgwin32_dispatch_queued_signals().

◆ SIGPIPE

◆ SIGQUIT

◆ SIGSTOP

#define SIGSTOP   17

Definition at line 166 of file win32_port.h.

Referenced by HandleChildCrash(), and signal_child().

◆ SIGTRAP

#define SIGTRAP   5

Definition at line 161 of file win32_port.h.

Referenced by pqinitmask().

◆ SIGTSTP

#define SIGTSTP   18

Definition at line 167 of file win32_port.h.

◆ SIGUSR1

◆ SIGUSR2

◆ SIGWINCH

#define SIGWINCH   28

Definition at line 170 of file win32_port.h.

◆ socket

#define socket (   af,
  type,
  protocol 
)    pgwin32_socket(af, type, protocol)

◆ stat [1/2]

#define stat   microsoft_native_stat

Definition at line 275 of file win32_port.h.

Referenced by _discoverArchiveFormat(), _PrepParallelRestore(), AlterSystemSetConfigFile(), BackupInProgress(), bt_page_stats_internal(), calculate_relation_size(), calculate_tablespace_size(), CancelBackup(), check_bin_dir(), check_for_new_tablespace_dir(), check_input(), check_single_dir(), check_ssl_key_file_permissions(), checkDataDir(), CheckForExternalTrigger(), CheckForStandbyTrigger(), CheckLogrotateSignal(), CheckPromoteSignal(), cmp_abs(), create_tablespace_directories(), createdb(), CreateExtensionInternal(), CreateSlotOnDisk(), CustomizableInitialize(), CustomizableNextWALFileReady(), db_dir_size(), dbase_redo(), dir_get_file_size(), directory_exists(), do_edit(), do_pg_start_backup(), do_pg_stop_backup(), do_restart(), do_stop(), file_exists(), fileAnalyzeForeignTable(), FileClose(), fileExplainForeignScan(), FindStreamingStart(), get_dirent_type(), get_pgpid(), get_tablespace_paths(), GETTEMP(), hash_page_stats(), InitArchiveFmt_Directory(), Initialize(), initialize_SSL(), InstallXLogFileSegment(), internal_load_library(), internal_unload_library(), itsdir(), KeepFileRestoredFromArchive(), parseServiceInfo(), passwordFromFile(), PathNameDeleteTemporaryDir(), PathNameDeleteTemporaryFile(), pg_file_sync(), pg_file_write_internal(), pg_ls_dir_files(), pg_mkdir_p(), pg_stat_file(), pg_tzenumerate_next(), pgarch_ArchiverCopyLoop(), PGReserveSemaphores(), PGSharedMemoryAttach(), PGSharedMemoryCreate(), PutMemoryContextsStatsTupleStore(), read_whole_file(), readRecoverySignalFile(), RestoreArchivedFile(), scan_available_timezones(), SelectConfigFiles(), SetDataDirectoryCreatePerm(), SnapBuildSerialize(), sqrt_var(), StartupXLOG(), statext_mcv_clauselist_selectivity(), TablespaceCreateDbspace(), transfer_relfile(), ts_accum(), ts_stat1(), ts_stat2(), ts_stat_sql(), validate_exec(), ValidateXLOGDirectoryStructure(), verify_backup_file(), XLogArchiveCheckDone(), XLogArchiveForceDone(), XLogArchiveIsBusy(), XLogArchiveIsReady(), and XLogArchiveIsReadyOrDone().

◆ stat [2/2]

#define stat (   path,
  sb 
)    _pgstat64(path, sb)

Definition at line 275 of file win32_port.h.

◆ strcoll_l

#define strcoll_l   _strcoll_l

Definition at line 414 of file win32_port.h.

Referenced by varstr_cmp(), and varstrfastcmp_locale().

◆ strxfrm_l

#define strxfrm_l   _strxfrm_l

Definition at line 415 of file win32_port.h.

Referenced by varstr_abbrev_convert().

◆ symlink

#define symlink (   oldpath,
  newpath 
)    pgsymlink(oldpath, newpath)

◆ tolower_l

#define tolower_l   _tolower_l

Definition at line 392 of file win32_port.h.

Referenced by pg_wc_tolower(), SB_lower_char(), str_initcap(), and str_tolower().

◆ toupper_l

#define toupper_l   _toupper_l

Definition at line 393 of file win32_port.h.

Referenced by pg_wc_toupper(), str_initcap(), and str_toupper().

◆ towlower_l

#define towlower_l   _towlower_l

Definition at line 394 of file win32_port.h.

Referenced by pg_wc_tolower(), str_initcap(), and str_tolower().

◆ towupper_l

#define towupper_l   _towupper_l

Definition at line 395 of file win32_port.h.

Referenced by pg_wc_toupper(), str_initcap(), and str_toupper().

◆ UNBLOCKED_SIGNAL_QUEUE

#define UNBLOCKED_SIGNAL_QUEUE ( )    (pg_signal_queue & ~pg_signal_mask)

Definition at line 445 of file win32_port.h.

Referenced by pgwin32_dispatch_queued_signals(), and pgwin32_poll_signals().

◆ unsetenv

◆ USES_WINSOCK

#define USES_WINSOCK

Definition at line 78 of file win32_port.h.

◆ wcscoll_l

#define wcscoll_l   _wcscoll_l

Definition at line 416 of file win32_port.h.

Referenced by varstr_cmp().

◆ wcstombs_l

#define wcstombs_l   _wcstombs_l

Definition at line 417 of file win32_port.h.

Referenced by wchar2char().

◆ WEXITSTATUS

#define WEXITSTATUS (   w)    (w)

◆ WIFEXITED

#define WIFEXITED (   w)    (((w) & 0XFFFFFF00) == 0)

◆ WIFSIGNALED

#define WIFSIGNALED (   w)    (!WIFEXITED(w))

◆ WTERMSIG

#define WTERMSIG (   w)    (w)

Typedef Documentation

◆ gid_t

typedef int gid_t

Definition at line 237 of file win32_port.h.

◆ key_t

typedef long key_t

Definition at line 239 of file win32_port.h.

◆ uid_t

typedef int uid_t

Definition at line 236 of file win32_port.h.

Function Documentation

◆ _dosmaperr()

void _dosmaperr ( unsigned  long)

Definition at line 171 of file win32error.c.

References DEBUG5, doserr, doserrors, ereport, errmsg_internal(), fprintf, i, lengthof, LOG, and winerr.

Referenced by BaseBackup(), copyFile(), dsm_impl_pin_segment(), dsm_impl_sysv(), dsm_impl_unpin_segment(), FileRead(), FileWrite(), getrusage(), mkdirs(), pg_pread(), pg_pwrite(), readdir(), socket_has_input(), and write_syslogger_file().

172 {
173  int i;
174 
175  if (e == 0)
176  {
177  errno = 0;
178  return;
179  }
180 
181  for (i = 0; i < lengthof(doserrors); i++)
182  {
183  if (doserrors[i].winerr == e)
184  {
185  int doserr = doserrors[i].doserr;
186 
187 #ifndef FRONTEND
188  ereport(DEBUG5,
189  (errmsg_internal("mapped win32 error code %lu to %d",
190  e, doserr)));
191 #elif defined(FRONTEND_DEBUG)
192  fprintf(stderr, "mapped win32 error code %lu to %d", e, doserr);
193 #endif
194  errno = doserr;
195  return;
196  }
197  }
198 
199 #ifndef FRONTEND
200  ereport(LOG,
201  (errmsg_internal("unrecognized win32 error code: %lu",
202  e)));
203 #else
204  fprintf(stderr, "unrecognized win32 error code: %lu", e);
205 #endif
206 
207  errno = EINVAL;
208 }
DWORD winerr
Definition: win32error.c:22
#define lengthof(array)
Definition: c.h:722
#define LOG
Definition: elog.h:26
#define fprintf
Definition: port.h:219
static const struct @166 doserrors[]
#define ereport(elevel,...)
Definition: elog.h:155
int errmsg_internal(const char *fmt,...)
Definition: elog.c:1002
e
Definition: preproc-init.c:82
int i
#define DEBUG5
Definition: elog.h:20
int doserr
Definition: win32error.c:23

◆ _pgfstat64()

int _pgfstat64 ( int  fileno,
struct stat buf 
)

◆ _pgstat64()

int _pgstat64 ( const char *  name,
struct stat buf 
)

◆ AddUserToTokenDacl()

BOOL AddUserToTokenDacl ( HANDLE  hToken)

Referenced by do_kill(), and set_pglocale_pgservice().

◆ pg_queue_signal()

void pg_queue_signal ( int  signum)

Definition at line 215 of file signal.c.

References Assert, PG_SIGNAL_COUNT, pg_signal_crit_sec, pg_signal_queue, pgwin32_signal_event, and sigmask.

Referenced by pg_console_handler(), pg_signal_thread(), pg_timer_thread(), and PostmasterMarkPIDForWorkerNotify().

216 {
217  Assert(pgwin32_signal_event != NULL);
218  if (signum >= PG_SIGNAL_COUNT || signum <= 0)
219  return; /* ignore any bad signal number */
220 
221  EnterCriticalSection(&pg_signal_crit_sec);
222  pg_signal_queue |= sigmask(signum);
223  LeaveCriticalSection(&pg_signal_crit_sec);
224 
225  SetEvent(pgwin32_signal_event);
226 }
volatile int pg_signal_queue
Definition: signal.c:24
#define sigmask(sig)
Definition: win32_port.h:148
HANDLE pgwin32_signal_event
Definition: signal.c:27
static CRITICAL_SECTION pg_signal_crit_sec
Definition: signal.c:34
#define PG_SIGNAL_COUNT
Definition: win32_port.h:446
#define Assert(condition)
Definition: c.h:792

◆ pgkill()

int pgkill ( int  pid,
int  sig 
)

◆ pgreadlink()

int pgreadlink ( const char *  path,
char *  buf,
size_t  size 
)

◆ pgsymlink()

int pgsymlink ( const char *  oldpath,
const char *  newpath 
)

◆ pgwin32_accept()

SOCKET pgwin32_accept ( SOCKET  s,
struct sockaddr *  addr,
int *  addrlen 
)

Definition at line 331 of file socket.c.

References pgwin32_poll_signals(), and TranslateSocketError().

332 {
333  SOCKET rs;
334 
335  /*
336  * Poll for signals, but don't return with EINTR, since we don't handle
337  * that in pqcomm.c
338  */
340 
341  rs = WSAAccept(s, addr, addrlen, NULL, 0);
342  if (rs == INVALID_SOCKET)
343  {
345  return INVALID_SOCKET;
346  }
347  return rs;
348 }
static int pgwin32_poll_signals(void)
Definition: socket.c:152
static void TranslateSocketError(void)
Definition: socket.c:56

◆ pgwin32_bind()

int pgwin32_bind ( SOCKET  s,
struct sockaddr *  addr,
int  addrlen 
)

Definition at line 309 of file socket.c.

References bind, and TranslateSocketError().

310 {
311  int res;
312 
313  res = bind(s, addr, addrlen);
314  if (res < 0)
316  return res;
317 }
#define bind(s, addr, addrlen)
Definition: win32_port.h:460
static void TranslateSocketError(void)
Definition: socket.c:56

◆ pgwin32_connect()

int pgwin32_connect ( SOCKET  s,
const struct sockaddr *  name,
int  namelen 
)

Definition at line 353 of file socket.c.

References pgwin32_waitforsinglesocket(), and TranslateSocketError().

354 {
355  int r;
356 
357  r = WSAConnect(s, addr, addrlen, NULL, NULL, NULL, NULL);
358  if (r == 0)
359  return 0;
360 
361  if (WSAGetLastError() != WSAEWOULDBLOCK)
362  {
364  return -1;
365  }
366 
367  while (pgwin32_waitforsinglesocket(s, FD_CONNECT, INFINITE) == 0)
368  {
369  /* Loop endlessly as long as we are just delivering signals */
370  }
371 
372  return 0;
373 }
int pgwin32_waitforsinglesocket(SOCKET s, int what, int timeout)
Definition: socket.c:176
static void TranslateSocketError(void)
Definition: socket.c:56

◆ pgwin32_create_signal_listener()

HANDLE pgwin32_create_signal_listener ( pid_t  pid)

Definition at line 183 of file signal.c.

References ereport, errmsg(), ERROR, and snprintf.

Referenced by PostmasterMarkPIDForWorkerNotify().

184 {
185  char pipename[128];
186  HANDLE pipe;
187 
188  snprintf(pipename, sizeof(pipename), "\\\\.\\pipe\\pgsignal_%u", (int) pid);
189 
190  pipe = CreateNamedPipe(pipename, PIPE_ACCESS_DUPLEX,
191  PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
192  PIPE_UNLIMITED_INSTANCES, 16, 16, 1000, NULL);
193 
194  if (pipe == INVALID_HANDLE_VALUE)
195  ereport(ERROR,
196  (errmsg("could not create signal listener pipe for PID %d: error code %lu",
197  (int) pid, GetLastError())));
198 
199  return pipe;
200 }
#define ERROR
Definition: elog.h:45
#define ereport(elevel,...)
Definition: elog.h:155
int errmsg(const char *fmt,...)
Definition: elog.c:915
#define snprintf
Definition: port.h:215

◆ pgwin32_dispatch_queued_signals()

void pgwin32_dispatch_queued_signals ( void  )

Definition at line 108 of file signal.c.

References Assert, i, pg_signal_array, PG_SIGNAL_COUNT, pg_signal_crit_sec, pg_signal_defaults, pg_signal_queue, pgwin32_signal_event, sig, SIG_DFL, SIG_ERR, SIG_IGN, sigmask, and UNBLOCKED_SIGNAL_QUEUE.

Referenced by pg_usleep(), PGSemaphoreLock(), pgwin32_poll_signals(), pgwin32_select(), pgwin32_waitforsinglesocket(), pqsigsetmask(), and WaitEventSetWait().

109 {
110  int exec_mask;
111 
112  Assert(pgwin32_signal_event != NULL);
113  EnterCriticalSection(&pg_signal_crit_sec);
114  while ((exec_mask = UNBLOCKED_SIGNAL_QUEUE()) != 0)
115  {
116  /* One or more unblocked signals queued for execution */
117  int i;
118 
119  for (i = 1; i < PG_SIGNAL_COUNT; i++)
120  {
121  if (exec_mask & sigmask(i))
122  {
123  /* Execute this signal */
125 
126  if (sig == SIG_DFL)
127  sig = pg_signal_defaults[i];
128  pg_signal_queue &= ~sigmask(i);
129  if (sig != SIG_ERR && sig != SIG_IGN && sig != SIG_DFL)
130  {
131  LeaveCriticalSection(&pg_signal_crit_sec);
132  sig(i);
133  EnterCriticalSection(&pg_signal_crit_sec);
134  break; /* Restart outer loop, in case signal mask or
135  * queue has been modified inside signal
136  * handler */
137  }
138  }
139  }
140  }
141  ResetEvent(pgwin32_signal_event);
142  LeaveCriticalSection(&pg_signal_crit_sec);
143 }
void(* pqsigfunc)(int signo)
Definition: port.h:538
volatile int pg_signal_queue
Definition: signal.c:24
#define SIG_ERR
Definition: win32_port.h:155
#define sigmask(sig)
Definition: win32_port.h:148
#define UNBLOCKED_SIGNAL_QUEUE()
Definition: win32_port.h:445
HANDLE pgwin32_signal_event
Definition: signal.c:27
static CRITICAL_SECTION pg_signal_crit_sec
Definition: signal.c:34
#define PG_SIGNAL_COUNT
Definition: win32_port.h:446
#define SIG_IGN
Definition: win32_port.h:156
static pqsigfunc pg_signal_defaults[PG_SIGNAL_COUNT]
Definition: signal.c:38
static int sig
Definition: pg_ctl.c:84
#define SIG_DFL
Definition: win32_port.h:154
#define Assert(condition)
Definition: c.h:792
static pqsigfunc pg_signal_array[PG_SIGNAL_COUNT]
Definition: signal.c:37
int i

◆ pgwin32_install_crashdump_handler()

void pgwin32_install_crashdump_handler ( void  )

Definition at line 180 of file crashdump.c.

References crashDumpHandler().

Referenced by main().

181 {
182  SetUnhandledExceptionFilter(crashDumpHandler);
183 }
static LONG WINAPI crashDumpHandler(struct _EXCEPTION_POINTERS *pExceptionInfo)
Definition: crashdump.c:92

◆ pgwin32_is_admin()

int pgwin32_is_admin ( void  )

Definition at line 49 of file win32security.c.

References _, and log_error.

Referenced by check_root().

50 {
51  PSID AdministratorsSid;
52  PSID PowerUsersSid;
53  SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY};
54  BOOL IsAdministrators;
55  BOOL IsPowerUsers;
56 
57  if (!AllocateAndInitializeSid(&NtAuthority, 2,
58  SECURITY_BUILTIN_DOMAIN_RID,
59  DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0,
60  0, &AdministratorsSid))
61  {
62  log_error(_("could not get SID for Administrators group: error code %lu\n"),
63  GetLastError());
64  exit(1);
65  }
66 
67  if (!AllocateAndInitializeSid(&NtAuthority, 2,
68  SECURITY_BUILTIN_DOMAIN_RID,
69  DOMAIN_ALIAS_RID_POWER_USERS, 0, 0, 0, 0, 0,
70  0, &PowerUsersSid))
71  {
72  log_error(_("could not get SID for PowerUsers group: error code %lu\n"),
73  GetLastError());
74  exit(1);
75  }
76 
77  if (!CheckTokenMembership(NULL, AdministratorsSid, &IsAdministrators) ||
78  !CheckTokenMembership(NULL, PowerUsersSid, &IsPowerUsers))
79  {
80  log_error(_("could not check access token membership: error code %lu\n"),
81  GetLastError());
82  exit(1);
83  }
84 
85  FreeSid(AdministratorsSid);
86  FreeSid(PowerUsersSid);
87 
88  if (IsAdministrators || IsPowerUsers)
89  return 1;
90  else
91  return 0;
92 }
#define log_error(errcodefn,...)
Definition: exec.c:41
#define _(x)
Definition: elog.c:89

◆ pgwin32_is_junction()

bool pgwin32_is_junction ( const char *  path)

◆ pgwin32_is_service()

int pgwin32_is_service ( void  )

Definition at line 117 of file win32security.c.

References fprintf.

Referenced by send_message_to_server_log(), and write_stderr().

118 {
119  static int _is_service = -1;
120  BOOL IsMember;
121  PSID ServiceSid;
122  PSID LocalSystemSid;
123  SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY};
124 
125  /* Only check the first time */
126  if (_is_service != -1)
127  return _is_service;
128 
129  /* First check for LocalSystem */
130  if (!AllocateAndInitializeSid(&NtAuthority, 1,
131  SECURITY_LOCAL_SYSTEM_RID, 0, 0, 0, 0, 0, 0, 0,
132  &LocalSystemSid))
133  {
134  fprintf(stderr, "could not get SID for local system account\n");
135  return -1;
136  }
137 
138  if (!CheckTokenMembership(NULL, LocalSystemSid, &IsMember))
139  {
140  fprintf(stderr, "could not check access token membership: error code %lu\n",
141  GetLastError());
142  FreeSid(LocalSystemSid);
143  return -1;
144  }
145  FreeSid(LocalSystemSid);
146 
147  if (IsMember)
148  {
149  _is_service = 1;
150  return _is_service;
151  }
152 
153  /* Check for service group membership */
154  if (!AllocateAndInitializeSid(&NtAuthority, 1,
155  SECURITY_SERVICE_RID, 0, 0, 0, 0, 0, 0, 0,
156  &ServiceSid))
157  {
158  fprintf(stderr, "could not get SID for service group: error code %lu\n",
159  GetLastError());
160  return -1;
161  }
162 
163  if (!CheckTokenMembership(NULL, ServiceSid, &IsMember))
164  {
165  fprintf(stderr, "could not check access token membership: error code %lu\n",
166  GetLastError());
167  FreeSid(ServiceSid);
168  return -1;
169  }
170  FreeSid(ServiceSid);
171 
172  if (IsMember)
173  _is_service = 1;
174  else
175  _is_service = 0;
176 
177  return _is_service;
178 }
#define fprintf
Definition: port.h:219

◆ pgwin32_listen()

int pgwin32_listen ( SOCKET  s,
int  backlog 
)

Definition at line 320 of file socket.c.

References listen, and TranslateSocketError().

321 {
322  int res;
323 
324  res = listen(s, backlog);
325  if (res < 0)
327  return res;
328 }
static void TranslateSocketError(void)
Definition: socket.c:56
#define listen(s, backlog)
Definition: win32_port.h:461

◆ pgwin32_putenv()

int pgwin32_putenv ( const char *  )

Definition at line 27 of file win32env.c.

References free, and i.

Referenced by pgwin32_setenv(), and pgwin32_unsetenv().

28 {
29  char *envcpy;
30  char *cp;
31  typedef int (_cdecl * PUTENVPROC) (const char *);
32  static const char *const modulenames[] = {
33  "msvcrt", /* Visual Studio 6.0 / MinGW */
34  "msvcrtd",
35  "msvcr70", /* Visual Studio 2002 */
36  "msvcr70d",
37  "msvcr71", /* Visual Studio 2003 */
38  "msvcr71d",
39  "msvcr80", /* Visual Studio 2005 */
40  "msvcr80d",
41  "msvcr90", /* Visual Studio 2008 */
42  "msvcr90d",
43  "msvcr100", /* Visual Studio 2010 */
44  "msvcr100d",
45  "msvcr110", /* Visual Studio 2012 */
46  "msvcr110d",
47  "msvcr120", /* Visual Studio 2013 */
48  "msvcr120d",
49  "ucrtbase", /* Visual Studio 2015 and later */
50  "ucrtbased",
51  NULL
52  };
53  int i;
54 
55  /*
56  * Update process environment, making this change visible to child
57  * processes and to CRTs initializing in the future. Do this before the
58  * _putenv() loop, for the benefit of any CRT that initializes during this
59  * pgwin32_putenv() execution, after the loop checks that CRT.
60  *
61  * Need a copy of the string so we can modify it.
62  */
63  envcpy = strdup(envval);
64  if (!envcpy)
65  return -1;
66  cp = strchr(envcpy, '=');
67  if (cp == NULL)
68  {
69  free(envcpy);
70  return -1;
71  }
72  *cp = '\0';
73  cp++;
74  if (*cp)
75  {
76  /*
77  * Only call SetEnvironmentVariable() when we are adding a variable,
78  * not when removing it. Calling it on both crashes on at least
79  * certain versions of MinGW.
80  */
81  if (!SetEnvironmentVariable(envcpy, cp))
82  {
83  free(envcpy);
84  return -1;
85  }
86  }
87  free(envcpy);
88 
89  /*
90  * Each CRT has its own _putenv() symbol and copy of the environment.
91  * Update the environment in each CRT module currently loaded, so every
92  * third-party library sees this change regardless of the CRT it links
93  * against. Addresses within these modules may become invalid the moment
94  * we call FreeLibrary(), so don't cache them.
95  */
96  for (i = 0; modulenames[i]; i++)
97  {
98  HMODULE hmodule = NULL;
99  BOOL res = GetModuleHandleEx(0, modulenames[i], &hmodule);
100 
101  if (res != 0 && hmodule != NULL)
102  {
103  PUTENVPROC putenvFunc;
104 
105  putenvFunc = (PUTENVPROC) (pg_funcptr_t) GetProcAddress(hmodule, "_putenv");
106  if (putenvFunc)
107  putenvFunc(envval);
108  FreeLibrary(hmodule);
109  }
110  }
111 
112  /*
113  * Finally, update our "own" cache. This is redundant with the loop
114  * above, except when PostgreSQL itself links to a CRT not listed above.
115  * Ideally, the loop does visit all possible CRTs, making this redundant.
116  */
117  return _putenv(envval);
118 }
#define free(a)
Definition: header.h:65
int i
void(* pg_funcptr_t)(void)
Definition: c.h:328

◆ pgwin32_recv()

int pgwin32_recv ( SOCKET  s,
char *  buf,
int  len,
int  flags 
)

Definition at line 376 of file socket.c.

References buf, ereport, errmsg_internal(), EWOULDBLOCK, NOTICE, pg_usleep(), pgwin32_noblock, pgwin32_poll_signals(), pgwin32_waitforsinglesocket(), and TranslateSocketError().

377 {
378  WSABUF wbuf;
379  int r;
380  DWORD b;
381  DWORD flags = f;
382  int n;
383 
384  if (pgwin32_poll_signals())
385  return -1;
386 
387  wbuf.len = len;
388  wbuf.buf = buf;
389 
390  r = WSARecv(s, &wbuf, 1, &b, &flags, NULL, NULL);
391  if (r != SOCKET_ERROR)
392  return b; /* success */
393 
394  if (WSAGetLastError() != WSAEWOULDBLOCK)
395  {
397  return -1;
398  }
399 
400  if (pgwin32_noblock)
401  {
402  /*
403  * No data received, and we are in "emulated non-blocking mode", so
404  * return indicating that we'd block if we were to continue.
405  */
406  errno = EWOULDBLOCK;
407  return -1;
408  }
409 
410  /* We're in blocking mode, so wait for data */
411 
412  for (n = 0; n < 5; n++)
413  {
414  if (pgwin32_waitforsinglesocket(s, FD_READ | FD_CLOSE | FD_ACCEPT,
415  INFINITE) == 0)
416  return -1; /* errno already set */
417 
418  r = WSARecv(s, &wbuf, 1, &b, &flags, NULL, NULL);
419  if (r != SOCKET_ERROR)
420  return b; /* success */
421  if (WSAGetLastError() != WSAEWOULDBLOCK)
422  {
424  return -1;
425  }
426 
427  /*
428  * There seem to be cases on win2k (at least) where WSARecv can return
429  * WSAEWOULDBLOCK even when pgwin32_waitforsinglesocket claims the
430  * socket is readable. In this case, just sleep for a moment and try
431  * again. We try up to 5 times - if it fails more than that it's not
432  * likely to ever come back.
433  */
434  pg_usleep(10000);
435  }
436  ereport(NOTICE,
437  (errmsg_internal("could not read from ready socket (after retries)")));
438  errno = EWOULDBLOCK;
439  return -1;
440 }
int pgwin32_noblock
Definition: socket.c:28
void pg_usleep(long microsec)
Definition: signal.c:53
static int pgwin32_poll_signals(void)
Definition: socket.c:152
static char * buf
Definition: pg_test_fsync.c:68
int pgwin32_waitforsinglesocket(SOCKET s, int what, int timeout)
Definition: socket.c:176
static void TranslateSocketError(void)
Definition: socket.c:56
#define ereport(elevel,...)
Definition: elog.h:155
#define NOTICE
Definition: elog.h:37
int errmsg_internal(const char *fmt,...)
Definition: elog.c:1002
#define EWOULDBLOCK
Definition: win32_port.h:349

◆ pgwin32_ReserveSharedMemoryRegion()

int pgwin32_ReserveSharedMemoryRegion ( HANDLE  )

Definition at line 550 of file win32_shmem.c.

References Assert, elog, LOG, PROTECTIVE_REGION_SIZE, ShmemProtectiveRegion, UsedShmemSegAddr, and UsedShmemSegSize.

Referenced by BackendRun().

551 {
552  void *address;
553 
554  Assert(ShmemProtectiveRegion != NULL);
555  Assert(UsedShmemSegAddr != NULL);
556  Assert(UsedShmemSegSize != 0);
557 
558  /* ShmemProtectiveRegion */
559  address = VirtualAllocEx(hChild, ShmemProtectiveRegion,
561  MEM_RESERVE, PAGE_NOACCESS);
562  if (address == NULL)
563  {
564  /* Don't use FATAL since we're running in the postmaster */
565  elog(LOG, "could not reserve shared memory region (addr=%p) for child %p: error code %lu",
566  ShmemProtectiveRegion, hChild, GetLastError());
567  return false;
568  }
569  if (address != ShmemProtectiveRegion)
570  {
571  /*
572  * Should never happen - in theory if allocation granularity causes
573  * strange effects it could, so check just in case.
574  *
575  * Don't use FATAL since we're running in the postmaster.
576  */
577  elog(LOG, "reserved shared memory region got incorrect address %p, expected %p",
578  address, ShmemProtectiveRegion);
579  return false;
580  }
581 
582  /* UsedShmemSegAddr */
583  address = VirtualAllocEx(hChild, UsedShmemSegAddr, UsedShmemSegSize,
584  MEM_RESERVE, PAGE_READWRITE);
585  if (address == NULL)
586  {
587  elog(LOG, "could not reserve shared memory region (addr=%p) for child %p: error code %lu",
588  UsedShmemSegAddr, hChild, GetLastError());
589  return false;
590  }
591  if (address != UsedShmemSegAddr)
592  {
593  elog(LOG, "reserved shared memory region got incorrect address %p, expected %p",
594  address, UsedShmemSegAddr);
595  return false;
596  }
597 
598  return true;
599 }
#define PROTECTIVE_REGION_SIZE
Definition: win32_shmem.c:39
void * ShmemProtectiveRegion
Definition: win32_shmem.c:40
#define LOG
Definition: elog.h:26
static Size UsedShmemSegSize
Definition: win32_shmem.c:44
#define Assert(condition)
Definition: c.h:792
#define elog(elevel,...)
Definition: elog.h:228
void * UsedShmemSegAddr
Definition: win32_shmem.c:43

◆ pgwin32_select()

int pgwin32_select ( int  nfds,
fd_set *  readfds,
fd_set *  writefds,
fd_set *  exceptfds,
const struct timeval *  timeout 
)

Definition at line 511 of file socket.c.

References Assert, buf, EINTR, elog, ERROR, i, pgwin32_dispatch_queued_signals(), pgwin32_poll_signals(), pgwin32_signal_event, and TranslateSocketError().

512 {
513  WSAEVENT events[FD_SETSIZE * 2]; /* worst case is readfds totally
514  * different from writefds, so
515  * 2*FD_SETSIZE sockets */
516  SOCKET sockets[FD_SETSIZE * 2];
517  int numevents = 0;
518  int i;
519  int r;
520  DWORD timeoutval = WSA_INFINITE;
521  FD_SET outreadfds;
522  FD_SET outwritefds;
523  int nummatches = 0;
524 
525  Assert(exceptfds == NULL);
526 
527  if (pgwin32_poll_signals())
528  return -1;
529 
530  FD_ZERO(&outreadfds);
531  FD_ZERO(&outwritefds);
532 
533  /*
534  * Windows does not guarantee to log an FD_WRITE network event indicating
535  * that more data can be sent unless the previous send() failed with
536  * WSAEWOULDBLOCK. While our caller might well have made such a call, we
537  * cannot assume that here. Therefore, if waiting for write-ready, force
538  * the issue by doing a dummy send(). If the dummy send() succeeds,
539  * assume that the socket is in fact write-ready, and return immediately.
540  * Also, if it fails with something other than WSAEWOULDBLOCK, return a
541  * write-ready indication to let our caller deal with the error condition.
542  */
543  if (writefds != NULL)
544  {
545  for (i = 0; i < writefds->fd_count; i++)
546  {
547  char c;
548  WSABUF buf;
549  DWORD sent;
550 
551  buf.buf = &c;
552  buf.len = 0;
553 
554  r = WSASend(writefds->fd_array[i], &buf, 1, &sent, 0, NULL, NULL);
555  if (r == 0 || WSAGetLastError() != WSAEWOULDBLOCK)
556  FD_SET(writefds->fd_array[i], &outwritefds);
557  }
558 
559  /* If we found any write-ready sockets, just return them immediately */
560  if (outwritefds.fd_count > 0)
561  {
562  memcpy(writefds, &outwritefds, sizeof(fd_set));
563  if (readfds)
564  FD_ZERO(readfds);
565  return outwritefds.fd_count;
566  }
567  }
568 
569 
570  /* Now set up for an actual select */
571 
572  if (timeout != NULL)
573  {
574  /* timeoutval is in milliseconds */
575  timeoutval = timeout->tv_sec * 1000 + timeout->tv_usec / 1000;
576  }
577 
578  if (readfds != NULL)
579  {
580  for (i = 0; i < readfds->fd_count; i++)
581  {
582  events[numevents] = WSACreateEvent();
583  sockets[numevents] = readfds->fd_array[i];
584  numevents++;
585  }
586  }
587  if (writefds != NULL)
588  {
589  for (i = 0; i < writefds->fd_count; i++)
590  {
591  if (!readfds ||
592  !FD_ISSET(writefds->fd_array[i], readfds))
593  {
594  /* If the socket is not in the read list */
595  events[numevents] = WSACreateEvent();
596  sockets[numevents] = writefds->fd_array[i];
597  numevents++;
598  }
599  }
600  }
601 
602  for (i = 0; i < numevents; i++)
603  {
604  int flags = 0;
605 
606  if (readfds && FD_ISSET(sockets[i], readfds))
607  flags |= FD_READ | FD_ACCEPT | FD_CLOSE;
608 
609  if (writefds && FD_ISSET(sockets[i], writefds))
610  flags |= FD_WRITE | FD_CLOSE;
611 
612  if (WSAEventSelect(sockets[i], events[i], flags) != 0)
613  {
615  /* release already-assigned event objects */
616  while (--i >= 0)
617  WSAEventSelect(sockets[i], NULL, 0);
618  for (i = 0; i < numevents; i++)
619  WSACloseEvent(events[i]);
620  return -1;
621  }
622  }
623 
624  events[numevents] = pgwin32_signal_event;
625  r = WaitForMultipleObjectsEx(numevents + 1, events, FALSE, timeoutval, TRUE);
626  if (r != WAIT_TIMEOUT && r != WAIT_IO_COMPLETION && r != (WAIT_OBJECT_0 + numevents))
627  {
628  /*
629  * We scan all events, even those not signaled, in case more than one
630  * event has been tagged but Wait.. can only return one.
631  */
632  WSANETWORKEVENTS resEvents;
633 
634  for (i = 0; i < numevents; i++)
635  {
636  ZeroMemory(&resEvents, sizeof(resEvents));
637  if (WSAEnumNetworkEvents(sockets[i], events[i], &resEvents) != 0)
638  elog(ERROR, "failed to enumerate network events: error code %u",
639  WSAGetLastError());
640  /* Read activity? */
641  if (readfds && FD_ISSET(sockets[i], readfds))
642  {
643  if ((resEvents.lNetworkEvents & FD_READ) ||
644  (resEvents.lNetworkEvents & FD_ACCEPT) ||
645  (resEvents.lNetworkEvents & FD_CLOSE))
646  {
647  FD_SET(sockets[i], &outreadfds);
648 
649  nummatches++;
650  }
651  }
652  /* Write activity? */
653  if (writefds && FD_ISSET(sockets[i], writefds))
654  {
655  if ((resEvents.lNetworkEvents & FD_WRITE) ||
656  (resEvents.lNetworkEvents & FD_CLOSE))
657  {
658  FD_SET(sockets[i], &outwritefds);
659 
660  nummatches++;
661  }
662  }
663  }
664  }
665 
666  /* Clean up all the event objects */
667  for (i = 0; i < numevents; i++)
668  {
669  WSAEventSelect(sockets[i], NULL, 0);
670  WSACloseEvent(events[i]);
671  }
672 
673  if (r == WSA_WAIT_TIMEOUT)
674  {
675  if (readfds)
676  FD_ZERO(readfds);
677  if (writefds)
678  FD_ZERO(writefds);
679  return 0;
680  }
681 
682  /* Signal-like events. */
683  if (r == WAIT_OBJECT_0 + numevents || r == WAIT_IO_COMPLETION)
684  {
686  errno = EINTR;
687  if (readfds)
688  FD_ZERO(readfds);
689  if (writefds)
690  FD_ZERO(writefds);
691  return -1;
692  }
693 
694  /* Overwrite socket sets with our resulting values */
695  if (readfds)
696  memcpy(readfds, &outreadfds, sizeof(fd_set));
697  if (writefds)
698  memcpy(writefds, &outwritefds, sizeof(fd_set));
699  return nummatches;
700 }
HANDLE pgwin32_signal_event
Definition: signal.c:27
void pgwin32_dispatch_queued_signals(void)
Definition: signal.c:108
#define ERROR
Definition: elog.h:45
static int pgwin32_poll_signals(void)
Definition: socket.c:152
char * c
static char * buf
Definition: pg_test_fsync.c:68
static void TranslateSocketError(void)
Definition: socket.c:56
#define Assert(condition)
Definition: c.h:792
#define elog(elevel,...)
Definition: elog.h:228
int i
#define EINTR
Definition: win32_port.h:343

◆ pgwin32_send()

int pgwin32_send ( SOCKET  s,
const void *  buf,
int  len,
int  flags 
)

Definition at line 453 of file socket.c.

References EWOULDBLOCK, pgwin32_noblock, pgwin32_poll_signals(), pgwin32_waitforsinglesocket(), and TranslateSocketError().

454 {
455  WSABUF wbuf;
456  int r;
457  DWORD b;
458 
459  if (pgwin32_poll_signals())
460  return -1;
461 
462  wbuf.len = len;
463  wbuf.buf = (char *) buf;
464 
465  /*
466  * Readiness of socket to send data to UDP socket may be not true: socket
467  * can become busy again! So loop until send or error occurs.
468  */
469  for (;;)
470  {
471  r = WSASend(s, &wbuf, 1, &b, flags, NULL, NULL);
472  if (r != SOCKET_ERROR && b > 0)
473  /* Write succeeded right away */
474  return b;
475 
476  if (r == SOCKET_ERROR &&
477  WSAGetLastError() != WSAEWOULDBLOCK)
478  {
480  return -1;
481  }
482 
483  if (pgwin32_noblock)
484  {
485  /*
486  * No data sent, and we are in "emulated non-blocking mode", so
487  * return indicating that we'd block if we were to continue.
488  */
489  errno = EWOULDBLOCK;
490  return -1;
491  }
492 
493  /* No error, zero bytes (win2000+) or error+WSAEWOULDBLOCK (<=nt4) */
494 
495  if (pgwin32_waitforsinglesocket(s, FD_WRITE | FD_CLOSE, INFINITE) == 0)
496  return -1;
497  }
498 
499  return -1;
500 }
int pgwin32_noblock
Definition: socket.c:28
static int pgwin32_poll_signals(void)
Definition: socket.c:152
static char * buf
Definition: pg_test_fsync.c:68
int pgwin32_waitforsinglesocket(SOCKET s, int what, int timeout)
Definition: socket.c:176
static void TranslateSocketError(void)
Definition: socket.c:56
#define EWOULDBLOCK
Definition: win32_port.h:349

◆ pgwin32_setenv()

int pgwin32_setenv ( const char *  name,
const char *  value,
int  overwrite 
)

Definition at line 121 of file win32env.c.

References free, malloc, pgwin32_putenv(), and sprintf.

122 {
123  int res;
124  char *envstr;
125 
126  /* Error conditions, per POSIX */
127  if (name == NULL || name[0] == '\0' || strchr(name, '=') != NULL ||
128  value == NULL)
129  {
130  errno = EINVAL;
131  return -1;
132  }
133 
134  /* No work if variable exists and we're not to replace it */
135  if (overwrite == 0 && getenv(name) != NULL)
136  return 0;
137 
138  envstr = (char *) malloc(strlen(name) + strlen(value) + 2);
139  if (!envstr) /* not much we can do if no memory */
140  return -1;
141 
142  sprintf(envstr, "%s=%s", name, value);
143 
144  res = pgwin32_putenv(envstr);
145  free(envstr);
146  return res;
147 }
static struct @144 value
#define malloc(a)
Definition: header.h:50
#define sprintf
Definition: port.h:217
static void overwrite(PGconn *conn, Oid lobjId, int start, int len)
Definition: testlo.c:108
#define free(a)
Definition: header.h:65
const char * name
Definition: encode.c:515
int pgwin32_putenv(const char *envval)
Definition: win32env.c:27

◆ pgwin32_setlocale()

char* pgwin32_setlocale ( int  category,
const char *  locale 
)

Definition at line 172 of file win32setlocale.c.

References map_locale(), setlocale, and unconstify.

173 {
174  const char *argument;
175  char *result;
176 
177  if (locale == NULL)
178  argument = NULL;
179  else
181 
182  /* Call the real setlocale() function */
183  result = setlocale(category, argument);
184 
185  /*
186  * setlocale() is specified to return a "char *" that the caller is
187  * forbidden to modify, so casting away the "const" is innocuous.
188  */
189  if (result)
190  result = unconstify(char *, map_locale(locale_map_result, result));
191 
192  return result;
193 }
#define setlocale(a, b)
Definition: win32_port.h:436
static const char * map_locale(const struct locale_map *map, const char *locale)
static const struct locale_map locale_map_argument[]
#define unconstify(underlying_type, expr)
Definition: c.h:1231
static const struct locale_map locale_map_result[]
static char * locale
Definition: initdb.c:126

◆ pgwin32_signal_initialize()

void pgwin32_signal_initialize ( void  )

Definition at line 69 of file signal.c.

References ereport, errmsg_internal(), FATAL, i, pg_console_handler(), pg_signal_array, PG_SIGNAL_COUNT, pg_signal_crit_sec, pg_signal_defaults, pg_signal_mask, pg_signal_queue, pg_signal_thread(), pgwin32_signal_event, SIG_DFL, and SIG_IGN.

Referenced by BackendRun(), and main().

70 {
71  int i;
72  HANDLE signal_thread_handle;
73 
74  InitializeCriticalSection(&pg_signal_crit_sec);
75 
76  for (i = 0; i < PG_SIGNAL_COUNT; i++)
77  {
80  }
81  pg_signal_mask = 0;
82  pg_signal_queue = 0;
83 
84  /* Create the global event handle used to flag signals */
85  pgwin32_signal_event = CreateEvent(NULL, TRUE, FALSE, NULL);
86  if (pgwin32_signal_event == NULL)
87  ereport(FATAL,
88  (errmsg_internal("could not create signal event: error code %lu", GetLastError())));
89 
90  /* Create thread for handling signals */
91  signal_thread_handle = CreateThread(NULL, 0, pg_signal_thread, NULL, 0, NULL);
92  if (signal_thread_handle == NULL)
93  ereport(FATAL,
94  (errmsg_internal("could not create signal handler thread")));
95 
96  /* Create console control handle to pick up Ctrl-C etc */
97  if (!SetConsoleCtrlHandler(pg_console_handler, TRUE))
98  ereport(FATAL,
99  (errmsg_internal("could not set console control handler")));
100 }
int pg_signal_mask
Definition: signal.c:25
static BOOL WINAPI pg_console_handler(DWORD dwCtrlType)
Definition: signal.c:333
volatile int pg_signal_queue
Definition: signal.c:24
HANDLE pgwin32_signal_event
Definition: signal.c:27
#define FATAL
Definition: elog.h:54
static CRITICAL_SECTION pg_signal_crit_sec
Definition: signal.c:34
#define PG_SIGNAL_COUNT
Definition: win32_port.h:446
#define SIG_IGN
Definition: win32_port.h:156
static pqsigfunc pg_signal_defaults[PG_SIGNAL_COUNT]
Definition: signal.c:38
#define ereport(elevel,...)
Definition: elog.h:155
int errmsg_internal(const char *fmt,...)
Definition: elog.c:1002
#define SIG_DFL
Definition: win32_port.h:154
static pqsigfunc pg_signal_array[PG_SIGNAL_COUNT]
Definition: signal.c:37
int i
static DWORD WINAPI pg_signal_thread(LPVOID param)
Definition: signal.c:230

◆ pgwin32_socket()

SOCKET pgwin32_socket ( int  af,
int  type,
int  protocol 
)

Definition at line 286 of file socket.c.

References TranslateSocketError().

287 {
288  SOCKET s;
289  unsigned long on = 1;
290 
291  s = WSASocket(af, type, protocol, NULL, 0, WSA_FLAG_OVERLAPPED);
292  if (s == INVALID_SOCKET)
293  {
295  return INVALID_SOCKET;
296  }
297 
298  if (ioctlsocket(s, FIONBIO, &on))
299  {
301  return INVALID_SOCKET;
302  }
303  errno = 0;
304 
305  return s;
306 }
static void TranslateSocketError(void)
Definition: socket.c:56

◆ pgwin32_unsetenv()

int pgwin32_unsetenv ( const char *  name)

Definition at line 150 of file win32env.c.

References free, malloc, pgwin32_putenv(), and sprintf.

151 {
152  int res;
153  char *envbuf;
154 
155  envbuf = (char *) malloc(strlen(name) + 2);
156  if (!envbuf)
157  return -1;
158 
159  sprintf(envbuf, "%s=", name);
160  res = pgwin32_putenv(envbuf);
161  free(envbuf);
162  return res;
163 }
#define malloc(a)
Definition: header.h:50
#define sprintf
Definition: port.h:217
#define free(a)
Definition: header.h:65
const char * name
Definition: encode.c:515
int pgwin32_putenv(const char *envval)
Definition: win32env.c:27

◆ pgwin32_waitforsinglesocket()

int pgwin32_waitforsinglesocket ( SOCKET  s,
int  what,
int  timeout 
)

Definition at line 176 of file socket.c.

References buf, EINTR, ereport, errmsg_internal(), ERROR, EWOULDBLOCK, isDataGram(), pgwin32_dispatch_queued_signals(), pgwin32_signal_event, and TranslateSocketError().

Referenced by pgwin32_connect(), pgwin32_recv(), and pgwin32_send().

177 {
178  static HANDLE waitevent = INVALID_HANDLE_VALUE;
179  static SOCKET current_socket = INVALID_SOCKET;
180  static int isUDP = 0;
181  HANDLE events[2];
182  int r;
183 
184  /* Create an event object just once and use it on all future calls */
185  if (waitevent == INVALID_HANDLE_VALUE)
186  {
187  waitevent = CreateEvent(NULL, TRUE, FALSE, NULL);
188 
189  if (waitevent == INVALID_HANDLE_VALUE)
190  ereport(ERROR,
191  (errmsg_internal("could not create socket waiting event: error code %lu", GetLastError())));
192  }
193  else if (!ResetEvent(waitevent))
194  ereport(ERROR,
195  (errmsg_internal("could not reset socket waiting event: error code %lu", GetLastError())));
196 
197  /*
198  * Track whether socket is UDP or not. (NB: most likely, this is both
199  * useless and wrong; there is no reason to think that the behavior of
200  * WSAEventSelect is different for TCP and UDP.)
201  */
202  if (current_socket != s)
203  isUDP = isDataGram(s);
204  current_socket = s;
205 
206  /*
207  * Attach event to socket. NOTE: we must detach it again before
208  * returning, since other bits of code may try to attach other events to
209  * the socket.
210  */
211  if (WSAEventSelect(s, waitevent, what) != 0)
212  {
214  return 0;
215  }
216 
217  events[0] = pgwin32_signal_event;
218  events[1] = waitevent;
219 
220  /*
221  * Just a workaround of unknown locking problem with writing in UDP socket
222  * under high load: Client's pgsql backend sleeps infinitely in
223  * WaitForMultipleObjectsEx, pgstat process sleeps in pgwin32_select().
224  * So, we will wait with small timeout(0.1 sec) and if socket is still
225  * blocked, try WSASend (see comments in pgwin32_select) and wait again.
226  */
227  if ((what & FD_WRITE) && isUDP)
228  {
229  for (;;)
230  {
231  r = WaitForMultipleObjectsEx(2, events, FALSE, 100, TRUE);
232 
233  if (r == WAIT_TIMEOUT)
234  {
235  char c;
236  WSABUF buf;
237  DWORD sent;
238 
239  buf.buf = &c;
240  buf.len = 0;
241 
242  r = WSASend(s, &buf, 1, &sent, 0, NULL, NULL);
243  if (r == 0) /* Completed - means things are fine! */
244  {
245  WSAEventSelect(s, NULL, 0);
246  return 1;
247  }
248  else if (WSAGetLastError() != WSAEWOULDBLOCK)
249  {
251  WSAEventSelect(s, NULL, 0);
252  return 0;
253  }
254  }
255  else
256  break;
257  }
258  }
259  else
260  r = WaitForMultipleObjectsEx(2, events, FALSE, timeout, TRUE);
261 
262  WSAEventSelect(s, NULL, 0);
263 
264  if (r == WAIT_OBJECT_0 || r == WAIT_IO_COMPLETION)
265  {
267  errno = EINTR;
268  return 0;
269  }
270  if (r == WAIT_OBJECT_0 + 1)
271  return 1;
272  if (r == WAIT_TIMEOUT)
273  {
274  errno = EWOULDBLOCK;
275  return 0;
276  }
277  ereport(ERROR,
278  (errmsg_internal("unrecognized return value from WaitForMultipleObjects: %d (error code %lu)", r, GetLastError())));
279  return 0;
280 }
HANDLE pgwin32_signal_event
Definition: signal.c:27
void pgwin32_dispatch_queued_signals(void)
Definition: signal.c:108
#define ERROR
Definition: elog.h:45
char * c
static char * buf
Definition: pg_test_fsync.c:68
static void TranslateSocketError(void)
Definition: socket.c:56
static int isDataGram(SOCKET s)
Definition: socket.c:164
#define ereport(elevel,...)
Definition: elog.h:155
int errmsg_internal(const char *fmt,...)
Definition: elog.c:1002
#define EWOULDBLOCK
Definition: win32_port.h:349
#define EINTR
Definition: win32_port.h:343

◆ setitimer()

int setitimer ( int  which,
const struct itimerval value,
struct itimerval ovalue 
)

Definition at line 86 of file timer.c.

References Assert, timerCA::crit_sec, ereport, errmsg_internal(), timerCA::event, FATAL, itimerval::it_interval, ITIMER_REAL, MemSet, pg_timer_thread(), timerThreadHandle, and timerCA::value.

Referenced by fork_process(), and schedule_alarm().

87 {
88  Assert(value != NULL);
89  Assert(value->it_interval.tv_sec == 0 && value->it_interval.tv_usec == 0);
90  Assert(which == ITIMER_REAL);
91 
92  if (timerThreadHandle == INVALID_HANDLE_VALUE)
93  {
94  /* First call in this backend, create event and the timer thread */
95  timerCommArea.event = CreateEvent(NULL, TRUE, FALSE, NULL);
96  if (timerCommArea.event == NULL)
97  ereport(FATAL,
98  (errmsg_internal("could not create timer event: error code %lu",
99  GetLastError())));
100 
101  MemSet(&timerCommArea.value, 0, sizeof(struct itimerval));
102 
103  InitializeCriticalSection(&timerCommArea.crit_sec);
104 
105  timerThreadHandle = CreateThread(NULL, 0, pg_timer_thread, NULL, 0, NULL);
106  if (timerThreadHandle == INVALID_HANDLE_VALUE)
107  ereport(FATAL,
108  (errmsg_internal("could not create timer thread: error code %lu",
109  GetLastError())));
110  }
111 
112  /* Request the timer thread to change settings */
113  EnterCriticalSection(&timerCommArea.crit_sec);
114  if (ovalue)
115  *ovalue = timerCommArea.value;
117  LeaveCriticalSection(&timerCommArea.crit_sec);
118  SetEvent(timerCommArea.event);
119 
120  return 0;
121 }
static struct @144 value
#define MemSet(start, val, len)
Definition: c.h:996
HANDLE event
Definition: timer.c:26
static DWORD WINAPI pg_timer_thread(LPVOID param)
Definition: timer.c:36
#define FATAL
Definition: elog.h:54
static timerCA timerCommArea
Definition: timer.c:30
#define ereport(elevel,...)
Definition: elog.h:155
struct itimerval value
Definition: timer.c:25
int errmsg_internal(const char *fmt,...)
Definition: elog.c:1002
#define Assert(condition)
Definition: c.h:792
CRITICAL_SECTION crit_sec
Definition: timer.c:27
struct timeval it_interval
Definition: win32_port.h:190
static HANDLE timerThreadHandle
Definition: timer.c:31
#define ITIMER_REAL
Definition: win32_port.h:187

Variable Documentation

◆ pg_signal_mask

PGDLLIMPORT int pg_signal_mask

Definition at line 25 of file signal.c.

Referenced by pgwin32_signal_initialize(), and pqsigsetmask().

◆ pg_signal_queue

PGDLLIMPORT volatile int pg_signal_queue

◆ pgwin32_initial_signal_pipe

HANDLE pgwin32_initial_signal_pipe

Definition at line 28 of file signal.c.

Referenced by pg_signal_thread(), and PostmasterMarkPIDForWorkerNotify().

◆ pgwin32_noblock

int pgwin32_noblock

◆ pgwin32_signal_event