0
0
mirror of https://github.com/zeromq/libzmq.git synced 2025-01-15 18:38:00 +08:00

Merge pull request #91 from jbreams/master

Clean up after using randombytes from libsodium
This commit is contained in:
Pieter Hintjens 2014-09-01 09:22:01 +02:00
commit 88e56365ef

View File

@ -35,6 +35,10 @@
#include "err.hpp"
#include "msg.hpp"
#ifdef HAVE_LIBSODIUM
#include <sodium.h>
#endif
#define ZMQ_CTX_TAG_VALUE_GOOD 0xabadcafe
#define ZMQ_CTX_TAG_VALUE_BAD 0xdeadbeef
@ -89,6 +93,12 @@ zmq::ctx_t::~ctx_t ()
// corresponding io_thread/socket objects.
free (slots);
// If we've done any Curve encryption, we may have a file handle
// to /dev/urandom open that needs to be cleaned up.
#ifdef HAVE_LIBSODIUM
randombytes_close();
#endif
// Remove the tag, so that the object is considered dead.
tag = ZMQ_CTX_TAG_VALUE_BAD;
}