PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: openGemini/openGemini (go)

Issue:
The MultiplexedSessionPool.Close may be deadlocked
### Describe the bug（Bug 描述）

https://github.com/openGemini/openGemini/blob/d12680553f73abea4005ef425751854d09d60ecc/engine/executor/spdy/multiplexed_session_pool.go#L167-L173

If the value of the variable c.closed is true, the lock is not released, and deadlock may occur.

For example, the Close() method is repeatedly invoked.

### To Reproduce（Bug 复现步骤）

_No response_

### Expected behavior（期望结果）

_No response_

### Screenshots（屏幕截图）

_No response_

### Logs（完整的错误日志）

_No response_

### Additional context（其他的一些补充内容）

_No response_

Pull request:
fix: deadlock for spdy when rpc session close repeated
Signed-off-by: minazukie <minazukie2015@gmail.com>

### What problem does this PR solve?
fix deadlock for spdy when rpc session close repeated. 

Issue Number: close #106

### What is changed and how it works?

Fix rpc session does not release the lock when first close. And if close again, it will cause deadlock.
Now every time we call `Close`, we will release the lock.

### How Has This Been Tested?

- [x] TestCloseAgain

# Checklist:

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my feature works
- [x] New and existing unit tests pass locally with my changes
- [x] Any dependent changes have been merged and published in downstream modules

Patch:
diff --git a/engine/executor/spdy/multiplexed_session_pool.go b/engine/executor/spdy/multiplexed_session_pool.go
index e0c62e6..891d09f 100644
--- a/engine/executor/spdy/multiplexed_session_pool.go
+++ b/engine/executor/spdy/multiplexed_session_pool.go
@@ -166,11 +166,14 @@ func (c *MultiplexedSessionPool) create() (*MultiplexedSession, error) {
 
 func (c *MultiplexedSessionPool) Close() {
 	c.closeGuard.Lock()
-	if c.closed {
-		return
-	}
+	closed := c.closed
 	c.closed = true
 	c.closeGuard.Unlock()
+
+	if closed {
+		return
+	}
+
 	c.wg.Done()
 	HandleError(c.conn.Close())
 	close(c.queue)


Test patch:
diff --git a/engine/executor/spdy/rrcserver_test.go b/engine/executor/spdy/rrcserver_test.go
index f4f7e35..84fcc97 100644
--- a/engine/executor/spdy/rrcserver_test.go
+++ b/engine/executor/spdy/rrcserver_test.go
@@ -28,6 +28,7 @@ import (
 	"github.com/openGemini/openGemini/engine/executor/spdy"
 	"github.com/openGemini/openGemini/lib/config"
 	"github.com/stretchr/testify/assert"
+	"github.com/stretchr/testify/require"
 )
 
 var (
@@ -437,6 +438,17 @@ func SequenceRequest(t *testing.T, ip string) error {
 	return nil
 }
 
+func TestCloseAgain(t *testing.T) {
+	server, spool, err := StartServer("127.0.0.8:18081")
+	require.NoError(t, err)
+
+	spool.Close()
+	spool.Close()
+
+	require.False(t, spool.Available())
+	server.Stop()
+}
+
 func TestSequenceRequest(t *testing.T) {
 	err := SequenceRequest(t, "127.0.0.8:18080")
 	if err != nil {