mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-02-23 19:39:53 +08:00
Reduce the amount of memory "clobbered" for every process title change,
on platforms that need this. This is done by only writing past the previously stored message, if it was longer.
This commit is contained in:
parent
8249409bc1
commit
1d722cf18c
@ -5,7 +5,7 @@
|
||||
* to contain some useful information. Mechanism differs wildly across
|
||||
* platforms.
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/utils/misc/ps_status.c,v 1.34 2007/01/05 22:19:46 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/misc/ps_status.c,v 1.35 2007/02/16 21:34:04 momjian Exp $
|
||||
*
|
||||
* Copyright (c) 2000-2007, PostgreSQL Global Development Group
|
||||
* various details abducted from various places
|
||||
@ -91,6 +91,7 @@ static const size_t ps_buffer_size = PS_BUFFER_SIZE;
|
||||
#else /* PS_USE_CLOBBER_ARGV */
|
||||
static char *ps_buffer; /* will point to argv area */
|
||||
static size_t ps_buffer_size; /* space determined at run time */
|
||||
static size_t last_status_len; /* use to minimize length of clobber */
|
||||
#endif /* PS_USE_CLOBBER_ARGV */
|
||||
|
||||
static size_t ps_buffer_fixed_size; /* size of the constant prefix */
|
||||
@ -153,8 +154,8 @@ save_ps_display_args(int argc, char **argv)
|
||||
}
|
||||
|
||||
ps_buffer = argv[0];
|
||||
ps_buffer_size = end_of_area - argv[0];
|
||||
|
||||
last_status_len = ps_buffer_size = end_of_area - argv[0];
|
||||
|
||||
/*
|
||||
* move the environment out of the way
|
||||
*/
|
||||
@ -329,7 +330,10 @@ set_ps_display(const char *activity, bool force)
|
||||
|
||||
/* pad unused memory */
|
||||
buflen = strlen(ps_buffer);
|
||||
MemSet(ps_buffer + buflen, PS_PADDING, ps_buffer_size - buflen);
|
||||
/* clobber remainder of old status string */
|
||||
if (last_status_len > buflen)
|
||||
MemSet(ps_buffer + buflen, PS_PADDING, last_status_len - buflen);
|
||||
last_status_len = buflen;
|
||||
}
|
||||
#endif /* PS_USE_CLOBBER_ARGV */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user