diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-01-25 19:26:20 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-01-25 19:26:20 +0100 |
commit | 3e58a6052200a4bcf1fbc1af0683650dc4b86145 (patch) | |
tree | a58fec6fb088e92f6c38deb390bcc2a4a15cdddd /synchronizer | |
parent | 35ae961b37dfc860ab52edd69093d71c5b2a732f (diff) | |
download | sink-3e58a6052200a4bcf1fbc1af0683650dc4b86145.tar.gz sink-3e58a6052200a4bcf1fbc1af0683650dc4b86145.zip |
Avoid shutting down the synchronizer all the time.
Diffstat (limited to 'synchronizer')
-rw-r--r-- | synchronizer/listener.cpp | 23 | ||||
-rw-r--r-- | synchronizer/listener.h | 1 |
2 files changed, 16 insertions, 8 deletions
diff --git a/synchronizer/listener.cpp b/synchronizer/listener.cpp index 1294c76..f52e48c 100644 --- a/synchronizer/listener.cpp +++ b/synchronizer/listener.cpp | |||
@@ -60,13 +60,23 @@ Listener::Listener(const QString &resourceName, QObject *parent) | |||
60 | log(QString("Listening on %1").arg(m_server->serverName())); | 60 | log(QString("Listening on %1").arg(m_server->serverName())); |
61 | } | 61 | } |
62 | 62 | ||
63 | m_checkConnectionsTimer = new QTimer; | ||
64 | m_checkConnectionsTimer->setSingleShot(true); | ||
65 | m_checkConnectionsTimer->setInterval(1000); | ||
66 | connect(m_checkConnectionsTimer, &QTimer::timeout, [this]() { | ||
67 | if (m_connections.isEmpty()) { | ||
68 | log(QString("No connections, shutting down.")); | ||
69 | m_server->close(); | ||
70 | emit noClients(); | ||
71 | } | ||
72 | }); | ||
73 | |||
63 | //TODO: experiment with different timeouts | 74 | //TODO: experiment with different timeouts |
64 | // or even just drop down to invoking the method queued? | 75 | // or even just drop down to invoking the method queued? => invoke queued unless we need throttling |
65 | m_clientBufferProcessesTimer->setInterval(10); | 76 | m_clientBufferProcessesTimer->setInterval(0); |
66 | m_clientBufferProcessesTimer->setSingleShot(true); | 77 | m_clientBufferProcessesTimer->setSingleShot(true); |
67 | connect(m_clientBufferProcessesTimer, &QTimer::timeout, | 78 | connect(m_clientBufferProcessesTimer, &QTimer::timeout, |
68 | this, &Listener::processClientBuffers); | 79 | this, &Listener::processClientBuffers); |
69 | QTimer::singleShot(2000, this, SLOT(checkConnections())); | ||
70 | } | 80 | } |
71 | 81 | ||
72 | Listener::~Listener() | 82 | Listener::~Listener() |
@@ -102,6 +112,7 @@ void Listener::acceptConnection() | |||
102 | m_connections << client; | 112 | m_connections << client; |
103 | connect(socket, &QLocalSocket::disconnected, | 113 | connect(socket, &QLocalSocket::disconnected, |
104 | this, &Listener::clientDropped); | 114 | this, &Listener::clientDropped); |
115 | m_checkConnectionsTimer->stop(); | ||
105 | 116 | ||
106 | } | 117 | } |
107 | 118 | ||
@@ -128,11 +139,7 @@ void Listener::clientDropped() | |||
128 | 139 | ||
129 | void Listener::checkConnections() | 140 | void Listener::checkConnections() |
130 | { | 141 | { |
131 | if (m_connections.isEmpty()) { | 142 | m_checkConnectionsTimer->start(); |
132 | log(QString("No connections, shutting down.")); | ||
133 | m_server->close(); | ||
134 | emit noClients(); | ||
135 | } | ||
136 | } | 143 | } |
137 | 144 | ||
138 | void Listener::readFromSocket() | 145 | void Listener::readFromSocket() |
diff --git a/synchronizer/listener.h b/synchronizer/listener.h index 4c35191..f1241c7 100644 --- a/synchronizer/listener.h +++ b/synchronizer/listener.h | |||
@@ -91,5 +91,6 @@ private: | |||
91 | Akonadi2::Resource *m_resource; | 91 | Akonadi2::Resource *m_resource; |
92 | Akonadi2::Pipeline *m_pipeline; | 92 | Akonadi2::Pipeline *m_pipeline; |
93 | QTimer *m_clientBufferProcessesTimer; | 93 | QTimer *m_clientBufferProcessesTimer; |
94 | QTimer *m_checkConnectionsTimer; | ||
94 | int m_messageId; | 95 | int m_messageId; |
95 | }; | 96 | }; |