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
7cf53252
Unverified
Commit
7cf53252
authored
Feb 06, 2020
by
Salvatore Sanfilippo
Committed by
GitHub
Feb 06, 2020
Browse files
Merge pull request #6849 from oranagra/free_client_mutex
freeClientAsync don't lock mutex if there's just one thread
parents
44266d6d
86e302f5
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/networking.c
View file @
7cf53252
...
@@ -1163,9 +1163,14 @@ void freeClientAsync(client *c) {
...
@@ -1163,9 +1163,14 @@ void freeClientAsync(client *c) {
* may access the list while Redis uses I/O threads. All the other accesses
* may access the list while Redis uses I/O threads. All the other accesses
* are in the context of the main thread while the other threads are
* are in the context of the main thread while the other threads are
* idle. */
* idle. */
static
pthread_mutex_t
async_free_queue_mutex
=
PTHREAD_MUTEX_INITIALIZER
;
if
(
c
->
flags
&
CLIENT_CLOSE_ASAP
||
c
->
flags
&
CLIENT_LUA
)
return
;
if
(
c
->
flags
&
CLIENT_CLOSE_ASAP
||
c
->
flags
&
CLIENT_LUA
)
return
;
c
->
flags
|=
CLIENT_CLOSE_ASAP
;
c
->
flags
|=
CLIENT_CLOSE_ASAP
;
if
(
server
.
io_threads_num
==
1
)
{
/* no need to bother with locking if there's just one thread (the main thread) */
listAddNodeTail
(
server
.
clients_to_close
,
c
);
return
;
}
static
pthread_mutex_t
async_free_queue_mutex
=
PTHREAD_MUTEX_INITIALIZER
;
pthread_mutex_lock
(
&
async_free_queue_mutex
);
pthread_mutex_lock
(
&
async_free_queue_mutex
);
listAddNodeTail
(
server
.
clients_to_close
,
c
);
listAddNodeTail
(
server
.
clients_to_close
,
c
);
pthread_mutex_unlock
(
&
async_free_queue_mutex
);
pthread_mutex_unlock
(
&
async_free_queue_mutex
);
...
...
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