diff options
| author | Shulhan <ms@kilabit.info> | 2022-07-29 00:40:25 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2022-07-29 00:40:25 +0700 |
| commit | d1a4ca2ee5039cdc3c58ad76e50df619a6cdcb26 (patch) | |
| tree | cd739776e2fef6bd2bd53301a1940776ba5f78e4 | |
| parent | 3f026ebd9fa98fe508ebcf793da22b2bfacb7f71 (diff) | |
| download | pakakeh.go-d1a4ca2ee5039cdc3c58ad76e50df619a6cdcb26.tar.xz | |
lib/websocket: fix possible data race on client test
We only do lock on exported methods, but when doing testing we call
the send method without lock which cause read and write on Client.conn
at the same time.
| -rw-r--r-- | lib/websocket/client_test.go | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/websocket/client_test.go b/lib/websocket/client_test.go index c609024b..8927b4bd 100644 --- a/lib/websocket/client_test.go +++ b/lib/websocket/client_test.go @@ -501,7 +501,9 @@ func TestClientFragmentation(t *testing.T) { for x = 0; x < len(c.frames); x++ { req = c.frames[x].pack() + testClient.Lock() err = testClient.send(req) + testClient.Unlock() if err != nil { // If the client send unmasked frame, the // server may close the connection before we |
