summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorMartin Petersson <martin.petersson@nokia.com>2012-07-11 12:31:29 +0200
committerQt by Nokia <qt-info@nokia.com>2012-08-01 18:12:34 +0200
commitb8453b6fe3552cdfe32c726f87bb30d897c679b0 (patch)
tree544227e592bda31eaf8ba266f33f7cadb6336a45 /src/corelib/kernel
parente178b49522465becf1b0c56bff1974e6037ba9ec (diff)
QtNetwork: Handle FD_CLOSE on Windows
We need to handle FD_CLOSE separately on Windows as this will be sent only once. When we get FD_CLOSE we need to check if there is more data available for reading. It there is this might indicate that there is another FD_READ that we need to handle after the FD_CLOSE. So in this case we will manually create another close event. Task-number: QTBUG-19409 Task-number: QTBUG-25386 Change-Id: Ie19906bc3f64fb6a85a508a5ab12caac5d70ccdb Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qcoreevent.h2
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp15
-rw-r--r--src/corelib/kernel/qsocketnotifier.cpp4
3 files changed, 15 insertions, 6 deletions
diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h
index 1af426e5d2e..f64e11c1797 100644
--- a/src/corelib/kernel/qcoreevent.h
+++ b/src/corelib/kernel/qcoreevent.h
@@ -275,6 +275,8 @@ public:
ThemeChange = 210,
+ SockClose = 211, // socket closed
+
// 512 reserved for Qt Jambi's MetaCall event
// 513 reserved for Qt Jambi's DeleteOnMainThread event
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp
index baacfa6a80e..cf182c9c292 100644
--- a/src/corelib/kernel/qeventdispatcher_win.cpp
+++ b/src/corelib/kernel/qeventdispatcher_win.cpp
@@ -377,7 +377,6 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA
int type = -1;
switch (WSAGETSELECTEVENT(lp)) {
case FD_READ:
- case FD_CLOSE:
case FD_ACCEPT:
type = 0;
break;
@@ -388,16 +387,24 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA
case FD_OOB:
type = 2;
break;
+ case FD_CLOSE:
+ type = 3;
+ break;
}
if (type >= 0) {
Q_ASSERT(d != 0);
- QSNDict *sn_vec[3] = { &d->sn_read, &d->sn_write, &d->sn_except };
+ QSNDict *sn_vec[4] = { &d->sn_read, &d->sn_write, &d->sn_except, &d->sn_read };
QSNDict *dict = sn_vec[type];
QSockNot *sn = dict ? dict->value(wp) : 0;
if (sn) {
- QEvent event(QEvent::SockAct);
- QCoreApplication::sendEvent(sn->obj, &event);
+ if (type < 3) {
+ QEvent event(QEvent::SockAct);
+ QCoreApplication::sendEvent(sn->obj, &event);
+ } else {
+ QEvent event(QEvent::SockClose);
+ QCoreApplication::sendEvent(sn->obj, &event);
+ }
}
}
return 0;
diff --git a/src/corelib/kernel/qsocketnotifier.cpp b/src/corelib/kernel/qsocketnotifier.cpp
index c108b967e20..98761098ee0 100644
--- a/src/corelib/kernel/qsocketnotifier.cpp
+++ b/src/corelib/kernel/qsocketnotifier.cpp
@@ -287,7 +287,7 @@ void QSocketNotifier::setEnabled(bool enable)
bool QSocketNotifier::event(QEvent *e)
{
Q_D(QSocketNotifier);
- // Emits the activated() signal when a QEvent::SockAct is
+ // Emits the activated() signal when a QEvent::SockAct or QEvent::SockClose is
// received.
if (e->type() == QEvent::ThreadChange) {
if (d->snenabled) {
@@ -297,7 +297,7 @@ bool QSocketNotifier::event(QEvent *e)
}
}
QObject::event(e); // will activate filters
- if (e->type() == QEvent::SockAct) {
+ if ((e->type() == QEvent::SockAct) || (e->type() == QEvent::SockClose)) {
emit activated(d->sockfd);
return true;
}