diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-07-20 12:46:05 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-07-20 12:46:05 +0200 |
commit | 5c0367fd637606043db41f21444d584c93bee9f0 (patch) | |
tree | 862d3cdce5daaf7a3758f2433297a3a4c5df45ea /synchronizer | |
parent | 440322eb73a16e2afbe118e457cc0a69aea41e3f (diff) | |
download | sink-5c0367fd637606043db41f21444d584c93bee9f0.tar.gz sink-5c0367fd637606043db41f21444d584c93bee9f0.zip |
Immediately start reading if there is data available
Diffstat (limited to 'synchronizer')
-rw-r--r-- | synchronizer/listener.cpp | 9 | ||||
-rw-r--r-- | synchronizer/listener.h | 3 |
2 files changed, 10 insertions, 2 deletions
diff --git a/synchronizer/listener.cpp b/synchronizer/listener.cpp index 36fa6ea..d9ee46d 100644 --- a/synchronizer/listener.cpp +++ b/synchronizer/listener.cpp | |||
@@ -124,6 +124,9 @@ void Listener::acceptConnection() | |||
124 | this, &Listener::clientDropped); | 124 | this, &Listener::clientDropped); |
125 | m_checkConnectionsTimer->stop(); | 125 | m_checkConnectionsTimer->stop(); |
126 | 126 | ||
127 | if (socket->bytesAvailable()) { | ||
128 | readFromSocket(socket); | ||
129 | } | ||
127 | } | 130 | } |
128 | 131 | ||
129 | void Listener::clientDropped() | 132 | void Listener::clientDropped() |
@@ -156,13 +159,17 @@ void Listener::checkConnections() | |||
156 | m_checkConnectionsTimer->start(); | 159 | m_checkConnectionsTimer->start(); |
157 | } | 160 | } |
158 | 161 | ||
159 | void Listener::readFromSocket() | 162 | void Listener::onDataAvailable() |
160 | { | 163 | { |
161 | QLocalSocket *socket = qobject_cast<QLocalSocket *>(sender()); | 164 | QLocalSocket *socket = qobject_cast<QLocalSocket *>(sender()); |
162 | if (!socket) { | 165 | if (!socket) { |
163 | return; | 166 | return; |
164 | } | 167 | } |
168 | readFromSocket(socket); | ||
169 | } | ||
165 | 170 | ||
171 | void Listener::readFromSocket(QLocalSocket *socket) | ||
172 | { | ||
166 | Trace() << "Reading from socket..."; | 173 | Trace() << "Reading from socket..."; |
167 | for (Client &client: m_connections) { | 174 | for (Client &client: m_connections) { |
168 | if (client.socket == socket) { | 175 | if (client.socket == socket) { |
diff --git a/synchronizer/listener.h b/synchronizer/listener.h index 2577673..e03c310 100644 --- a/synchronizer/listener.h +++ b/synchronizer/listener.h | |||
@@ -73,7 +73,7 @@ private Q_SLOTS: | |||
73 | void acceptConnection(); | 73 | void acceptConnection(); |
74 | void clientDropped(); | 74 | void clientDropped(); |
75 | void checkConnections(); | 75 | void checkConnections(); |
76 | void readFromSocket(); | 76 | void onDataAvailable(); |
77 | void processClientBuffers(); | 77 | void processClientBuffers(); |
78 | void refreshRevision(); | 78 | void refreshRevision(); |
79 | void quit(); | 79 | void quit(); |
@@ -85,6 +85,7 @@ private: | |||
85 | void sendCommandCompleted(QLocalSocket *socket, uint messageId); | 85 | void sendCommandCompleted(QLocalSocket *socket, uint messageId); |
86 | void updateClientsWithRevision(); | 86 | void updateClientsWithRevision(); |
87 | void loadResource(); | 87 | void loadResource(); |
88 | void readFromSocket(QLocalSocket *socket); | ||
88 | 89 | ||
89 | QLocalServer *m_server; | 90 | QLocalServer *m_server; |
90 | QVector<Client> m_connections; | 91 | QVector<Client> m_connections; |