From 2a6d12cac6c70e299de124302d1a7d646bbc9a7d Mon Sep 17 00:00:00 2001 From: hama Date: Sun, 22 Mar 2015 17:56:10 +0100 Subject: [PATCH] dirtool TCP works with upload/download test --- base/ReThread.cpp | 33 +++++++++++-- base/ReThread.hpp | 1 + net/ReTCP.cpp | 113 ++++++++++++++++++++++++++----------------- net/ReTCP.hpp | 33 +++++++++++-- os/ReDirTools.cpp | 119 +++++++++++++++++++++++++--------------------- 5 files changed, 194 insertions(+), 105 deletions(-) diff --git a/base/ReThread.cpp b/base/ReThread.cpp index b7f638a..512a850 100644 --- a/base/ReThread.cpp +++ b/base/ReThread.cpp @@ -33,7 +33,7 @@ ReThread::ReThread(bool autoDelete) : m_threadInfo(), #elif defined __WIN32__ m_threadInfo(NULL), - m_osThreadId(0), + m_osThreadId(0), #endif m_shouldStop(false), m_isStopped(false), @@ -86,12 +86,13 @@ bool ReThread::prepareToRun(int id, ReLogger* masterLogger, ReThreadPool* pool) { bool rc = false; if (m_pool != NULL) { - ReLogger* current = masterLogger == NULL ? globalLogger() : masterLogger; + ReLogger* current = + masterLogger == NULL ? globalLogger() : masterLogger; current->sayF(LOG_ERROR | CAT_LIB, LC_PREPARE_TO_RUN_1, i18n("prepareToRun($1) is called multiple times")).arg(id).end(); } else { m_threadId = id; - if (m_appender != NULL){ + if (m_appender != NULL) { m_appender->setMasterLogger(masterLogger); } else { m_appender = new ReSlaveAppender(masterLogger, @@ -191,6 +192,32 @@ bool ReThreadPool::insertThread(ReThread* thread) { return found; } +/** + * Returns the number of active threads. + * + * Inactive threads will be removed. + * + * @return the number of running threads + */ +int ReThreadPool::countThreads() { + int count = 0; + m_mutexThreads.lock(); + for (int ii = 0; ii < m_maxThreads; ii++) { + ReThread* current = m_threads[ii]; + if (current != NULL) { + if (!current->m_isStopped) + count++; + else { + if (current->m_autoDelete) + delete current; + m_threads[ii] = NULL; + } + } + } + m_mutexThreads.unlock(); + return count; +} + /** * Stopps all running threads. */ diff --git a/base/ReThread.hpp b/base/ReThread.hpp index 0d970e7..29eaea6 100644 --- a/base/ReThread.hpp +++ b/base/ReThread.hpp @@ -82,6 +82,7 @@ public: ReThreadPool(int maxThreads, ReLogger* logger); virtual ~ReThreadPool(); public: + int countThreads(); void killAllThreads(); bool startSimpleThread(ReProcessor& processor); bool startThread(ReThread* thread); diff --git a/net/ReTCP.cpp b/net/ReTCP.cpp index cd938e7..74adb0d 100644 --- a/net/ReTCP.cpp +++ b/net/ReTCP.cpp @@ -31,12 +31,33 @@ enum LOCATION_DIRTOOL { LC_SERVER_CONNECTION_RUN_1, // 50520 LC_SERVER_CONNECTION_RUN_2, // 50521 LC_SERVER_CONNECTION_RUN_3, // 50522 + LC_HANDLE_CONNECTION_4, // 50523 }; #if defined __WIN32__ bool ReTCPConnection::isGlobalInitialized = false; #endif +/** + * Constructor. + * + * @param message the description of the exception + */ +ReTCPException::ReTCPException(const char* message) { + +} +; + +/** + * Constructor. + * + * @param socket the socket which is disconnected + */ +ReTCPDisconnectException::ReTCPDisconnectException(int socket) : + ReTCPException(i18n("disconnected")), + m_socket(socket) { +} + /** * Constructor. * @@ -188,7 +209,8 @@ ReTCPConnection::ReTCPConnection(int id, ReLoggerOwner* loggerOwner) : m_handleSocket(-1), m_id(id), m_noSent(0), - m_noReceived(0) { + m_noReceived(0), + m_logSendReceive(true) { #if defined __WIN32__ WSADATA wsaData; if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) { @@ -246,11 +268,16 @@ void ReTCPConnection::setConnectedAddress(int family, const char* ip, * * @param command OUT: the received command * @param data OUT: the received data + * + * @throws ReTCPBrokenPipeException */ void ReTCPConnection::receive(ReByteBuffer& command, ReByteBuffer& data) { command.setLength(8); int received = recv(m_handleSocket, command.buffer(), 8, 0); - if (received != 8) { + if (received == 0) { + // connection closed from the peer + throw ReTCPDisconnectException(m_handleSocket); + } else if (received != 8) { m_loggerOwner->logger()->sayF(LOG_ERROR | CAT_NETWORK, LC_RECEIVE_1, i18n("cannot receive ($1): $2 [$3]")).arg(errno).arg(received).arg( m_peerName).end(); @@ -291,7 +318,7 @@ void ReTCPConnection::receive(ReByteBuffer& command, ReByteBuffer& data) { m_loggerOwner->logger()->sayF(LOG_ERROR | CAT_NETWORK, LC_RECEIVE_4, i18n("too few bytes read: $1/$2 [$3]")).arg( readBytes).arg(received).arg(m_peerName).end(); - } else { + } else if (m_logSendReceive) { m_loggerOwner->logger()->sayF(LOG_DEBUG | CAT_NETWORK, LC_RECEIVE_5, i18n("received: $1 bytes in $2 round(s) [$3]: $4")).arg( @@ -325,11 +352,14 @@ void ReTCPConnection::send(const char* command, const char* data, int length) { // add command length: int rest = length + 8; m_toSend.appendInt(rest | (flags << 24), "%08x"); + // we send the flag/length too: + rest += 8; m_toSend.appendFix(command, -1, 8, 8, NULL); m_toSend.append(data, length); int sent = 0; const char* buf = m_toSend.str(); int rounds = 0; + while (rest > 0) { rounds++; if ((sent = ::send(m_handleSocket, buf, rest, 0)) > 0) { @@ -341,7 +371,7 @@ void ReTCPConnection::send(const char* command, const char* data, int length) { break; } } - if (rest == 0) + if (rest == 0 && m_logSendReceive) m_loggerOwner->logger()->sayF(LOG_DEBUG | CAT_NETWORK, LC_WRITE_2, i18n("sent: $1 bytes in $2 round(s): $3 $4")).arg(length).arg( rounds).arg(command).arg( @@ -376,26 +406,34 @@ void ReTCPServerConnection::run() { ReByteBuffer command; ReNetCommandHandler::ProcessingState rc = ReNetCommandHandler::PS_UNDEF; m_loggerOwner->logger()->sayF(LOG_INFO | CAT_NETWORK, - LC_SERVER_CONNECTION_RUN_1, i18n("new connection to $1")) - .arg(m_name).end(); - do { - receive(command, m_received); - rc = m_server->handler().handleNetCommand(command, m_received, this); - if (rc == ReNetCommandHandler::PS_UNKNOWN) { - logger()->sayF(LOG_ERROR | CAT_NETWORK, LC_HANDLE_CONNECTION_1, - i18n("unknown command: $1 length: $2")).arg(command).arg( - m_received.length()).end(); - } - } while (rc != ReNetCommandHandler::PS_STOP && !m_shouldStop); - m_pool->setShouldStop(); + LC_SERVER_CONNECTION_RUN_1, i18n("new connection to $1")).arg(m_name) + .end(); + try { + do { + receive(command, m_received); + rc = m_server->handler().handleNetCommand(command, m_received, + this); + if (rc == ReNetCommandHandler::PS_UNKNOWN) { + logger()->sayF(LOG_ERROR | CAT_NETWORK, LC_HANDLE_CONNECTION_1, + i18n("unknown command: $1 length: $2")).arg(command).arg( + m_received.length()).end(); + } + } while (rc != ReNetCommandHandler::PS_STOP && !m_shouldStop); + m_pool->setShouldStop(); + } catch (ReTCPDisconnectException& e) { + rc = ReNetCommandHandler::PS_CLOSED; + } close(); - if (rc == ReNetCommandHandler::PS_STOP) + if (rc == ReNetCommandHandler::PS_CLOSED) + logger()->sayF(LOG_INFO | CAT_NETWORK, LC_HANDLE_CONNECTION_4, + i18n("connection closed by the peer $1")).arg(m_peerName).end(); + else if (rc == ReNetCommandHandler::PS_STOP) m_loggerOwner->logger()->sayF(LOG_INFO | CAT_NETWORK, - LC_SERVER_CONNECTION_RUN_2, i18n("stop signal received from $1")) - .arg(m_name).end(); + LC_SERVER_CONNECTION_RUN_2, i18n("stop signal received from $1")) + .arg(m_name).end(); else m_loggerOwner->logger()->say(LOG_INFO | CAT_NETWORK, - LC_SERVER_CONNECTION_RUN_3, i18n("stop order received")); + LC_SERVER_CONNECTION_RUN_3, i18n("stop order received")); m_id = -1; } @@ -414,25 +452,18 @@ ReTCPServer::ReTCPServer(int port, class ReNetCommandHandler& commandHandler, ReLogger* logger, int maxConnections) : ReTCPConnection(0, this), m_maxConnections(maxConnections), - m_countConnections(0), - m_connections(new ReTCPServerConnection*[maxConnections]), m_handler(commandHandler), - m_logger(logger) { + m_logger(logger), + m_threadPool(maxConnections, logger) { #pragma warning( pop ) m_port = port; - memset(m_connections, 0, maxConnections * sizeof *m_connections); } /** * Destructor. */ ReTCPServer::~ReTCPServer() { - for (int ii = 0; ii < m_countConnections; ii++) { - delete m_connections[ii]; - m_connections[ii] = NULL; - } - delete[] m_connections; - m_connections = NULL; + // m_poolConnections does the things! } /** * Creates a server connection. @@ -444,15 +475,9 @@ ReTCPServer::~ReTCPServer() { ReTCPServerConnection* ReTCPServer::createConnection(int id, int handleSocket, const struct sockaddr& address) { ReTCPServerConnection* rc = NULL; - for (int ii = 0; rc == NULL && ii < m_maxConnections; ii++) { - if (m_connections[ii] == NULL) - m_connections[ii] = rc = new ReTCPServerConnection(id, this); - else if (m_connections[ii]->id() < 0) { - rc = m_connections[ii]; - rc->setId(id); - } - } - if (rc != NULL) { + if (m_threadPool.countThreads() < m_maxConnections) { + rc = new ReTCPServerConnection(id, this); + rc->setId(id); rc->setHandleSocket(handleSocket); char ip[INET6_ADDRSTRLEN]; inet_ntop(address.sa_family, @@ -476,7 +501,6 @@ bool ReTCPServer::listenForAll() { bool rc = false; struct addrinfo hints; struct addrinfo* addrInfo; - ReThreadPool pool(m_maxConnections + 1, m_logger); // first, load up address structs with getaddrinfo(): memset(&hints, 0, sizeof hints); @@ -524,8 +548,8 @@ bool ReTCPServer::listenForAll() { socklen_t lengthAddr = sizeof(struct sockaddr_in); while ((clientSocket = accept(m_handleSocket, (struct sockaddr *) &addrClient, &lengthAddr)) != 0) { - if (!pool.shouldStop()) { - if (m_countConnections >= m_maxConnections) { + if (!m_threadPool.shouldStop()) { + if (m_threadPool.countThreads() >= m_maxConnections) { // close the connection at once: m_logger->sayF(LOG_WARNING | CAT_NETWORK, LC_LISTEN_FOR_ALL_5, @@ -536,7 +560,8 @@ bool ReTCPServer::listenForAll() { } else { ReTCPServerConnection* connection = createConnection( nextId++, clientSocket, addrClient); - if (!pool.startThread(connection)) { + connection->setLogSendReceive(m_logSendReceive); + if (!m_threadPool.startThread(connection)) { m_logger->sayF(LOG_ERROR | CAT_PROCESS, LC_LISTEN_FOR_ALL_6, i18n("cannot create a thread: $1")).arg( @@ -549,7 +574,7 @@ bool ReTCPServer::listenForAll() { } } } - if (pool.shouldStop()) { + if (m_threadPool.shouldStop()) { m_logger->say(LOG_INFO | CAT_PROCESS, LC_LISTEN_FOR_ALL_7, i18n("stop request received")); } diff --git a/net/ReTCP.hpp b/net/ReTCP.hpp index b9e620f..05066ba 100644 --- a/net/ReTCP.hpp +++ b/net/ReTCP.hpp @@ -15,6 +15,25 @@ #elif defined __WIN32__ # define reCloseSocket(handle) ::closesocket(handle) #endif + +/** + * Exceptions for TCP processing. + */ +class ReTCPException: public ReException { +public: + ReTCPException(const char* message); +}; + +/** + * Exceptions when a connection is lost. + */ +class ReTCPDisconnectException: ReTCPException { +public: + ReTCPDisconnectException(int socket); +public: + int m_socket; +}; + /** * Administrates the internal data of an ip address, usable for IP4 and IP6. */ @@ -94,6 +113,12 @@ public: inline void setId(int id) { m_id = id; } + /** Sets the flag for logging sending and/or receiving. + * @param value true: the logging should be done + */ + void setLogSendReceive(bool value) { + m_logSendReceive = value; + } protected: ReByteBuffer m_peerName; ReByteBuffer m_received; @@ -102,12 +127,14 @@ protected: int m_id; uint32_t m_noSent; uint32_t m_noReceived; + bool m_logSendReceive; #if defined __WIN32__ private: static bool isGlobalInitialized; #endif public: static void globalClose(); + }; /** * Implements a TCP client. @@ -122,7 +149,6 @@ public: private: ReLogger* m_logger; }; - class ReTCPServer; /** * Implements a single server connection to a client (in a single thread). @@ -146,6 +172,7 @@ public: ReLogger* logger, int maxConnections = 16); virtual ~ReTCPServer(); public: + ReTCPServerConnection* connectionByIndex(int index); /** Returns the command handler. * @return the handler for the incoming messages */ @@ -160,10 +187,9 @@ private: protected: int m_maxConnections; - int m_countConnections; - ReTCPServerConnection** m_connections; ReNetCommandHandler& m_handler; ReLogger* m_logger; + ReThreadPool m_threadPool; }; /** @@ -177,6 +203,7 @@ public: PS_PROCESSED, // task has been successfully handled PS_FAILED, // task has been handled, error occurred PS_STOP, // no further processing should be done + PS_CLOSED, // connection has been closed by peer }; public: ReNetCommandHandler(); diff --git a/os/ReDirTools.cpp b/os/ReDirTools.cpp index b054fae..53ff136 100644 --- a/os/ReDirTools.cpp +++ b/os/ReDirTools.cpp @@ -409,7 +409,7 @@ ReFileTime_t ReDirOptions::checkDate(const char* value) { * @return the value (multiplied with the unit factor) * @throws ReOptionExecption */ -time_t ReDirOptions::checkSize(const char* value) { +int64_t ReDirOptions::checkSize(const char* value) { int64_t rc = 0; char unit = 'b'; switch (sscanf(value, "%lld%c", (long long int*) &rc, &unit)) { @@ -984,25 +984,25 @@ ReDirBatch::ReDirBatch(ReLogger* logger) : m_isExe(false) { // standard short options: D d O o P p T t v y Z z m_programArgs.addString("first", - i18n("defines the first line of the output"), '1', "first-line", true, + i18n("defines the first line of the output"), '1', "first-line", true, #if defined __linux__ - "#! /bin/sh" + "#! /bin/sh" #elif defined __WIN32__ - "rem this batch is created by dirtool" + "rem this batch is created by dirtool" #endif - ); +) ; m_programArgs.addString("arguments", i18n("template for the output line.\n" - "Possible placeholders: (e.g. e:\\data\\sample.txt)\n" - " !full!: e:\\data\\sample.txt\n" - " !path!: e:\\data\\\n" - " !basename!: sample.txt\n" - " !name!: sample\n" - " !ext!: .txt\n" - "example: --arguments='echo !basename! in !path! found'"), 'a', - "arguments", false, NULL); + "Possible placeholders: (e.g. e:\\data\\sample.txt)\n" + " !full!: e:\\data\\sample.txt\n" + " !path!: e:\\data\\\n" + " !basename!: sample.txt\n" + " !name!: sample\n" + " !ext!: .txt\n" + "example: --arguments='echo !basename! in !path! found'"), 'a', + "arguments", false, NULL); m_programArgs.addString("script", - i18n("name of the script (starts each output line)"), 'c', "script", - false, NULL); + i18n("name of the script (starts each output line)"), 'c', "script", + false, NULL); #if defined __WIN32__ m_programArgs.addBool("isexe", i18n("supresses the starting 'call' of each output line" @@ -1080,7 +1080,7 @@ void ReDirBatch::doIt() { #elif defined __WIN32__ static const char* prefix = "rem "; #endif - printSummary (prefix); + printSummary(prefix); } /** @@ -1834,7 +1834,7 @@ void ReDirTouch::processDir(ReDirStatus_t* entry) { static bool isAbsoluteTime(ReFileTime_t& time) { #if defined __linux__ - static struct tm year1980 = {0, 0, 0, 1, 1 - 1, 1980 - 1900}; + static struct tm year1980 = { 0, 0, 0, 1, 1 - 1, 1980 - 1900 }; static time_t time1980 = mktime(&year1980); return time.tv_sec >= time1980; #elif defined __WIN32__ @@ -2078,47 +2078,47 @@ bool ReDirSync::copyFile(const char* source, ReFileProperties_t* properties, struct stat info; if (properties == NULL) { if (stat(source, &info) == 0) - properties = &info; + properties = &info; else { if (logger != NULL) - logger->sayF(LOG_ERROR | CAT_FILE, LC_COPY_FILE_1, - i18n("could not find: $1 (errno: $2)")).arg(source).arg( + logger->sayF(LOG_ERROR | CAT_FILE, LC_COPY_FILE_1, + i18n("could not find: $1 (errno: $2)")).arg(source).arg( errno).end(); } } FILE* fpSource = fopen(source, "rb"); if (fpSource == NULL) { if (logger != NULL) - logger->sayF(LOG_ERROR | CAT_FILE, LC_COPY_FILE_2, - i18n("cannot open $1 (errno: $2)")).arg(source).arg(errno).end(); + logger->sayF(LOG_ERROR | CAT_FILE, LC_COPY_FILE_2, + i18n("cannot open $1 (errno: $2)")).arg(source).arg(errno).end(); } else { ReFileSize_t size = - properties == NULL ? 0x7fffffff : properties->st_size; + properties == NULL ? 0x7fffffff : properties->st_size; FILE* fpTarget = fopen(target, "w"); if (fpTarget == NULL) { if (logger != NULL) - logger->sayF(LOG_ERROR | CAT_FILE, LC_COPY_FILE_3, - i18n("cannot open $1 (errno: $2)")).arg(target).arg(errno) - .end(); + logger->sayF(LOG_ERROR | CAT_FILE, LC_COPY_FILE_3, + i18n("cannot open $1 (errno: $2)")).arg(target).arg(errno) + .end(); } else { while (size > 0) { size_t blockSize = buffer.capacity(); if ((int) blockSize > size) - blockSize = size; + blockSize = size; if (fread(buffer.buffer(), blockSize, 1, fpSource) != 1) { if (logger != NULL) - logger->sayF(LOG_ERROR | CAT_FILE, LC_COPY_FILE_5, - i18n("cannot read $1 (errno: $2)")).arg(source).arg( + logger->sayF(LOG_ERROR | CAT_FILE, LC_COPY_FILE_5, + i18n("cannot read $1 (errno: $2)")).arg(source).arg( errno).end(); break; } size_t written; if ((written = fwrite(buffer.buffer(), 1, blockSize, fpTarget)) - != blockSize) { + != blockSize) { if (logger != NULL) - logger->sayF(LOG_ERROR | CAT_FILE, LC_COPY_FILE_6, - i18n("cannot write $1 [$2] (errno: $3)")).arg( - target).arg(written).arg(errno).end(); + logger->sayF(LOG_ERROR | CAT_FILE, LC_COPY_FILE_6, + i18n("cannot write $1 [$2] (errno: $3)")).arg( + target).arg(written).arg(errno).end(); break; } size -= blockSize; @@ -2126,7 +2126,7 @@ bool ReDirSync::copyFile(const char* source, ReFileProperties_t* properties, rc = size == 0ll; fclose(fpTarget); if (properties != NULL) - setProperties(target, properties, logger); + setProperties(target, properties, logger); } fclose(fpSource); } @@ -2159,24 +2159,24 @@ bool ReDirSync::setProperties(const char* fullName, times[1].tv_usec = properties->st_mtim.tv_nsec / 1000; if (utimes(fullName, times) != 0) { if (logger != NULL) - logger->sayF(LOG_ERROR | CAT_FILE, LC_SET_PROPERTIES_1, - i18n("cannot change file times: $1 (errno: $2)")).arg(fullName) - .arg(errno).end(); + logger->sayF(LOG_ERROR | CAT_FILE, LC_SET_PROPERTIES_1, + i18n("cannot change file times: $1 (errno: $2)")).arg(fullName) + .arg(errno).end(); rc = false; } int rights = properties->st_mode & (S_IRWXO | S_IRWXG | S_IRWXU); if (chmod(fullName, rights) != 0) { if (logger != NULL) - logger->sayF(LOG_ERROR | CAT_FILE, LC_SET_PROPERTIES_2, - i18n("cannot change file modes: $1 (errno: $2)")).arg(fullName) - .arg(errno).end(); + logger->sayF(LOG_ERROR | CAT_FILE, LC_SET_PROPERTIES_2, + i18n("cannot change file modes: $1 (errno: $2)")).arg(fullName) + .arg(errno).end(); rc = false; } if (chown(fullName, properties->st_uid, properties->st_gid) != 0) { if (logger != NULL) - logger->sayF(LOG_ERROR | CAT_FILE, LC_SET_PROPERTIES_3, - i18n("cannot change file owner: $1 (errno: $2)")).arg(fullName) - .arg(errno).end(); + logger->sayF(LOG_ERROR | CAT_FILE, LC_SET_PROPERTIES_3, + i18n("cannot change file owner: $1 (errno: $2)")).arg(fullName) + .arg(errno).end(); rc = false; } #endif @@ -2362,9 +2362,11 @@ void ReDirSync::doIt() { ReDirTCP::ReDirTCP(ReLogger* logger) : ReTool(s_tcpUsage, s_tcpExamples, 1, 0, 0, true, logger) { m_hasStandardArgs = false; - m_programArgs.addInt("size", - i18n("size of the message to send/receive (in KiByte)"), 'b', - "--buffer-size", 64); + m_programArgs.addString("size", i18n("size of the message to send/receive\n" + " is a number followed by an unit\n" + "units: b(yte) k(Byte) K(iByte) m(Byte), M(iByte)\n" + "Note: maximum: 16M-32=16777184\n" + "examples: -b1m --buffer-size=512K"), 'b', "size", false, "64K"); m_programArgs.addInt("port", i18n("port of the server/client"), 'p', "--port", 58111); } @@ -2374,11 +2376,16 @@ ReDirTCP::ReDirTCP(ReLogger* logger) : */ void ReDirTCP::doIt() { int port = m_programArgs.getInt("port"); - int bufferSize = m_programArgs.getInt("size") * 1024; - + ReByteBuffer buffer; + int64_t bufferSize = checkSize(m_programArgs.getString("size", buffer)); + // the protocol does not allow more than 16 MiByte because of the flags: + if (bufferSize > 16LL * 1024 * 1024 - 64LL) + help(i18n("buffersize exceeds 16777184 = 16MiByte - 32: "), + buffer.str()); ReByteBuffer command = m_programArgs.arg(0); if (command.isPrefixOf("server", -1, true)) { ReTCPEchoServer server(port, m_logger); + server.setLogSendReceive(false); server.listenForAll(); } else if (command.isPrefixOf("client", -1, true)) { const char* ip = m_programArgs.arg(1); @@ -2399,9 +2406,9 @@ void ReDirTCP::doIt() { if (m_programArgs.argCount() > 4) interval = atoi(m_programArgs.arg(4)); if (tolower(direction.at(0)) == 'm') - runMixedClient(ip, port, rounds, interval, bufferSize); + runMixedClient(ip, port, rounds, interval, (int) bufferSize); else - runOneThreadClient(ip, port, rounds, interval, bufferSize, + runOneThreadClient(ip, port, rounds, interval, (int) bufferSize, tolower(direction.at(0)) == 'u'); } else help("unknown subcommand: $1", command.str()); @@ -2425,6 +2432,7 @@ void ReDirTCP::runOneThreadClient(const char* ip, int port, int rounds, int64_t size = 0; int duration = 0; ReByteBuffer answer, data; + client.setLogSendReceive(false); for (int ii = 0; ii < rounds; ii++) { client.send(command, message.str(), message.length()); client.receive(answer, data); @@ -2442,7 +2450,8 @@ void ReDirTCP::runOneThreadClient(const char* ip, int port, int rounds, if (duration == 0) duration = 1; printf("%2d: %9.3f MiByte %8.3f kiByte %s/sec %s\n", rounds, - size / 1024.0 / 1024, (double) size / duration / 1024, upload ? "up" : "down"); + size / 1024.0 / 1024, (double) size / duration / 1024, + upload ? "up" : "down"); } } @@ -2461,13 +2470,13 @@ ReDirWhich::ReDirWhich(ReLogger* logger) : false, NULL); m_programArgs.addString("separator", - i18n("separator between the path elements"), 's', "separator", false, + i18n("separator between the path elements"), 's', "separator", false, #if defined __linux__ - ":" + ":" #elif defined __WIN32__ - ";" + ";" #endif - ); +) ; m_programArgs.addString("variable", i18n("variable with the path list"), 'v', "variable", false, "PATH"); m_hasStandardArgs = false; -- 2.39.5