Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1bc180c

Browse files
committed
Use setproctitle_fast() to update the ps status, if available.
FreeBSD has introduced a faster variant of setproctitle(). Use it, where available. Author: Thomas Munro Discussion: https://postgr.es/m/CAEepm=1wKMTi81uodJ=1KbJAz5WedOg=cr8ewEXrUFeaxWEgww@mail.gmail.com
1 parent 3214463 commit 1bc180c

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14916,7 +14916,7 @@ fi
1491614916
LIBS_including_readline="$LIBS"
1491714917
LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
1491814918

14919-
for ac_func in cbrt clock_gettime dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll posix_fallocate pstat pthread_is_threaded_np readlink setproctitle setsid shm_open symlink sync_file_range utime utimes wcstombs_l
14919+
for ac_func in cbrt clock_gettime dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll posix_fallocate pstat pthread_is_threaded_np readlink setproctitle setproctitle_fast setsid shm_open symlink sync_file_range utime utimes wcstombs_l
1492014920
do :
1492114921
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
1492214922
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"

configure.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1540,7 +1540,7 @@ PGAC_FUNC_WCSTOMBS_L
15401540
LIBS_including_readline="$LIBS"
15411541
LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
15421542

1543-
AC_CHECK_FUNCS([cbrt clock_gettime dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll posix_fallocate pstat pthread_is_threaded_np readlink setproctitle setsid shm_open symlink sync_file_range utime utimes wcstombs_l])
1543+
AC_CHECK_FUNCS([cbrt clock_gettime dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll posix_fallocate pstat pthread_is_threaded_np readlink setproctitle setproctitle_fast setsid shm_open symlink sync_file_range utime utimes wcstombs_l])
15441544

15451545
AC_REPLACE_FUNCS(fseeko)
15461546
case $host_os in

src/backend/utils/misc/ps_status.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ bool update_process_title = true;
3838
/*
3939
* Alternative ways of updating ps display:
4040
*
41+
* PS_USE_SETPROCTITLE_FAST
42+
* use the function setproctitle_fast(const char *, ...)
43+
* (newer FreeBSD systems)
4144
* PS_USE_SETPROCTITLE
4245
* use the function setproctitle(const char *, ...)
4346
* (newer BSD systems)
@@ -59,7 +62,9 @@ bool update_process_title = true;
5962
* don't update ps display
6063
* (This is the default, as it is safest.)
6164
*/
62-
#if defined(HAVE_SETPROCTITLE)
65+
#if defined(HAVE_SETPROCTITLE_FAST)
66+
#define PS_USE_SETPROCTITLE_FAST
67+
#elif defined(HAVE_SETPROCTITLE)
6368
#define PS_USE_SETPROCTITLE
6469
#elif defined(HAVE_PSTAT) && defined(PSTAT_SETCMD)
6570
#define PS_USE_PSTAT
@@ -286,7 +291,7 @@ init_ps_display(const char *username, const char *dbname,
286291
* Make fixed prefix of ps display.
287292
*/
288293

289-
#ifdef PS_USE_SETPROCTITLE
294+
#if defined(PS_USE_SETPROCTITLE) || defined(PS_USE_SETPROCTITLE_FAST)
290295

291296
/*
292297
* apparently setproctitle() already adds a `progname:' prefix to the ps
@@ -349,6 +354,8 @@ set_ps_display(const char *activity, bool force)
349354

350355
#ifdef PS_USE_SETPROCTITLE
351356
setproctitle("%s", ps_buffer);
357+
#elif defined(PS_USE_SETPROCTITLE_FAST)
358+
setproctitle_fast("%s", ps_buffer);
352359
#endif
353360

354361
#ifdef PS_USE_PSTAT

src/include/pg_config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,9 @@
489489
/* Define to 1 if you have the `setproctitle' function. */
490490
#undef HAVE_SETPROCTITLE
491491

492+
/* Define to 1 if you have the `setproctitle_fast' function. */
493+
#undef HAVE_SETPROCTITLE_FAST
494+
492495
/* Define to 1 if you have the `setsid' function. */
493496
#undef HAVE_SETSID
494497

0 commit comments

Comments
 (0)