Difference between CFRunLoopRemoveSource and CFRunLoopSourceInvalidate

I was debugging a crash in my HID driver code on a Mac and found that a crash occurred in CFRunLoop. In the driver code, I open the USB handles for devices that match the VID and PID that match my HID device, and then set up an interrupt call for it using the setInterruptReportHandlerCallback function, and then add it to CFRunLoop by calling CFRunLoopAddSource. In my call to the closure methods, I freed them using CFRunLoopRemoveSource and then CFRelease to CFRunLoopSourceRef.

The problem occurs when I try to open descriptors, wait a while (5 ms), and then close the handles in a loop.

When I searched for the problem, I came across a link where they had a similar problem with my http://lists.apple.com/archives/usb/.../msg00099.html , where they used CFRunLoopSourceInvalidate instead of calling Remove Source. When I changed it to Invalidate source in my call with private addresses, it fixed my failure. I wanted to know what is the difference between a failure and why did this call record my failure?

Thanks jbsp72

+3
source share
1 answer

First, let me thank you. I type CFRunLoopRemoveSourcein google, I find your message that it is the problem that I tried to solve, and your solution, by calling CFRunLoopSourceInvalidate, also solves my problem.

CFRunLoopRemoveSource a CFRunLoopSourceInvalidate:

  • CFRunLoopRemoveSource , .
  • CFRunLoopSourceInvalidate , .

, , , , , , , , , , . , __spin_lock .

, ? . , , . , . , , , .

, , , , , , .

+3

Source: https://habr.com/ru/post/1705783/


All Articles