Skip to content

Commit

Permalink
cleaning the code
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Kraynyukhov committed May 19, 2018
1 parent bdab8ab commit fdc50fe
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 25 deletions.
11 changes: 2 additions & 9 deletions include/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ namespace LAppS
}

explicit Application(const std::string& appName,const std::string& target,const size_t mims)
: mMayRun(true),mMutex(),mName(appName), mTarget(target),
: mMayRun{true},mMutex(),mName(appName), mTarget(target),
max_inbound_message_size(mims),mAppContext(appName,this)
{
itc::Singleton<WSWorkersPool<TLSEnable,StatsEnable>>::getInstance()->getWorkers(mWorkers);
Expand Down Expand Up @@ -155,7 +155,7 @@ namespace LAppS
{
try
{
auto te=mEvents.recv();
auto te=std::move(mEvents.recv());
switch(te.event.type)
{
case WebSocketProtocol::OpCode::CLOSE:
Expand All @@ -166,13 +166,6 @@ namespace LAppS
const bool exec_result=mAppContext.onMessage(te.wid,te.sockfd,te.event);
if(!exec_result)
{
/*
MSGBufferTypeSPtr outBuffer=std::make_shared<MSGBufferType>();
WebSocketProtocol::ServerCloseMessage(*outBuffer,WebSocketProtocol::DefiniteCloseCode::SHUTDOWN);
getWorker(te.wid)->submitResponse(te.sockfd,outBuffer);
**/
mMayRun.store(false);
}
}
Expand Down
2 changes: 1 addition & 1 deletion include/ApplicationContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ namespace LAppS
ApplicationContext(ApplicationContext&)=delete;

explicit ApplicationContext(const std::string& appname, abstract::Application* parent)
: ::abstract::ApplicationContext(appname), mParent(parent),mMutex(),mustStop(false)
: ::abstract::ApplicationContext(appname), mParent(parent),mMutex(),mustStop{false}
{
luaL_openlibs(mLState);

Expand Down
2 changes: 1 addition & 1 deletion include/Balancer.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace LAppS
mInbound.send(data);
}

Balancer(const float connw=0.7):mConnectionWeight(connw),mMayRun(true),mWorkersCache(0)
Balancer(const float connw=0.7):mConnectionWeight(connw),mMayRun{true},mWorkersCache(0)
{
itc::Singleton<WSWorkersPool<TLSEnable,StatsEnable>>::getInstance()->getWorkers(mWorkersCache);
}
Expand Down
5 changes: 3 additions & 2 deletions include/IOWorker.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ namespace LAppS

explicit IOWorker(const size_t id, const size_t maxConnections,const bool af)
: Worker(id,maxConnections,af), enableTLS(), enableStatsUpdate(),
mMayRun(true), mCanStop(false), mConnectionsMutex(),
mMayRun{true}, mCanStop{false}, mConnectionsMutex(),
mInboundMutex(), mShakespeer(), mEPoll(std::make_shared<ePoll>()),
mInboundConnections(), mConnections(), mEvents(1000),
mNap(), haveConnections(false),haveNewConnections(false)
mNap(), haveConnections{false},haveNewConnections{false}
{
mConnections.clear();
}
Expand Down Expand Up @@ -130,6 +130,7 @@ namespace LAppS
{
if(error_bit(mEvents[i].events))
{
SyncLock sync(mConnectionsMutex);
deleteConnection(mEvents[i].data.fd);
}
else
Expand Down
2 changes: 1 addition & 1 deletion include/InternalAppContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ namespace LAppS
public:

InternalAppContext(const std::string& name):
::abstract::ApplicationContext(name)
::abstract::ApplicationContext(name), mMustStop{false},mCanStop{false}
{
luaL_openlibs(mLState);

Expand Down
5 changes: 3 additions & 2 deletions include/WebSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,8 @@ template <bool TLSEnable=false, bool StatsEnable=false> class WebSocket
int send(const std::vector<uint8_t>& buff)
{
updateOutStats(buff.size());
return this->send(buff,enableTLS);
int ret=this->send(buff,enableTLS);
return ret;
}

void updateInStats(const size_t sz)
Expand Down Expand Up @@ -823,7 +824,7 @@ RFC 6455 The WebSocket Protocol December 2011
}while(outCursor!=buff.size());

return outCursor;
}
}
};

#endif /* __WEBSOCKET_H__ */
Expand Down
11 changes: 11 additions & 0 deletions include/ePollController.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@
*
**/

/***
* DEPRECATED DEPRECATED DEPRECATED DEPRECATED
* DE CATED DE DE CATED DE CATED
* DE CATED DE DE CATED DE CATED
* DE CATED DEPRECATED DEPRECATED DEPRECATED
* DE CATED DE DE DE REC
* DE CATED DE DE DE ECA
* DEPRECATED DEPRECATED DE DE CATED
*
* ... you've got the idea. this sht is deprecated.
***/

#ifndef __EPOLLCONTROLLER_H__
# define __EPOLLCONTROLLER_H__
Expand Down
6 changes: 3 additions & 3 deletions nbproject/Makefile-Debug.mk
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@ ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/lapps: ../utils/dist/Debug/GNU-Linux/

${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/lapps: ${OBJECTFILES}
${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}
g++ -pipe -Wall -pthread -O2 -mtune=native -march=native -fPIC -fstack-check -fstack-protector-strong -mfpmath=sse -msse2avx -ftree-vectorize -funroll-loops -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/lapps ${OBJECTFILES} ${LDLIBSOPTIONS} -latomic -lcryptopp -ltls -lcrypto -lluajit-5.1 -lprofiler
g++ -pipe -Wall -pthread -O2 -mtune=native -march=native -fPIC -fstack-check -fstack-protector-strong -mfpmath=sse -msse2avx -ftree-vectorize -funroll-loops -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/lapps ${OBJECTFILES} ${LDLIBSOPTIONS} -latomic -lcryptopp -ltls -lcrypto -lluajit-5.1

${OBJECTDIR}/src/getLog.o: src/getLog.cpp nbproject/Makefile-${CND_CONF}.mk
${MKDIR} -p ${OBJECTDIR}/src
${RM} "$@.d"
$(COMPILE.cc) -g -DAPP_NAME=\"LAppS\" -DLOG_FILE=\"lapps.log\" -DLOG_INFO -DMAX_BUFF_SIZE=512 -DSTATS_ENABLE -DTSAFE_LOG=1 -DLAPPS_TLS_ENABLE -I../libressl/include -I../ITCFramework/include -I../ITCLib/include -I../utils/include -Iinclude -Iinclude/modules -I/usr/local/include -I/usr/local/include/luajit-2.0 -std=c++14 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/src/getLog.o src/getLog.cpp
$(COMPILE.cc) -g -DAPP_NAME=\"LAppS\" -DLOG_FILE=\"lapps.log\" -DLOG_INFO -DMAX_BUFF_SIZE=512 -DSTATS_ENABLE -DTSAFE_LOG=1 -I../libressl/include -I../ITCFramework/include -I../ITCLib/include -I../utils/include -Iinclude -Iinclude/modules -I/usr/local/include -I/usr/local/include/luajit-2.0 -std=c++14 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/src/getLog.o src/getLog.cpp

${OBJECTDIR}/src/main.o: src/main.cpp nbproject/Makefile-${CND_CONF}.mk
${MKDIR} -p ${OBJECTDIR}/src
${RM} "$@.d"
$(COMPILE.cc) -g -DAPP_NAME=\"LAppS\" -DLOG_FILE=\"lapps.log\" -DLOG_INFO -DMAX_BUFF_SIZE=512 -DSTATS_ENABLE -DTSAFE_LOG=1 -DLAPPS_TLS_ENABLE -I../libressl/include -I../ITCFramework/include -I../ITCLib/include -I../utils/include -Iinclude -Iinclude/modules -I/usr/local/include -I/usr/local/include/luajit-2.0 -std=c++14 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/src/main.o src/main.cpp
$(COMPILE.cc) -g -DAPP_NAME=\"LAppS\" -DLOG_FILE=\"lapps.log\" -DLOG_INFO -DMAX_BUFF_SIZE=512 -DSTATS_ENABLE -DTSAFE_LOG=1 -I../libressl/include -I../ITCFramework/include -I../ITCLib/include -I../utils/include -Iinclude -Iinclude/modules -I/usr/local/include -I/usr/local/include/luajit-2.0 -std=c++14 -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/src/main.o src/main.cpp

# Subprojects
.build-subprojects:
Expand Down
4 changes: 4 additions & 0 deletions nbproject/Package-Debug.bash
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ cd "${TOP}"
makeDirectory "${NBTMPDIR}//usr/bin"
copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755

cd "${TOP}"
makeDirectory "${NBTMPDIR}//usr/bin"
copyFileToTmpDir "${OUTPUT_PATH}" "${NBTMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755


# Create control file
cd "${TOP}"
Expand Down
9 changes: 7 additions & 2 deletions nbproject/configurations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@
<commandLine>-pipe -Wall -pthread -O2 -fPIC -march=native -mtune=native -fstack-check -fstack-protector-strong -mfpmath=sse -ftree-vectorize -funroll-loops</commandLine>
<preprocessorList>
<Elem>APP_NAME="LAppS"</Elem>
<Elem>LAPPS_TLS_ENABLE</Elem>
<Elem>LOG_FILE="lapps.log"</Elem>
<Elem>LOG_INFO</Elem>
<Elem>MAX_BUFF_SIZE=512</Elem>
Expand Down Expand Up @@ -166,7 +165,7 @@
</makeArtifact>
</linkerLibProjectItem>
</linkerLibItems>
<commandLine>-latomic -lcryptopp -ltls -lcrypto -lluajit-5.1 -lprofiler</commandLine>
<commandLine>-latomic -lcryptopp -ltls -lcrypto -lluajit-5.1</commandLine>
</linkerTool>
<requiredProjects>
<makeArtifact PL="../utils"
Expand Down Expand Up @@ -522,6 +521,12 @@
perm="755"
owner="root"
group="bin"/>
<packFileListElem type="File"
to="${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}"
from="${OUTPUT_PATH}"
perm="755"
owner="root"
group="bin"/>
</packFileList>
<packInfoList>
<packInfoListElem name="Package" value="lapps" mandatory="true"/>
Expand Down
6 changes: 2 additions & 4 deletions nbproject/private/private.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/home/pk/workspace/docker/luadev.env/workspace/LAppS/include/Config.h</file>
<file>file:/home/pk/workspace/docker/luadev.env/workspace/LAppS/include/IOWorker.h</file>
<file>file:/home/pk/workspace/docker/luadev.env/workspace/LAppS/include/WSStreamProcessor.h</file>
<file>file:/home/pk/workspace/docker/luadev.env/workspace/LAppS/include/WebSocket.h</file>
<file>file:/home/pk/workspace/docker/luadev.env/workspace/LAppS/include/WSServerMessage.h</file>
<file>file:/home/pk/workspace/docker/luadev.env/workspace/LAppS/include/ApplicationContext.h</file>
<file>file:/home/pk/workspace/docker/luadev.env/workspace/LAppS/include/ePollController.h</file>
</group>
</open-files>
</project-private>

0 comments on commit fdc50fe

Please # to comment.