Changeset View
Changeset View
Standalone View
Standalone View
src/server/connection.cpp
Show All 22 Lines | |||||
23 | 23 | | |||
24 | #include <QSettings> | 24 | #include <QSettings> | ||
25 | #include <QDataStream> | 25 | #include <QDataStream> | ||
26 | #include <QEventLoop> | 26 | #include <QEventLoop> | ||
27 | #include <QGlobalStatic> | 27 | #include <QGlobalStatic> | ||
28 | #include <QThreadStorage> | 28 | #include <QThreadStorage> | ||
29 | 29 | | |||
30 | #include "storage/datastore.h" | 30 | #include "storage/datastore.h" | ||
31 | #include "storage/dbdeadlockcatcher.h" | ||||
31 | #include "handler.h" | 32 | #include "handler.h" | ||
32 | #include "notificationmanager.h" | 33 | #include "notificationmanager.h" | ||
33 | 34 | | |||
34 | #include "tracer.h" | 35 | #include "tracer.h" | ||
35 | #include "collectionreferencemanager.h" | 36 | #include "collectionreferencemanager.h" | ||
36 | 37 | | |||
37 | #include <cassert> | 38 | #include <cassert> | ||
38 | 39 | | |||
39 | #ifndef Q_OS_WIN | 40 | #ifndef Q_OS_WIN | ||
40 | #include <cxxabi.h> | 41 | #include <cxxabi.h> | ||
41 | #endif | 42 | #endif | ||
42 | 43 | | |||
43 | #include <QElapsedTimer> | 44 | #include <QElapsedTimer> | ||
44 | 45 | | |||
45 | #include <private/protocol_p.h> | 46 | #include <private/protocol_p.h> | ||
46 | #include <private/datastream_p_p.h> | 47 | #include <private/datastream_p_p.h> | ||
47 | #include <private/standarddirs_p.h> | 48 | #include <private/standarddirs_p.h> | ||
48 | 49 | | |||
49 | using namespace Akonadi; | 50 | using namespace Akonadi; | ||
dvratil: Use "" instead of <>, it is a local include (while `private` is another library) | |||||
50 | using namespace Akonadi::Server; | 51 | using namespace Akonadi::Server; | ||
51 | 52 | | |||
52 | #define IDLE_TIMER_TIMEOUT 180000 // 3 min | 53 | #define IDLE_TIMER_TIMEOUT 180000 // 3 min | ||
53 | 54 | | |||
54 | static QString connectionIdentifier(Connection *c) { | 55 | static QString connectionIdentifier(Connection *c) { | ||
55 | QString id; | 56 | QString id; | ||
56 | id.sprintf("%p", static_cast<void *>(c)); | 57 | id.sprintf("%p", static_cast<void *>(c)); | ||
57 | return id; | 58 | return id; | ||
▲ Show 20 Lines • Show All 131 Lines • ▼ Show 20 Line(s) | 188 | { | |||
189 | // from slotNewDate() | 190 | // from slotNewDate() | ||
190 | if (m_currentHandler) { | 191 | if (m_currentHandler) { | ||
191 | return; | 192 | return; | ||
192 | } | 193 | } | ||
193 | 194 | | |||
194 | Q_EMIT disconnected(); | 195 | Q_EMIT disconnected(); | ||
195 | } | 196 | } | ||
196 | 197 | | |||
198 | void Connection::parseStream(const Protocol::CommandPtr &cmd) | ||||
199 | { | ||||
200 | if (!m_currentHandler->parseStream()) { | ||||
201 | try { | ||||
202 | m_currentHandler->failureResponse("Error while handling a command"); | ||||
203 | } catch (...) { | ||||
204 | m_connectionClosing = true; | ||||
205 | } | ||||
206 | qCWarning(AKONADISERVER_LOG) << "Error while handling command" << cmd->type() | ||||
207 | << "on connection" << m_identifier; | ||||
208 | } | ||||
209 | } | ||||
210 | | ||||
197 | void Connection::handleIncomingData() | 211 | void Connection::handleIncomingData() | ||
198 | { | 212 | { | ||
199 | Q_FOREVER { | 213 | Q_FOREVER { | ||
200 | 214 | | |||
201 | if (m_connectionClosing || !m_socket || m_socket->state() != QLocalSocket::ConnectedState) { | 215 | if (m_connectionClosing || !m_socket || m_socket->state() != QLocalSocket::ConnectedState) { | ||
202 | break; | 216 | break; | ||
203 | } | 217 | } | ||
204 | 218 | | |||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Line(s) | 242 | while (m_socket->bytesAvailable() >= int(sizeof(qint64))) { | |||
269 | if (m_reportTime) { | 283 | if (m_reportTime) { | ||
270 | startTime(); | 284 | startTime(); | ||
271 | } | 285 | } | ||
272 | 286 | | |||
273 | m_currentHandler->setConnection(this); | 287 | m_currentHandler->setConnection(this); | ||
274 | m_currentHandler->setTag(tag); | 288 | m_currentHandler->setTag(tag); | ||
275 | m_currentHandler->setCommand(cmd); | 289 | m_currentHandler->setCommand(cmd); | ||
276 | try { | 290 | try { | ||
277 | if (!m_currentHandler->parseStream()) { | 291 | DbDeadlockCatcher catcher([this, cmd]() { parseStream(cmd); }); | ||
278 | try { | | |||
279 | m_currentHandler->failureResponse("Error while handling a command"); | | |||
280 | } catch (...) { | | |||
281 | m_connectionClosing = true; | | |||
282 | } | | |||
283 | qCWarning(AKONADISERVER_LOG) << "Error while handling command" << cmd->type() | | |||
284 | << "on connection" << m_identifier; | | |||
285 | } | | |||
286 | } catch (const Akonadi::Server::HandlerException &e) { | 292 | } catch (const Akonadi::Server::HandlerException &e) { | ||
287 | if (m_currentHandler) { | 293 | if (m_currentHandler) { | ||
288 | try { | 294 | try { | ||
289 | m_currentHandler->failureResponse(e.what()); | 295 | m_currentHandler->failureResponse(e.what()); | ||
290 | } catch (...) { | 296 | } catch (...) { | ||
291 | m_connectionClosing = true; | 297 | m_connectionClosing = true; | ||
292 | } | 298 | } | ||
293 | qCWarning(AKONADISERVER_LOG) << "Handler exception when handling command" << cmd->type() | 299 | qCWarning(AKONADISERVER_LOG) << "Handler exception when handling command" << cmd->type() | ||
▲ Show 20 Lines • Show All 225 Lines • Show Last 20 Lines |
Use "" instead of <>, it is a local include (while private is another library)