From 1c6a70a87e22dd4fcc5faf1887d98862b40b7913 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Wed, 14 Dec 2016 23:31:51 +0000 Subject: [PATCH] we can now build with gcc6/stdc++6 --- CMakeLists.txt | 31 +++++++++---------- .../src/shared/GameServerConnection.cpp | 22 ++++++++----- .../src/shared/CentralServerConnection.cpp | 25 +++++++++------ .../transferServer/TransferCharacterData.h | 3 +- .../sharedNetwork/src/linux/TcpClient.cpp | 4 +-- 5 files changed, 46 insertions(+), 39 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d63ac216..25ecd4ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,27 +58,24 @@ elseif(UNIX) # don't put anything too crazy in debug...and any common flags go into CMAKE_CXX_FLAGS set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG -DDEBUG_LEVEL=2 -DPRODUCTION=0 -Og -g3") - # funroll loops and everything else potentially crazy for performance here - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDEBUG_LEVEL=0 -DPRODUCTION=1 -Ofast -funroll-loops") - - # TODO: The below flags will enhance security but at the cost of performance, arguably... - # currently with them SWG cluster idles at ~17-18% of 24 cpus, and ata round ~14-17% without - # there is likely also a latency/speed impact as well - # not sure if needed or not - https://wiki.debian.org/Hardening - # ============================================================================================ - # -fstack-protector-all -Wstack-protector --param ssp-buffer-size=4 -fPIE -ftrapv - # -D_FORTIFY_SOURCE=2 is generally considered safe but crashes datatabletool when built with gcc - - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -D_GLIBCXX_USE_CXX11_ABI=0 \ + # Ofast doesn't work with gcc builds + if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Ofast") + elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3") + elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Ofast") + endif() + + # funroll loops and everything else potentially crazy for performance here + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDEBUG_LEVEL=0 -DPRODUCTION=1 -funroll-loops") + + # our "always on" flags + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 \ -m32 -pipe -march=native -mtune=native \ -Wformat -Wno-overloaded-virtual -Wno-missing-braces -Wno-format \ -Wno-write-strings -Wno-unknown-pragmas \ -Wno-uninitialized -Wno-reorder") - - # we could use libc++ with gcc too but let's roll with default there - #if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - #endif() add_definitions(-DLINUX -D_REENTRANT -Dlinux -DSTELLA_INTERNAL -D_GNU_SOURCE -D_XOPEN_SOURCE=500) endif() diff --git a/engine/server/application/CentralServer/src/shared/GameServerConnection.cpp b/engine/server/application/CentralServer/src/shared/GameServerConnection.cpp index ac6edcb8..bb70c1c5 100755 --- a/engine/server/application/CentralServer/src/shared/GameServerConnection.cpp +++ b/engine/server/application/CentralServer/src/shared/GameServerConnection.cpp @@ -33,9 +33,10 @@ #include "serverNetworkMessages/UploadCharacterMessage.h" #include "sharedLog/Log.h" #include "sharedNetworkMessages/ConsoleChannelMessages.h" -#include "sharedNetworkMessages/GenericValueTypeMessage.h" #include "unicodeArchive/UnicodeArchive.h" +#include "sharedNetworkMessages/GenericValueTypeMessage.h" + #include "sharedFoundation/CrcConstexpr.hpp" // ====================================================================== @@ -126,11 +127,16 @@ void GameServerConnection::onReceive(Archive::ByteStream const &message) } case constcrc("TransferReplyNameValidation") : { - GenericValueTypeMessage > const replyNameValidation(ri); + GenericValueTypeMessage > const replyNameValidation(ri); + auto i = replyNameValidation.getValue().begin(); - if (replyNameValidation.getValue().second.getTransferRequestSource() == TransferRequestMoveValidation::TRS_transfer_server) + if (i == replyNameValidation.getValue().end()) { + break; + } + + if (i->second.getTransferRequestSource() == TransferRequestMoveValidation::TRS_transfer_server) { - LOG("CustomerService", ("CharacterTransfer: Received TransferReplyNameValidation from GameServer, forwarding to TransferServer : %s", replyNameValidation.getValue().second.toString().c_str())); + LOG("CustomerService", ("CharacterTransfer: Received TransferReplyNameValidation from GameServer, forwarding to TransferServer : %s", i->second.toString().c_str())); CentralServer::getInstance().sendToTransferServer(replyNameValidation); } else @@ -138,14 +144,14 @@ void GameServerConnection::onReceive(Archive::ByteStream const &message) // pass reply back to the source galaxy for handling, which is to // either display an error message to the user if the request failed, // or to start the transfer process if the request succeeds - LOG("CustomerService", ("CharacterTransfer: Received TransferReplyNameValidation from GameServer, forwarding to source galaxy CentralServer : %s", replyNameValidation.getValue().second.toString().c_str())); + LOG("CustomerService", ("CharacterTransfer: Received TransferReplyNameValidation from GameServer, forwarding to source galaxy CentralServer : %s", i->second.toString().c_str())); CentralServer::getInstance().sendToArbitraryLoginServer(replyNameValidation); // if the request succeeded, also disconnect any clients with a connection to SWG services on this (the target) galaxy - if (replyNameValidation.getValue().second.getIsValidName() && (replyNameValidation.getValue().second.getTransferRequestSource() != TransferRequestMoveValidation::TRS_ingame_freects_command_validate) && (replyNameValidation.getValue().second.getTransferRequestSource() != TransferRequestMoveValidation::TRS_ingame_cts_command_validate)) + if (i->second.getIsValidName() && (i->second.getTransferRequestSource() != TransferRequestMoveValidation::TRS_ingame_freects_command_validate) && (i->second.getTransferRequestSource() != TransferRequestMoveValidation::TRS_ingame_cts_command_validate)) { - GenericValueTypeMessage kickSource("TransferKickConnectedClients", replyNameValidation.getValue().second.getSourceStationId()); - GenericValueTypeMessage kickDestination("TransferKickConnectedClients", replyNameValidation.getValue().second.getDestinationStationId()); + GenericValueTypeMessage kickSource("TransferKickConnectedClients", i->second.getSourceStationId()); + GenericValueTypeMessage kickDestination("TransferKickConnectedClients", i->second.getDestinationStationId()); CentralServer::getInstance().sendToAllLoginServers(kickSource); CentralServer::getInstance().sendToAllLoginServers(kickDestination); CentralServer::getInstance().sendToAllConnectionServers(kickSource, true); diff --git a/engine/server/application/TransferServer/src/shared/CentralServerConnection.cpp b/engine/server/application/TransferServer/src/shared/CentralServerConnection.cpp index ece4ff3d..ea3b1637 100755 --- a/engine/server/application/TransferServer/src/shared/CentralServerConnection.cpp +++ b/engine/server/application/TransferServer/src/shared/CentralServerConnection.cpp @@ -228,27 +228,32 @@ void CentralServerConnection::onReceive(const Archive::ByteStream & message) } case constcrc("TransferReplyNameValidation") : { - const GenericValueTypeMessage > replyNameValidation(ri); - if(!replyNameValidation.getValue().second.getIsMoveRequest()) + const GenericValueTypeMessage > replyNameValidation(ri); + auto i = replyNameValidation.getValue().begin(); + + if (i == replyNameValidation.getValue().end()) { + break; + } + + if(!i->second.getIsMoveRequest()) { - LOG("CustomerService", ("CharacterTransfer: Received replyNameValidation for move validation request. (%s) %s", replyNameValidation.getValue().first.c_str(), replyNameValidation.getValue().second.toString().c_str())); - TransferServer::replyValidateMove(replyNameValidation.getValue().second); + LOG("CustomerService", ("CharacterTransfer: Received replyNameValidation for move validation request. (%s) %s", i->first.c_str(), i->second.toString().c_str())); + TransferServer::replyValidateMove(i->second); } else { - if(TransferServer::isRename(replyNameValidation.getValue().second)) + if(TransferServer::isRename(i->second)) { - LOG("CustomerService", ("CharacterTransfer: Received replyNameValidation for rename request, starting character rename protocol. (%s) %s", replyNameValidation.getValue().first.c_str(), replyNameValidation.getValue().second.toString().c_str())); - const GenericValueTypeMessage renameCharacter("TransferRenameCharacter", replyNameValidation.getValue().second); - CentralServerConnection * centralServerConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(replyNameValidation.getValue().second.getSourceGalaxy()); + LOG("CustomerService", ("CharacterTransfer: Received replyNameValidation for rename request, starting character rename protocol. (%s) %s", i->first.c_str(), i->second.toString().c_str())); + const GenericValueTypeMessage renameCharacter("TransferRenameCharacter", i->second); + CentralServerConnection * centralServerConnection = CentralServerConnection::getCentralServerConnectionForGalaxy(i->second.getSourceGalaxy()); if(centralServerConnection) { centralServerConnection->send(renameCharacter, true); } else { - TransferServer::transferCreateCharacterFailed(replyNameValidation.getValue().second); - } + TransferServer::transferCreateCharacterFailed(i->second); } } else { diff --git a/engine/server/library/serverNetworkMessages/src/shared/transferServer/TransferCharacterData.h b/engine/server/library/serverNetworkMessages/src/shared/transferServer/TransferCharacterData.h index 528f873d..60f9c1f4 100755 --- a/engine/server/library/serverNetworkMessages/src/shared/transferServer/TransferCharacterData.h +++ b/engine/server/library/serverNetworkMessages/src/shared/transferServer/TransferCharacterData.h @@ -104,9 +104,8 @@ public: void setCSToolId (const unsigned int toolId); -private: TransferCharacterData(); - +private: friend class Archive::AutoVariable; friend struct std::pair; friend void Archive::get(Archive::ReadIterator & source, TransferCharacterData & target); diff --git a/engine/shared/library/sharedNetwork/src/linux/TcpClient.cpp b/engine/shared/library/sharedNetwork/src/linux/TcpClient.cpp index e053c695..8acf1289 100755 --- a/engine/shared/library/sharedNetwork/src/linux/TcpClient.cpp +++ b/engine/shared/library/sharedNetwork/src/linux/TcpClient.cpp @@ -373,7 +373,7 @@ void TcpClient::queryConnect () pfd.fd = m_socket; pfd.events = POLLOUT; pfd.revents = 0; - int pollResult = poll(&pfd, 1, 3000); + int pollResult = poll(&pfd, 1, 0); if(pollResult > 0) { if (pfd.revents & POLLERR) @@ -483,7 +483,7 @@ void TcpClient::update() pfd.fd = m_socket; pfd.events = POLLIN|POLLHUP; pfd.revents = 0; - int pollResult = poll (&pfd, 1, 3000); + int pollResult = poll (&pfd, 1, 0); // POLLERR is mutually exclusive with POLLIN and POLLHUP. // POLLIN and POLLHUP are not consistent cross-platform. Additionally, // a POLLHUP doesn't mean that there's not data available. The best,