Commit d8430f4b authored by Martin Sustrik's avatar Martin Sustrik

Multi-hop REQ/REP, part IV., add command deallocation mechanism

parent 313b5dfa
......@@ -125,6 +125,7 @@ libzmq_la_SOURCES = app_thread.hpp \
zmq_init.hpp \
zmq_listener.hpp \
app_thread.cpp \
command.cpp \
devpoll.cpp \
dispatcher.cpp \
downstream.cpp \
......
/*
Copyright (c) 2007-2010 iMatix Corporation
This file is part of 0MQ.
0MQ is free software; you can redistribute it and/or modify it under
the terms of the Lesser GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
0MQ is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Lesser GNU General Public License for more details.
You should have received a copy of the Lesser GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "command.hpp"
void zmq::deallocate_command (command_t *cmd_)
{
}
......@@ -107,6 +107,9 @@ namespace zmq
} args;
};
// Function to deallocate dynamically allocated components of the command.
void deallocate_command (command_t *cmd_);
}
#endif
......@@ -117,6 +117,10 @@ zmq::dispatcher_t::~dispatcher_t ()
while (!pipes.empty ())
delete *pipes.begin ();
// TODO: Deallocate any commands still in the pipes. Keep in mind that
// simple reading from a pipe and deallocating commands won't do as
// command pipe has template parameter D set to true, meaning that
// read may return false even if there are still commands in the pipe.
delete [] command_pipes;
#ifdef ZMQ_HAVE_WINDOWS
......
......@@ -77,17 +77,17 @@ void zmq::object_t::process_command (command_t &cmd_)
case command_t::own:
process_own (cmd_.args.own.object);
return;
break;
case command_t::attach:
process_attach (cmd_.args.attach.engine);
process_seqnum ();
return;
break;
case command_t::bind:
process_bind (cmd_.args.bind.in_pipe, cmd_.args.bind.out_pipe);
process_seqnum ();
return;
break;
case command_t::pipe_term:
process_pipe_term ();
......@@ -95,23 +95,27 @@ void zmq::object_t::process_command (command_t &cmd_)
case command_t::pipe_term_ack:
process_pipe_term_ack ();
return;
break;
case command_t::term_req:
process_term_req (cmd_.args.term_req.object);
return;
break;
case command_t::term:
process_term ();
return;
break;
case command_t::term_ack:
process_term_ack ();
return;
break;
default:
zmq_assert (false);
}
// The assumption here is that each command is processed once only,
// so deallocating it after processing is all right.
deallocate_command (&cmd_);
}
void zmq::object_t::register_pipe (class pipe_t *pipe_)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment