summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qcfsocketnotifier.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/kernel/qcfsocketnotifier.cpp')
-rw-r--r--src/corelib/kernel/qcfsocketnotifier.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/corelib/kernel/qcfsocketnotifier.cpp b/src/corelib/kernel/qcfsocketnotifier.cpp
index a079031e96..1fee2aa5fc 100644
--- a/src/corelib/kernel/qcfsocketnotifier.cpp
+++ b/src/corelib/kernel/qcfsocketnotifier.cpp
@@ -292,10 +292,19 @@ void QCFSocketNotifier::enableSocketNotifiers(CFRunLoopObserverRef ref, CFRunLoo
continue;
}
- if (!socketInfo->readNotifier)
+ // Apple docs say: "If a callback is automatically re-enabled,
+ // it is called every time the condition becomes true ... If a
+ // callback is not automatically re-enabled, then it gets called
+ // exactly once, and is not called again until you manually
+ // re-enable that callback by calling CFSocketEnableCallBacks()".
+ // So, we don't need to enable callbacks on registering.
+ socketInfo->readEnabled = (socketInfo->readNotifier != nullptr);
+ if (!socketInfo->readEnabled)
CFSocketDisableCallBacks(socketInfo->socket, kCFSocketReadCallBack);
- if (!socketInfo->writeNotifier)
+ socketInfo->writeEnabled = (socketInfo->writeNotifier != nullptr);
+ if (!socketInfo->writeEnabled)
CFSocketDisableCallBacks(socketInfo->socket, kCFSocketWriteCallBack);
+ continue;
}
if (socketInfo->readNotifier && !socketInfo->readEnabled) {