mirror of
https://github.com/debauchee/barrier.git
synced 2024-11-23 09:43:24 +03:00
Used different chunk size for SSL and non-SSL socket #4601
This commit is contained in:
parent
36ddc4f1c1
commit
ff9ad5554a
@ -17,6 +17,7 @@
|
||||
|
||||
#include "synergy/ArgParser.h"
|
||||
|
||||
#include "synergy/StreamChunker.h"
|
||||
#include "synergy/App.h"
|
||||
#include "synergy/ServerArgs.h"
|
||||
#include "synergy/ClientArgs.h"
|
||||
@ -288,6 +289,7 @@ ArgParser::parseGenericArgs(int argc, const char* const* argv, int& i)
|
||||
}
|
||||
else if (isArg(i, argc, argv, NULL, "--enable-crypto")) {
|
||||
argsBase().m_enableCrypto = true;
|
||||
StreamChunker::updateChunkSize(true);
|
||||
}
|
||||
else if (isArg(i, argc, argv, NULL, "--profile-dir", 1)) {
|
||||
argsBase().m_profileDirectory = argv[++i];
|
||||
|
@ -35,7 +35,10 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
const size_t StreamChunker::m_chunkSize = 512 * 1024; // 512kb
|
||||
#define SOCKET_CHUNK_SIZE 512 * 1024; // 512kb
|
||||
#define SECURE_SOCKET_CHUNK_SIZE 2 * 1024; // 2kb
|
||||
|
||||
size_t StreamChunker::s_chunkSize = SOCKET_CHUNK_SIZE;
|
||||
|
||||
void
|
||||
StreamChunker::sendFile(
|
||||
@ -61,7 +64,7 @@ StreamChunker::sendFile(
|
||||
|
||||
// send chunk messages with a fixed chunk size
|
||||
size_t sentLength = 0;
|
||||
size_t chunkSize = m_chunkSize;
|
||||
size_t chunkSize = s_chunkSize;
|
||||
Stopwatch stopwatch;
|
||||
stopwatch.start();
|
||||
file.seekg (0, std::ios::beg);
|
||||
@ -115,9 +118,8 @@ StreamChunker::sendClipboard(
|
||||
events->addEvent(Event(events->forClipboard().clipboardSending(), eventTarget, sizeMessage));
|
||||
|
||||
// send clipboard chunk with a fixed size
|
||||
// TODO: 4096 fails and this shouldn't a magic number
|
||||
size_t sentLength = 0;
|
||||
size_t chunkSize = 2048;
|
||||
size_t chunkSize = s_chunkSize;
|
||||
Stopwatch stopwatch;
|
||||
stopwatch.start();
|
||||
while (true) {
|
||||
@ -147,3 +149,14 @@ StreamChunker::sendClipboard(
|
||||
|
||||
events->addEvent(Event(events->forClipboard().clipboardSending(), eventTarget, end));
|
||||
}
|
||||
|
||||
void
|
||||
StreamChunker::updateChunkSize(bool useSecureSocket)
|
||||
{
|
||||
if (useSecureSocket) {
|
||||
s_chunkSize = SECURE_SOCKET_CHUNK_SIZE;
|
||||
}
|
||||
else {
|
||||
s_chunkSize = SOCKET_CHUNK_SIZE;
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,8 @@ public:
|
||||
UInt32 sequence,
|
||||
IEventQueue* events,
|
||||
void* eventTarget);
|
||||
static void updateChunkSize(bool useSecureSocket);
|
||||
|
||||
private:
|
||||
static const size_t m_chunkSize;
|
||||
static size_t s_chunkSize;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user