Skip to content

Use the default schedulre when starting new tasks#1536

Merged
sipsorcery merged 1 commit intomasterfrom
task-longrunning-defaultscheduler
Feb 26, 2026
Merged

Use the default schedulre when starting new tasks#1536
sipsorcery merged 1 commit intomasterfrom
task-longrunning-defaultscheduler

Conversation

@sipsorcery
Copy link
Member

Avoid long running tasks getting starved on the current conext scheduler. Resolves #1535.

…arved on the current conext scheduler. Resolves #1535.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes issue #1535 where SIP channels behave differently when started from async contexts, specifically preventing SIP messages (OPTIONS, INVITE) from being received. The fix explicitly specifies TaskScheduler.Default when starting long-running tasks to avoid them being starved on custom task schedulers that may be active in async contexts.

Changes:

  • Updated all Task.Factory.StartNew calls with TaskCreationOptions.LongRunning to explicitly use TaskScheduler.Default and CancellationToken.None
  • Applied consistently across SIPTransport and all SIP channel types (UDP, TCP, WebSocket)

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/SIPSorcery/core/SIP/SIPTransport.cs Updated ProcessReceiveQueue task creation to use TaskScheduler.Default
src/SIPSorcery/core/SIP/Channels/SIPUDPChannel.cs Updated ExpireFailedSends task creation to use TaskScheduler.Default
src/SIPSorcery/core/SIP/Channels/SIPTCPChannel.cs Updated AcceptConnections and PruneConnections task creation to use TaskScheduler.Default
src/SIPSorcery/core/SIP/Channels/SIPClientWebSocketChannel.cs Updated MonitorReceiveTasks task creation to use TaskScheduler.Default

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sipsorcery sipsorcery merged commit 316fb0e into master Feb 26, 2026
8 of 9 checks passed
@sipsorcery sipsorcery deleted the task-longrunning-defaultscheduler branch February 26, 2026 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding SIP channel within an async function behaves differently.

2 participants