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

Appearance settings

Commit 09f70e8

Browse filesBrowse files
committed
修改锁的粒度
1 parent b46ab77 commit 09f70e8
Copy full SHA for 09f70e8

File tree

1 file changed

+3
-4
lines changed
Filter options

1 file changed

+3
-4
lines changed

‎client/xclient.go

Copy file name to clipboardExpand all lines: client/xclient.go
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,8 @@ func (c *xClient) getCachedClient(k string, servicePath, serviceMethod string, a
300300
}
301301

302302
c.mu.Lock()
303+
defer c.mu.Unlock()
304+
303305
client = c.findCachedClient(k, servicePath, serviceMethod)
304306
if client != nil {
305307
if !client.IsClosing() && !client.IsShutdown() {
@@ -308,9 +310,8 @@ func (c *xClient) getCachedClient(k string, servicePath, serviceMethod string, a
308310
}
309311
c.deleteCachedClient(client, k, servicePath, serviceMethod)
310312
}
311-
313+
312314
client = c.findCachedClient(k, servicePath, serviceMethod)
313-
c.mu.Unlock()
314315

315316
if client == nil || client.IsShutdown() {
316317
generatedClient, err, _ := c.slGroup.Do(k, func() (interface{}, error) {
@@ -329,9 +330,7 @@ func (c *xClient) getCachedClient(k string, servicePath, serviceMethod string, a
329330

330331
client.RegisterServerMessageChan(c.serverMessageChan)
331332

332-
c.mu.Lock()
333333
c.setCachedClient(client, k, servicePath, serviceMethod)
334-
c.mu.Unlock()
335334

336335
// forget k only when client is cached
337336
c.slGroup.Forget(k)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.