Problem: leaks on send_zap_request fail, use of goto idiom is fragile.

This commit is contained in:
evoskuil
2017-03-29 16:48:40 -07:00
parent 29a5c98d83
commit a014e77ef7
5 changed files with 91 additions and 96 deletions

View File

@@ -34,6 +34,7 @@
#include <stdio.h>
#include "config.hpp"
#include "err.hpp"
#include "fd.hpp"
#include "atomic_counter.hpp"
#include "metadata.hpp"
@@ -246,6 +247,20 @@ namespace zmq
} u;
};
inline int send_failure (zmq::msg_t *msg)
{
const int rc = msg->close ();
errno_assert (rc == 0);
return -1;
}
inline int send_failure (zmq::msg_t msg[], int count)
{
for (int i = 0; i < count; i++)
send_failure (&msg [i]);
return -1;
}
}
#endif