Skip to content

Commit e71e02d

Browse files
committed
Minor code cleanup: make the WIN32 case less gratuitously different from
the other platform-specific cases in ps_status.
1 parent e2e2a9d commit e71e02d

File tree

1 file changed

+24
-33
lines changed

1 file changed

+24
-33
lines changed

src/backend/utils/misc/ps_status.c

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* to contain some useful information. Mechanism differs wildly across
66
* platforms.
77
*
8-
* $PostgreSQL: pgsql/src/backend/utils/misc/ps_status.c,v 1.29 2006/03/05 15:58:49 momjian Exp $
8+
* $PostgreSQL: pgsql/src/backend/utils/misc/ps_status.c,v 1.30 2006/06/12 02:39:49 tgl Exp $
99
*
1010
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
1111
* various details abducted from various places
@@ -33,7 +33,7 @@
3333
extern char **environ;
3434

3535

36-
/*------
36+
/*
3737
* Alternative ways of updating ps display:
3838
*
3939
* PS_USE_SETPROCTITLE
@@ -51,6 +51,8 @@ extern char **environ;
5151
* PS_USE_CLOBBER_ARGV
5252
* write over the argv and environment area
5353
* (most SysV-like systems)
54+
* PS_USE_WIN32
55+
* push the string out as the name of a Windows event
5456
* PS_USE_NONE
5557
* don't update ps display
5658
* (This is the default, as it is safest.)
@@ -65,7 +67,7 @@ extern char **environ;
6567
#define PS_USE_CHANGE_ARGV
6668
#elif defined(__linux__) || defined(_AIX) || defined(__sgi) || (defined(sun) && !defined(BSD)) || defined(ultrix) || defined(__ksr__) || defined(__osf__) || defined(__svr4__) || defined(__svr5__) || defined(__darwin__)
6769
#define PS_USE_CLOBBER_ARGV
68-
#elif defined (WIN32)
70+
#elif defined(WIN32)
6971
#define PS_USE_WIN32
7072
#else
7173
#define PS_USE_NONE
@@ -96,30 +98,6 @@ static size_t ps_buffer_fixed_size; /* size of the constant prefix */
9698
static int save_argc;
9799
static char **save_argv;
98100

99-
#ifdef WIN32
100-
101-
/*
102-
* Win32 does not support showing any changed arguments. To make it at all
103-
* possible to track which backend is doing what, we create a named object
104-
* that can be viewed with for example Process Explorer
105-
*/
106-
static HANDLE ident_handle = INVALID_HANDLE_VALUE;
107-
static void
108-
pgwin32_update_ident(char *ident)
109-
{
110-
char name[PS_BUFFER_SIZE + 32];
111-
112-
if (ident_handle != INVALID_HANDLE_VALUE)
113-
CloseHandle(ident_handle);
114-
115-
sprintf(name, "pgident: %s", ident);
116-
117-
ident_handle = CreateEvent(NULL,
118-
TRUE,
119-
FALSE,
120-
name);
121-
}
122-
#endif
123101

124102
/*
125103
* Call this early in startup to save the original argc/argv values.
@@ -292,9 +270,6 @@ init_ps_display(const char *username, const char *dbname,
292270

293271
ps_buffer_fixed_size = strlen(ps_buffer);
294272

295-
#ifdef WIN32
296-
pgwin32_update_ident(ps_buffer);
297-
#endif
298273
#endif /* not PS_USE_NONE */
299274
}
300275

@@ -352,9 +327,25 @@ set_ps_display(const char *activity)
352327
}
353328
#endif /* PS_USE_CLOBBER_ARGV */
354329

355-
#ifdef WIN32
356-
pgwin32_update_ident(ps_buffer);
357-
#endif
330+
#ifdef PS_USE_WIN32
331+
{
332+
/*
333+
* Win32 does not support showing any changed arguments. To make it
334+
* at all possible to track which backend is doing what, we create a
335+
* named object that can be viewed with for example Process Explorer.
336+
*/
337+
static HANDLE ident_handle = INVALID_HANDLE_VALUE;
338+
char name[PS_BUFFER_SIZE + 32];
339+
340+
if (ident_handle != INVALID_HANDLE_VALUE)
341+
CloseHandle(ident_handle);
342+
343+
sprintf(name, "pgident: %s", ps_buffer);
344+
345+
ident_handle = CreateEvent(NULL, TRUE, FALSE, name);
346+
}
347+
#endif /* PS_USE_WIN32 */
348+
358349
#endif /* not PS_USE_NONE */
359350
}
360351

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