Reset metadata for outbound messages

This commit is contained in:
Martin Hurton 2014-08-13 08:51:13 +02:00
parent 25de6a03ac
commit a54d8d7b0c
3 changed files with 12 additions and 0 deletions

View File

@ -288,6 +288,15 @@ void zmq::msg_t::set_metadata (zmq::metadata_t *metadata_)
u.base.metadata = metadata_;
}
void zmq::msg_t::reset_metadata ()
{
if (u.base.metadata) {
if (u.base.metadata->drop_ref ())
delete u.base.metadata;
u.base.metadata = NULL;
}
}
bool zmq::msg_t::is_identity () const
{
return (u.base.flags & identity) == identity;

View File

@ -73,6 +73,7 @@ namespace zmq
void set_fd (int64_t fd_);
metadata_t *metadata () const;
void set_metadata (metadata_t *metadata_);
void reset_metadata ();
bool is_identity () const;
bool is_credential () const;
bool is_delimiter () const;

View File

@ -799,6 +799,8 @@ int zmq::socket_base_t::send (msg_t *msg_, int flags_)
if (flags_ & ZMQ_SNDMORE)
msg_->set_flags (msg_t::more);
msg_->reset_metadata ();
// Try to send the message.
rc = xsend (msg_);
if (rc == 0)