Skip to content

Commit

Permalink
Enabled logging, moved some code
Browse files Browse the repository at this point in the history
  • Loading branch information
diefbell-grabcad committed Nov 22, 2024
1 parent 1c0ccf9 commit bf399d5
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include <iostream>
#include "nan.h"

// #define DEBUG
#define DEBUG
#ifdef DEBUG
#define LOG(msg) std::cout << "[ZeroMQ.js] " << msg << std::endl;
#else
Expand Down Expand Up @@ -271,13 +271,6 @@ namespace zmq {

if(instance) {
LOG("Trying to clean up context with " + std::to_string(instance->sockets_.size()) + " socket(s)...");
for(auto it = instance->sockets_.begin(); it != instance->sockets_.end(); it++) {
LOG("\tTrying to clean up socket...")
Socket* socket = *it;
delete socket;
LOG("\tSocket cleaned up during environment shutdown");
}

delete instance;
LOG("Context cleaned up during environment shutdown\n");
}
Expand All @@ -298,6 +291,14 @@ namespace zmq {

void
Context::Close() {
for(auto it = sockets_.begin(); it != sockets_.end(); it++) {
LOG("\tTrying to clean up socket...")
Socket* socket = *it;
UnregisterSocket(socket);
delete socket;
LOG("\tSocket cleaned up during environment shutdown");
}

if (context_ != NULL) {
if (zmq_term(context_) < 0) {
Nan::ThrowError(ErrorMessage());
Expand Down Expand Up @@ -1415,7 +1416,9 @@ namespace zmq {
if(!context_.IsEmpty()) {
v8::Local<v8::Object> obj = Nan::New(context_);
Context* context = Nan::ObjectWrap::Unwrap<Context>(obj);
context->UnregisterSocket(this);
if(context) {
context->UnregisterSocket(this);
}
}

context_.Reset();
Expand Down

0 comments on commit bf399d5

Please sign in to comment.