summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@accenture.com>2011-03-25 18:07:15 (GMT)
committerShane Kearns <shane.kearns@accenture.com>2011-03-29 09:48:24 (GMT)
commitbcbce977fa7a0d61de5f17e6727eba5a823bc3bb (patch)
tree5e92572550bc5d75c8d9145bd4ba9e4231b88c86
parent41ffab6b5b2d9f5a578109a4ea6ca0c5df58a3eb (diff)
downloadQt-bcbce977fa7a0d61de5f17e6727eba5a823bc3bb.zip
Qt-bcbce977fa7a0d61de5f17e6727eba5a823bc3bb.tar.gz
Qt-bcbce977fa7a0d61de5f17e6727eba5a823bc3bb.tar.bz2
Performance: use select poll for timeout of 0ms
A timer of 0ms completes on the next kernel tick (up to 0.999ms) There is a poll GetOpt we can use instead that doesn't require using a timer to cancel the select ioctl. Reviewed-by: Markus Goetz
-rw-r--r--src/network/socket/qsymbiansocketengine.cpp67
1 files changed, 37 insertions, 30 deletions
diff --git a/src/network/socket/qsymbiansocketengine.cpp b/src/network/socket/qsymbiansocketengine.cpp
index 58e8d9f..af755a9 100644
--- a/src/network/socket/qsymbiansocketengine.cpp
+++ b/src/network/socket/qsymbiansocketengine.cpp
@@ -1105,39 +1105,46 @@ int QSymbianSocketEnginePrivate::nativeSelect(int timeout, bool checkRead, bool
selectFlags() |= KSockSelectRead;
if (checkWrite)
selectFlags() |= KSockSelectWrite;
- TRequestStatus selectStat;
- nativeSocket.Ioctl(KIOctlSelect, selectStat, &selectFlags, KSOLSocket);
-
- if (timeout < 0)
- User::WaitForRequest(selectStat); //negative means no timeout
- else {
- if (!selectTimer.Handle())
- qt_symbian_throwIfError(selectTimer.CreateLocal());
- TRequestStatus timerStat;
- selectTimer.HighRes(timerStat, timeout * 1000);
- User::WaitForRequest(timerStat, selectStat);
- if (selectStat == KRequestPending) {
- nativeSocket.CancelIoctl();
- //CancelIoctl completes the request (most likely with KErrCancel)
- //We need to wait for this to keep the thread semaphore balanced (or active scheduler will panic)
- User::WaitForRequest(selectStat);
- //restart asynchronous notifier (only one IOCTL allowed at a time)
- if (asyncSelect)
- asyncSelect->IssueRequest();
-#ifdef QNATIVESOCKETENGINE_DEBUG
- qDebug() << "QSymbianSocketEnginePrivate::nativeSelect: select timeout";
-#endif
- return 0; //timeout
- } else {
- selectTimer.Cancel();
- User::WaitForRequest(timerStat);
+ TInt err;
+ if (timeout == 0) {
+ //if timeout is zero, poll
+ err = nativeSocket.GetOpt(KSOSelectPoll, KSOLSocket, selectFlags);
+ } else {
+ TRequestStatus selectStat;
+ nativeSocket.Ioctl(KIOctlSelect, selectStat, &selectFlags, KSOLSocket);
+
+ if (timeout < 0)
+ User::WaitForRequest(selectStat); //negative means no timeout
+ else {
+ if (!selectTimer.Handle())
+ qt_symbian_throwIfError(selectTimer.CreateLocal());
+ TRequestStatus timerStat;
+ selectTimer.HighRes(timerStat, timeout * 1000);
+ User::WaitForRequest(timerStat, selectStat);
+ if (selectStat == KRequestPending) {
+ nativeSocket.CancelIoctl();
+ //CancelIoctl completes the request (most likely with KErrCancel)
+ //We need to wait for this to keep the thread semaphore balanced (or active scheduler will panic)
+ User::WaitForRequest(selectStat);
+ //restart asynchronous notifier (only one IOCTL allowed at a time)
+ if (asyncSelect)
+ asyncSelect->IssueRequest();
+ #ifdef QNATIVESOCKETENGINE_DEBUG
+ qDebug() << "QSymbianSocketEnginePrivate::nativeSelect: select timeout";
+ #endif
+ return 0; //timeout
+ } else {
+ selectTimer.Cancel();
+ User::WaitForRequest(timerStat);
+ }
}
+
+ #ifdef QNATIVESOCKETENGINE_DEBUG
+ qDebug() << "QSymbianSocketEnginePrivate::nativeSelect: select status" << selectStat.Int() << (int)selectFlags();
+ #endif
+ err = selectStat.Int();
}
-#ifdef QNATIVESOCKETENGINE_DEBUG
- qDebug() << "QSymbianSocketEnginePrivate::nativeSelect: select status" << selectStat.Int() << (int)selectFlags();
-#endif
- TInt err = selectStat.Int();
if (!err && (selectFlags() & KSockSelectExcept)) {
nativeSocket.GetOpt(KSOSelectLastError, KSOLSocket, err);
#ifdef QNATIVESOCKETENGINE_DEBUG