-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix dead lock bug, add Login Command
- Loading branch information
root
committed
Oct 20, 2015
1 parent
6be050f
commit b217972
Showing
15 changed files
with
190 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* ===================================================================================== | ||
* | ||
* Filename: LoginProcessCmd.h | ||
* | ||
* Description: Login Command | ||
* | ||
* Version: 1.0 | ||
* Created: 10/20/2015 11:46:56 AM | ||
* Revision: none | ||
* Compiler: gcc | ||
* | ||
* Author: huangyun (hy), [email protected] | ||
* Organization: | ||
* | ||
* ===================================================================================== | ||
*/ | ||
|
||
#ifndef __LOGINPROCESSCMD_H_ | ||
#define __LOGINPROCESSCMD_H_ | ||
#include "CmdNumber.h" | ||
#include "BaseCmd.h" | ||
#include <cstring> | ||
|
||
namespace MyNameSpace | ||
{ | ||
namespace Command | ||
{ | ||
const int MAX_ACCOUNT_LEN = 48; | ||
struct ReqLogin : BaseCommand | ||
{ | ||
ReqLogin() : BaseCommand(REQ_LOGIN_CMD, COMMAND_TYPE::OUTTER) | ||
{ | ||
memset(this, 0x0, sizeof(*this)); | ||
} | ||
char account[MAX_ACCOUNT_LEN]; | ||
}__attribute__ ((packed)); | ||
|
||
struct RtnLogin : BaseCommand | ||
{ | ||
RtnLogin() : BaseCommand(RTN_LOGIN_CMD, COMMAND_TYPE::OUTTER) | ||
{ | ||
res = 0; | ||
} | ||
int res; | ||
}__attribute__ ((packed)); | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* ===================================================================================== | ||
* | ||
* Filename: LoginProcess.cpp | ||
* | ||
* Description: Login Process | ||
* | ||
* Version: 1.0 | ||
* Created: 10/20/2015 11:38:24 AM | ||
* Revision: none | ||
* Compiler: gcc | ||
* | ||
* Author: huangyun (hy), [email protected] | ||
* Organization: | ||
* | ||
* ===================================================================================== | ||
*/ | ||
|
||
#include "LoginProcess.h" | ||
#include "LoginProcessCmd.h" | ||
#include "MySockTask.h" | ||
#include "MySockTaskManager.h" | ||
#include "LoginProcessCmd.h" | ||
|
||
namespace MyNameSpace | ||
{ | ||
bool LoginProcess::ReqLogin(const Command::BaseCommand *cmd, uint32_t len, int taskId) | ||
{ | ||
MySockTask* task = MySockTaskManager::getInstance().getTaskByIdWithOutLock(taskId); | ||
std::cout<<taskId<<std::endl; | ||
if (NULL != task) | ||
{ | ||
Command::RtnLogin rtn; | ||
rtn.res = 1; | ||
std::cout<<"return message! len:"<<sizeof(rtn)<<std::endl; | ||
task->sendDataWithBuffer(reinterpret_cast<const char *>(&rtn), sizeof(rtn)); | ||
} | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* ===================================================================================== | ||
* | ||
* Filename: LoginProcess.h | ||
* | ||
* Description: Login Process | ||
* | ||
* Version: 1.0 | ||
* Created: 10/20/2015 10:46:40 AM | ||
* Revision: none | ||
* Compiler: gcc | ||
* | ||
* Author: huangyun (hy), [email protected] | ||
* Organization: | ||
* | ||
* ===================================================================================== | ||
*/ | ||
|
||
|
||
#ifndef __LOGINPROCESS_H_ | ||
#define __LOGINPROCESS_H_ | ||
#include "BaseCmd.h" | ||
namespace MyNameSpace | ||
{ | ||
class LoginProcess | ||
{ | ||
public: | ||
LoginProcess() {} | ||
~LoginProcess() {} | ||
public: | ||
bool ReqLogin(const Command::BaseCommand *cmd, uint32_t len, int taskId); | ||
|
||
}; | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,24 @@ | ||
CXXFLAGS=-Wall -std=c++11 -g -Wparentheses -Wl,-rpath,../lib | ||
#CXXFLAGS=-Wall -std=c++11 -g -gstabs+ | ||
INCLUDE= -I../base -I../server -I../client -I../lib/tinyxml | ||
INCLUDE= -I../base -I../server -I../client -I../proto -I../lib/tinyxml | ||
LDFLAGS= -L../lib -lhyServer -L../lib -lhyClient -L../lib/tinyxml -ltinyxml | ||
.PHONY : all | ||
all : server | ||
server : main.o Server.o XmlconfigParse.o | ||
g++ $(CXXFLAGS) $(INCLUDE) main.o Server.o XmlconfigParse.o -o $@ $(LDFLAGS) | ||
server : main.o Server.o XmlconfigParse.o LoginProcess.o | ||
g++ $(CXXFLAGS) $(INCLUDE) main.o Server.o LoginProcess.o XmlconfigParse.o -o $@ $(LDFLAGS) | ||
main.o : main.cpp | ||
g++ $(CXXFLAGS) $(INCLUDE) -c $< -o $@ | ||
Server.o : Server.cpp Server.h | ||
g++ $(CXXFLAGS) $(INCLUDE) -c $< -o $@ | ||
|
||
XmlconfigParse.o : XmlconfigParse.cpp XmlconfigParse.h | ||
g++ $(CXXFLAGS) $(INCLUDE) -c $< -o $@ | ||
LoginProcess.o : LoginProcess.cpp LoginProcess.h | ||
g++ $(CXXFLAGS) $(INCLUDE) -c $< -o $@ | ||
|
||
clean: | ||
rm -rf server | ||
rm -rf Server.o | ||
rm -rf main.o | ||
rm -rf XmlconfigParse.o | ||
rm -rf LoginProcess.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.