Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
85d1d1f8
Unverified
Commit
85d1d1f8
authored
Apr 20, 2020
by
Salvatore Sanfilippo
Committed by
GitHub
Apr 20, 2020
Browse files
Merge pull request #7089 from bytedance/set-thread-name
Threaded IO: set thread name for redis-server
parents
23219392
5010da6a
Changes
3
Show whitespace changes
Inline
Side-by-side
src/bio.c
View file @
85d1d1f8
...
...
@@ -154,6 +154,18 @@ void *bioProcessBackgroundJobs(void *arg) {
return
NULL
;
}
switch
(
type
)
{
case
BIO_CLOSE_FILE
:
redis_set_thread_title
(
"bio_close_file"
);
break
;
case
BIO_AOF_FSYNC
:
redis_set_thread_title
(
"bio_aof_fsync"
);
break
;
case
BIO_LAZY_FREE
:
redis_set_thread_title
(
"bio_lazy_free"
);
break
;
}
/* Make the thread killable at any time, so that bioKillThreads()
* can work reliably. */
pthread_setcancelstate
(
PTHREAD_CANCEL_ENABLE
,
NULL
);
...
...
src/config.h
View file @
85d1d1f8
...
...
@@ -226,4 +226,16 @@ void setproctitle(const char *fmt, ...);
#define USE_ALIGNED_ACCESS
#endif
/* Define for redis_set_thread_title */
#ifdef __linux__
#define redis_set_thread_title(name) pthread_setname_np(pthread_self(), name)
#else
#if (defined __NetBSD__ || defined __FreeBSD__ || defined __OpenBSD__)
#include <pthread_np.h>
#define redis_set_thread_title(name) pthread_set_name_np(pthread_self(), name)
#else
#define redis_set_thread_title(name)
#endif
#endif
#endif
src/networking.c
View file @
85d1d1f8
...
...
@@ -2821,6 +2821,10 @@ void *IOThreadMain(void *myid) {
/* The ID is the thread number (from 0 to server.iothreads_num-1), and is
* used by the thread to just manipulate a single sub-array of clients. */
long
id
=
(
unsigned
long
)
myid
;
char
thdname
[
16
];
snprintf
(
thdname
,
sizeof
(
thdname
),
"io_thd_%ld"
,
id
);
redis_set_thread_title
(
thdname
);
while
(
1
)
{
/* Wait for start */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment