Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1d722cf

Browse files
committed
Reduce the amount of memory "clobbered" for every process title change,
on platforms that need this. This is done by only writing past thepreviously stored message, if it was longer.
1 parent8249409 commit1d722cf

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

‎src/backend/utils/misc/ps_status.c

Lines changed: 8 additions & 4 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.34 2007/01/05 22:19:46 momjian Exp $
8+
* $PostgreSQL: pgsql/src/backend/utils/misc/ps_status.c,v 1.35 2007/02/16 21:34:04 momjian Exp $
99
*
1010
* Copyright (c) 2000-2007, PostgreSQL Global Development Group
1111
* various details abducted from various places
@@ -91,6 +91,7 @@ static const size_t ps_buffer_size = PS_BUFFER_SIZE;
9191
#else/* PS_USE_CLOBBER_ARGV */
9292
staticchar*ps_buffer;/* will point to argv area */
9393
staticsize_tps_buffer_size;/* space determined at run time */
94+
staticsize_tlast_status_len;/* use to minimize length of clobber */
9495
#endif/* PS_USE_CLOBBER_ARGV */
9596

9697
staticsize_tps_buffer_fixed_size;/* size of the constant prefix */
@@ -153,8 +154,8 @@ save_ps_display_args(int argc, char **argv)
153154
}
154155

155156
ps_buffer=argv[0];
156-
ps_buffer_size=end_of_area-argv[0];
157-
157+
last_status_len=ps_buffer_size=end_of_area-argv[0];
158+
158159
/*
159160
* move the environment out of the way
160161
*/
@@ -329,7 +330,10 @@ set_ps_display(const char *activity, bool force)
329330

330331
/* pad unused memory */
331332
buflen=strlen(ps_buffer);
332-
MemSet(ps_buffer+buflen,PS_PADDING,ps_buffer_size-buflen);
333+
/* clobber remainder of old status string */
334+
if (last_status_len>buflen)
335+
MemSet(ps_buffer+buflen,PS_PADDING,last_status_len-buflen);
336+
last_status_len=buflen;
333337
}
334338
#endif/* PS_USE_CLOBBER_ARGV */
335339

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp