diff --git a/src/ctx.cpp b/src/ctx.cpp index f7b432a0..a06f3624 100644 --- a/src/ctx.cpp +++ b/src/ctx.cpp @@ -35,6 +35,10 @@ #include "err.hpp" #include "msg.hpp" +#ifdef HAVE_LIBSODIUM +#include +#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; }