Used different chunk size for SSL and non-SSL socket #4601

This commit is contained in:
Jerry (Xinyu Hou) 2015-05-22 13:30:50 -07:00
parent 36ddc4f1c1
commit ff9ad5554a
3 changed files with 21 additions and 5 deletions

View File

@ -17,6 +17,7 @@
#include "synergy/ArgParser.h" #include "synergy/ArgParser.h"
#include "synergy/StreamChunker.h"
#include "synergy/App.h" #include "synergy/App.h"
#include "synergy/ServerArgs.h" #include "synergy/ServerArgs.h"
#include "synergy/ClientArgs.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")) { else if (isArg(i, argc, argv, NULL, "--enable-crypto")) {
argsBase().m_enableCrypto = true; argsBase().m_enableCrypto = true;
StreamChunker::updateChunkSize(true);
} }
else if (isArg(i, argc, argv, NULL, "--profile-dir", 1)) { else if (isArg(i, argc, argv, NULL, "--profile-dir", 1)) {
argsBase().m_profileDirectory = argv[++i]; argsBase().m_profileDirectory = argv[++i];

View File

@ -35,7 +35,10 @@
using namespace std; 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 void
StreamChunker::sendFile( StreamChunker::sendFile(
@ -61,7 +64,7 @@ StreamChunker::sendFile(
// send chunk messages with a fixed chunk size // send chunk messages with a fixed chunk size
size_t sentLength = 0; size_t sentLength = 0;
size_t chunkSize = m_chunkSize; size_t chunkSize = s_chunkSize;
Stopwatch stopwatch; Stopwatch stopwatch;
stopwatch.start(); stopwatch.start();
file.seekg (0, std::ios::beg); file.seekg (0, std::ios::beg);
@ -115,9 +118,8 @@ StreamChunker::sendClipboard(
events->addEvent(Event(events->forClipboard().clipboardSending(), eventTarget, sizeMessage)); events->addEvent(Event(events->forClipboard().clipboardSending(), eventTarget, sizeMessage));
// send clipboard chunk with a fixed size // send clipboard chunk with a fixed size
// TODO: 4096 fails and this shouldn't a magic number
size_t sentLength = 0; size_t sentLength = 0;
size_t chunkSize = 2048; size_t chunkSize = s_chunkSize;
Stopwatch stopwatch; Stopwatch stopwatch;
stopwatch.start(); stopwatch.start();
while (true) { while (true) {
@ -147,3 +149,14 @@ StreamChunker::sendClipboard(
events->addEvent(Event(events->forClipboard().clipboardSending(), eventTarget, end)); 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;
}
}

View File

@ -35,7 +35,8 @@ public:
UInt32 sequence, UInt32 sequence,
IEventQueue* events, IEventQueue* events,
void* eventTarget); void* eventTarget);
static void updateChunkSize(bool useSecureSocket);
private: private:
static const size_t m_chunkSize; static size_t s_chunkSize;
}; };