Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit 11c33a2

Browse files
ankur22ka3de
authored andcommitted
Use msgId in connection
Work with the previously defined msgId in connection. This is the first step in ensuring that all msgIds are unique at the connection scope. Currently this doesn't fix the original problem though and we need to work with this same msgId in the session too.
1 parent 7b35e83 commit 11c33a2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

common/connection.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ type Connection struct {
125125
done chan struct{}
126126
closing chan struct{}
127127
shutdownOnce sync.Once
128-
msgID int64
128+
msgID *msgID
129129

130130
sessionsMu sync.RWMutex
131131
sessions map[target.SessionID]*Session
@@ -163,7 +163,7 @@ func NewConnection(ctx context.Context, wsURL string, logger *log.Logger) (*Conn
163163
errorCh: make(chan error),
164164
done: make(chan struct{}),
165165
closing: make(chan struct{}),
166-
msgID: 0,
166+
msgID: &msgID{},
167167
sessions: make(map[target.SessionID]*Session),
168168
}
169169

@@ -509,7 +509,7 @@ func (c *Connection) Close(args ...goja.Value) {
509509
// Execute implements cdproto.Executor and performs a synchronous send and receive.
510510
func (c *Connection) Execute(ctx context.Context, method string, params easyjson.Marshaler, res easyjson.Unmarshaler) error {
511511
c.logger.Debugf("connection:Execute", "wsURL:%q method:%q", c.wsURL, method)
512-
id := atomic.AddInt64(&c.msgID, 1)
512+
id := c.msgID.new()
513513

514514
// Setup event handler used to block for response to message being sent.
515515
ch := make(chan *cdproto.Message, 1)

0 commit comments

Comments
 (0)