diff options
-rw-r--r-- | src/murmur/UnixMurmur.cpp | 62 | ||||
-rw-r--r-- | src/murmur/UnixMurmur.h | 12 | ||||
-rw-r--r-- | src/murmur/main.cpp | 22 |
3 files changed, 76 insertions, 20 deletions
diff --git a/src/murmur/UnixMurmur.cpp b/src/murmur/UnixMurmur.cpp index b4857e384..ec4c32a7a 100644 --- a/src/murmur/UnixMurmur.cpp +++ b/src/murmur/UnixMurmur.cpp @@ -30,9 +30,71 @@ #include <signal.h> +#include "murmur_pch.h" #include "UnixMurmur.h" #include "Meta.h" +QMutex *LimitTest::qm; +QWaitCondition *LimitTest::qw; + +LimitTest::LimitTest() : QThread() { +} + +void LimitTest::run() { + qm->lock(); + qw->wait(qm); + qm->unlock(); +} + +void LimitTest::testLimits(QCoreApplication &a) { + QAbstractEventDispatcher *ed = QAbstractEventDispatcher::instance(); + if (QLatin1String(ed->metaObject()->className()) != QLatin1String("QEventDispatcherGlib")) + qWarning("Not running with glib. While you may be able to open more descriptors, sockets above %d will not work", FD_SETSIZE); + qWarning("Running descriptor test."); + int count; + QList<QFile *> ql; + for (count=0;count < 524288; ++count) { + QFile *qf = new QFile(a.applicationFilePath()); + if (qf->open(QIODevice::ReadOnly)) + ql << qf; + else + break; + if ((count & 511) == 0) + qWarning("%d descriptors...", count); + } + foreach(QFile *qf, ql) + delete qf; + ql.clear(); + qCritical("Managed to open %d descriptors", count); + + qm = new QMutex(); + qw = new QWaitCondition(); + + int fdcount = count / 2; + + QList<QThread *> qtl; + for (count=0;count < fdcount; ++count) { + QThread *t = new LimitTest(); + qtl << t; + t->start(); + if (! t->isRunning()) + break; + if ((count & 511) == 0) + qWarning("%d threads...", count); + } + sleep(1); + qm->lock(); + qw->wakeAll(); + qm->unlock(); + foreach(QThread *qt, qtl) { + if (! qt->wait(1000)) { + qWarning("Thread failed to terminate..."); + qt->terminate(); + } + } + qFatal("Managed to spawn %d threads", count); +} + extern QFile *qfLog; int UnixMurmur::iHupFd[2]; diff --git a/src/murmur/UnixMurmur.h b/src/murmur/UnixMurmur.h index cb8d10e36..714aa7731 100644 --- a/src/murmur/UnixMurmur.h +++ b/src/murmur/UnixMurmur.h @@ -33,6 +33,18 @@ #include "murmur_pch.h"
+class LimitTest : public QThread {
+ Q_OBJECT
+ Q_DISABLE_COPY(LimitTest)
+ protected:
+ static QMutex *qm;
+ static QWaitCondition *qw;
+ LimitTest();
+ public:
+ void run();
+ static void testLimits(QCoreApplication &);
+};
+
class UnixMurmur : public QObject {
Q_OBJECT
Q_DISABLE_COPY(UnixMurmur)
diff --git a/src/murmur/main.cpp b/src/murmur/main.cpp index 14b13f373..af1544001 100644 --- a/src/murmur/main.cpp +++ b/src/murmur/main.cpp @@ -247,26 +247,8 @@ int main(int argc, char **argv) { "If no inifile is provided, murmur will search for one in \n" "default locations.", argv[0]); #ifdef Q_OS_UNIX - } else if (arg == "-descriptors") { - QAbstractEventDispatcher *ed = QAbstractEventDispatcher::instance(); - if (QLatin1String(ed->metaObject()->className()) != QLatin1String("QEventDispatcherGlib")) - qWarning("Not running with glib. While you may be able to open more descriptors, sockets above %d will not work", FD_SETSIZE); - qWarning("Running descriptor test."); - int count; - QList<QFile *> ql; - for (count=0;count < 524288; ++count) { - QFile *qf = new QFile(a.applicationFilePath()); - if (qf->open(QIODevice::ReadOnly)) - ql << qf; - else - break; - if ((count & 511) == 0) - qWarning("%d descriptors...", count); - } - foreach(QFile *qf, ql) - delete qf; - ql.clear(); - qFatal("Managed to open %d descriptors", count); + } else if (arg == "-limits") { + LimitTest::testLimits(a); #endif } else { detach = false; |