path: root/src/platformsupport/cfsocketnotifier/qcfsocketnotifier_p.h
diff options
authorAlex Trotsenko <>2015-10-07 16:49:47 +0300
committerJani Heikkinen <>2015-10-09 13:00:58 +0000
commit6542161d5c698d461a11f0e5ca6cc2a00d33a824 (patch)
tree8c376507c253278df313dc98a760cb696597a3d6 /src/platformsupport/cfsocketnotifier/qcfsocketnotifier_p.h
parentda104e7db04a5aeafb99a7b0ef3ab3cdd08da272 (diff)
Fix spurious socket notifications on OS X and iOSv5.5.1
Core Foundation Framework forwards notifications about socket activity through a callback function which called from the run loop. The default behavior of Core Foundation is to automatically re-enable the read callback after each notification, and we explicitly enabled the same behavior for the write callback. With this behavior, if the client did multiple recv() calls in response to the first notification in a series of read notifications, the client would still get the QSocketNotifier notifications for the data that was already read. To get rid of these extra notifications, we disable automatically re-enabling the callbacks, and then manually enable them on each run loop pass. Task-number: QTBUG-48556 Change-Id: I0b060222b787f45600be0cb7da85d04aef415e57 Reviewed-by: Tor Arne Vestbø <>
Diffstat (limited to 'src/platformsupport/cfsocketnotifier/qcfsocketnotifier_p.h')
1 files changed, 13 insertions, 1 deletions
diff --git a/src/platformsupport/cfsocketnotifier/qcfsocketnotifier_p.h b/src/platformsupport/cfsocketnotifier/qcfsocketnotifier_p.h
index af8122f753..9bccc1bf98 100644
--- a/src/platformsupport/cfsocketnotifier/qcfsocketnotifier_p.h
+++ b/src/platformsupport/cfsocketnotifier/qcfsocketnotifier_p.h
@@ -53,11 +53,14 @@
struct MacSocketInfo {
- MacSocketInfo() : socket(0), runloop(0), readNotifier(0), writeNotifier(0) {}
+ MacSocketInfo() : socket(0), runloop(0), readNotifier(0), writeNotifier(0),
+ readEnabled(false), writeEnabled(false) {}
CFSocketRef socket;
CFRunLoopSourceRef runloop;
QObject *readNotifier;
QObject *writeNotifier;
+ bool readEnabled;
+ bool writeEnabled;
typedef QHash<int, MacSocketInfo *> MacSocketHash;
@@ -83,9 +86,18 @@ public:
void unregisterSocketNotifier(QSocketNotifier *notifier);
void removeSocketNotifiers();
+ void destroyRunLoopObserver();
+ static void unregisterSocketInfo(MacSocketInfo *socketInfo);
+ static void enableSocketNotifiers(CFRunLoopObserverRef ref, CFRunLoopActivity activity, void *info);
MacSocketHash macSockets;
QAbstractEventDispatcher *eventDispatcher;
MaybeCancelWaitForMoreEventsFn maybeCancelWaitForMoreEvents;
+ CFRunLoopObserverRef enableNotifiersObserver;
+ friend void qt_mac_socket_callback(CFSocketRef, CFSocketCallBackType, CFDataRef, const void *, void *);