Skip to content

C# Client: 送信時のレースコンディションを解消 - #98

Open
makiuchi-d wants to merge 5 commits into
mainfrom
fix-sender-race
Open

C# Client: 送信時のレースコンディションを解消#98
makiuchi-d wants to merge 5 commits into
mainfrom
fix-sender-race

Conversation

@makiuchi-d

@makiuchi-d makiuchi-d commented Jun 23, 2026

Copy link
Copy Markdown
Member

クライアントメッセージのHMACが一致しないことがあるのを発見
websocket再接続の前後でのレースコンディションにより、送信バッファが別タスクから書き換えられる可能性があった

修正内容:

  • キャンセル済み接続からのmsgPool読み出しを抑制
  • websocket接続ごとに送信semaphoreと切断フラグを持つように整理

挙動の変更:
NetworkInformer.OnRoomSend()呼び出しタイミングが変更になり、切断後の送信も呼び出されるようになった
もともとこの機能はデバッグ時の計測用途のため影響は軽微(Conditional("DEBUG")が指定されている)

@makiuchi-d
makiuchi-d requested a review from inada-s June 23, 2026 04:58
{
ClientWebSocket client;
SemaphoreSlim sendSemaphore;
bool closed;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ありがとうございます
volatileつけました

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

WebSocket再接続時の送信競合を抑制する変更です。

Changes:

  • キャンセル済みSenderによるメッセージ取得を抑制
  • 接続単位で送信Semaphoreと切断状態を管理

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
MsgPool.cs キャンセル検出可能な待機処理へ変更
Connection.cs WebSocket接続ごとの送信状態と同期処理を導入

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +444 to +446
if (ct.IsCancellationRequested)
{
return;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants