Priority: P3: Somewhat important
Affects Version/s: 5.15.2
Component/s: Core: Event loop
Commits:d492245d9f98e410e1748f28a598945244dbafa8 (qt/qtbase/dev) 72c609203b48a684afe51878bd7bd487fe96a103 (qt/qtbase/6.0) 63bdb5dd04478143dda23e273400fc56a30842ad (qt/tqtc-qtbase/5.15)
QCFSocketNotifier implements socket notifications when Cocoa platform plugin is used (Qt GUI applications). However it only registers read and write but not connect callbacks while creating underlying CFSocket object (see codes below taken from QCFSocketNotifier::registerSocketNotifier() function).
Any TCP client socket used in Qt GUI application under macOS will not receive connection completion or failure notifications. It is fine if connection succeeds as write notification will be triggered. However if connection fails, it will not trigger any notification. We will have to wait for the connection timer expiry in QAbstractSocket, which is 30 seconds by default. And as QAbstractSocket try the same address twice, it will take 60 seconds before QAbstractSocket::disconnected to be triggered. Before that no error signals are triggered at all - it is supposed to trigger disconnected immediately when socket connection fails.
The fix would be adding kCFSocketConnectCallback to callbackTypes in QCFSocketNotifier::registerSocketNotifier() and handles it in qt_mac_socket_callback() (just need to trigger the notifications similar to implementations for other platforms).
|For Gerrit Dashboard: QTBUG-91619|
|358070,1||macOS: Notify socket notifier on connection error||6.1||qt/qtbase||Status: NEW||+2||0|
|338073,6||macOS: Notify socket notifier on connection error||dev||qt/qtbase||Status: MERGED||-1||0|
|358071,2||macOS: Notify socket notifier on connection error||6.0||qt/qtbase||Status: MERGED||+2||0|
|358072,2||macOS: Notify socket notifier on connection error||tqtc/lts-5.15||qt/tqtc-qtbase||Status: MERGED||+2||0|