Changeset View
Changeset View
Standalone View
Standalone View
src/server/connection.cpp
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | |||||
47 | #define IDLE_TIMER_TIMEOUT 180000 // 3 min | 47 | #define IDLE_TIMER_TIMEOUT 180000 // 3 min | ||
48 | 48 | | |||
49 | static QString connectionIdentifier(Connection *c) { | 49 | static QString connectionIdentifier(Connection *c) { | ||
50 | QString id; | 50 | QString id; | ||
51 | id.sprintf("%p", static_cast<void *>(c)); | 51 | id.sprintf("%p", static_cast<void *>(c)); | ||
52 | return id; | 52 | return id; | ||
53 | } | 53 | } | ||
54 | 54 | | |||
55 | #ifdef Q_OS_FREEBSD | ||||
56 | #include <sys/types.h> | ||||
57 | #include <sys/socket.h> | ||||
58 | | ||||
59 | void adjustSocketBuffer( int real_fd ) | ||||
60 | { | ||||
61 | int so_data = 0; | ||||
62 | socklen_t so_len = sizeof(so_data); | ||||
63 | int r = getsockopt(real_fd, SOL_SOCKET, SO_SNDBUF, &so_data, &so_len); | ||||
64 | qDebug() << "SNDBUF" << r << so_data; | ||||
65 | if (!r && (so_data < 65536)) | ||||
66 | { | ||||
67 | so_data = 65536; | ||||
68 | r = setsockopt(real_fd, SOL_SOCKET, SO_SNDBUF, &so_data, sizeof(so_data)); | ||||
69 | if (r) | ||||
70 | qCDebug(AKONADISERVER_LOG) << "Could not enlarge send buffer" << r; | ||||
71 | } | ||||
72 | r = getsockopt(real_fd, SOL_SOCKET, SO_SNDBUF, &so_data, &so_len); | ||||
73 | qDebug() << "SNDBUF" << r << so_data; | ||||
74 | | ||||
75 | r = getsockopt(real_fd, SOL_SOCKET, SO_RCVBUF, &so_data, &so_len); | ||||
76 | qDebug() << "RCVBUF" << r << so_data; | ||||
77 | if (!r && (so_data < 65536)) | ||||
78 | { | ||||
79 | so_data = 65536; | ||||
80 | r = setsockopt(real_fd, SOL_SOCKET, SO_RCVBUF, &so_data, sizeof(so_data)); | ||||
81 | if (r) | ||||
82 | qCDebug(AKONADISERVER_LOG) << "Could not enlarge recv buffer" << r; | ||||
83 | } | ||||
84 | r = getsockopt(real_fd, SOL_SOCKET, SO_RCVBUF, &so_data, &so_len); | ||||
85 | qDebug() << "RCVBUF" << r << so_data; | ||||
86 | } | ||||
87 | | ||||
88 | #endif | ||||
89 | | ||||
55 | Connection::Connection(QObject *parent) | 90 | Connection::Connection(QObject *parent) | ||
56 | : AkThread(connectionIdentifier(this), QThread::InheritPriority, parent) | 91 | : AkThread(connectionIdentifier(this), QThread::InheritPriority, parent) | ||
57 | , m_socketDescriptor(0) | 92 | , m_socketDescriptor(0) | ||
58 | , m_socket(nullptr) | 93 | , m_socket(nullptr) | ||
59 | , m_currentHandler(nullptr) | 94 | , m_currentHandler(nullptr) | ||
60 | , m_connectionState(NonAuthenticated) | 95 | , m_connectionState(NonAuthenticated) | ||
61 | , m_backend(nullptr) | 96 | , m_backend(nullptr) | ||
62 | , m_verifyCacheOnRetrieval(false) | 97 | , m_verifyCacheOnRetrieval(false) | ||
63 | , m_idleTimer(nullptr) | 98 | , m_idleTimer(nullptr) | ||
64 | , m_totalTime(0) | 99 | , m_totalTime(0) | ||
65 | , m_connectionClosing(false) | 100 | , m_connectionClosing(false) | ||
66 | , m_reportTime(false) | 101 | , m_reportTime(false) | ||
67 | { | 102 | { | ||
68 | } | 103 | } | ||
69 | 104 | | |||
70 | Connection::Connection(quintptr socketDescriptor, QObject *parent) | 105 | Connection::Connection(quintptr socketDescriptor, QObject *parent) | ||
71 | : Connection(parent) | 106 | : Connection(parent) | ||
72 | { | 107 | { | ||
108 | #ifdef Q_OS_FREEBSD | ||||
109 | int real_fd = static_cast<int>(socketDescriptor); | ||||
110 | adjustSocketBuffer( real_fd ); | ||||
111 | #endif | ||||
73 | m_socketDescriptor = socketDescriptor; | 112 | m_socketDescriptor = socketDescriptor; | ||
74 | m_identifier = connectionIdentifier(this); // same as objectName() | 113 | m_identifier = connectionIdentifier(this); // same as objectName() | ||
75 | 114 | | |||
76 | const QSettings settings(Akonadi::StandardDirs::serverConfigFile(), QSettings::IniFormat); | 115 | const QSettings settings(Akonadi::StandardDirs::serverConfigFile(), QSettings::IniFormat); | ||
77 | m_verifyCacheOnRetrieval = settings.value(QStringLiteral("Cache/VerifyOnRetrieval"), m_verifyCacheOnRetrieval).toBool(); | 116 | m_verifyCacheOnRetrieval = settings.value(QStringLiteral("Cache/VerifyOnRetrieval"), m_verifyCacheOnRetrieval).toBool(); | ||
78 | } | 117 | } | ||
79 | 118 | | |||
80 | void Connection::init() | 119 | void Connection::init() | ||
▲ Show 20 Lines • Show All 410 Lines • Show Last 20 Lines |