Skip to content

Commit

Permalink
Delete all commands with greater or equal tag
Browse files Browse the repository at this point in the history
Do not test for an exact tag value, use >= test.
  • Loading branch information
dnk777 committed Jul 17, 2017
1 parent 3aa1e6e commit dcd15fb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/protocol_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ GenericClientProtocolExecutor::GenericClientProtocolExecutor( Client *client_,

typedef GenericClientProtocolExecutor GPTE;

// Register persistent server commands

serverCommandHandlers.Register( "challenge", &GPTE::ServerCommand_Challenge );
serverCommandHandlers.Register( "client_connect", &GPTE::ServerCommand_ClientConnect );
serverCommandHandlers.Register( "cs", &GPTE::ServerCommand_Cs );
Expand Down Expand Up @@ -71,13 +73,15 @@ GenericClientProtocolExecutor::GenericClientProtocolExecutor( Client *client_,
serverCommandHandlers.Register( "aw", nullptr );
serverCommandHandlers.Register( "qm", nullptr );

serverCommandHandlers.NewGenerationTag();

serverCommandHandlers.Register( "dstart", nullptr );
serverCommandHandlers.Register( "dstop", nullptr );
serverCommandHandlers.Register( "dcancel", nullptr );
serverCommandHandlers.Register( "cpc", nullptr );
serverCommandHandlers.Register( "cpa", nullptr );

serverCommandHandlers.NewGenerationTag();
// Register persistent client commands

clientCommandHandlers.Register( "connect", &GPTE::Command_Connect );
clientCommandHandlers.Register( "disconnect", &GPTE::Command_Disconnect );
Expand Down Expand Up @@ -399,7 +403,7 @@ void CommandHandlersRegistry::Clear( unsigned tag ) {

// TODO: Start from the last?
while( i < numHandlers ) {
if( handlers[i].tag == tag ) {
if( handlers[i].tag >= tag ) {
handlers[i] = handlers[numHandlers - 1];
numHandlers--;
} else {
Expand Down

0 comments on commit dcd15fb

Please sign in to comment.