Skip to content

[SR-3199] Cancel handler is never called on DispatchSource after invoking .cancel() #710

Open
@swift-ci

Description

@swift-ci
Previous ID SR-3199
Radar None
Original Reporter tylercloutier (JIRA User)
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Foundation, libdispatch
Labels Bug
Assignee mww (JIRA)
Priority Medium

md5: 1641e42bfc66b37d5426aff6370cf49c

Issue Description:

It appears that the cancel handler is never invoked after calling cancel on a DispatchSource in Swift 3 on macOS.

This issue can be replicated by following steps with Swift 3.0.1.

  1. Clone https://github.com/SwiftOnEdge/Edge.git
  2. Check out the commit 1bc2552c3f7cb0d33080d65b1290008ac5342cdf
  3. Comment out line 125 of /Sources/TCP/Server.swift and insert print statement there.
  4. Insert a print statement in the cancelHandler on line 47 of the same file
  5. Run the test RouterTests.testMiddleware

You should see that although the cancel in invoked, the test completes without ever invoking the cancel handler configured on line 47.

Shouldn't the listeningSource maintain a strong reference to the handler and submit it to the main queue (in this case) to be run when cancel is invoked or am I misunderstanding something about the contract of cancel?

Note: This is on macOS. I have not tested this for Linux.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions