Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorvald Natvig <slicer@users.sourceforge.net>2009-02-16 17:25:12 +0300
committerThorvald Natvig <slicer@users.sourceforge.net>2009-02-16 17:25:12 +0300
commit7148a0b5c907d7f8b0512b594b9d84c4ff089ee2 (patch)
treecaa0b5b62a6992588338c0e553807b9f2a23f07c /src/murmur/UnixMurmur.cpp
parent39519d2a53eec998bbb62fb8bfa1803acb2da613 (diff)
Add a thread count test
git-svn-id: https://mumble.svn.sourceforge.net/svnroot/mumble/trunk@1541 05730e5d-ab1b-0410-a4ac-84af385074fa
Diffstat (limited to 'src/murmur/UnixMurmur.cpp')
-rw-r--r--src/murmur/UnixMurmur.cpp62
1 files changed, 62 insertions, 0 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];