Skip to content

Commit

Permalink
wip, +18
Browse files Browse the repository at this point in the history
  • Loading branch information
levb committed Oct 9, 2024
1 parent c4869e0 commit 139d66a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/micro.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,12 @@ void micro_release_on_endpoint_complete(void *closure)
micro_lock_endpoint(ep);
ep->is_draining = false;
sub = ep->sub;
// ep->sub = NULL;
ep->sub = NULL; // Force the subscription to be destroyed now, so NULL out the pointer to avoid a double free.
ep->refs--;
destroyEndpoint = (ep->refs == 0);
micro_unlock_endpoint(ep);

// Force the subscription to be destroyed now.
// natsSubscription_Destroy(sub);

natsSubscription_Destroy(sub);

_lock_service(m);

Expand Down
2 changes: 1 addition & 1 deletion src/sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ _freeSub(natsSubscription *sub)
_freeControlMessages(sub);
_cleanupOwnDispatcher(sub);

NATS_FREE(sub->subject);
NATS_FREE(sub->queue);

natsCondition_Destroy(sub->drainCond);
Expand All @@ -124,6 +123,7 @@ _freeSub(natsSubscription *sub)
natsConn_release(sub->conn);

printf("<>/<> Freeing subscription %s\n", sub->subject);
NATS_FREE(sub->subject);
NATS_FREE(sub);
}

Expand Down

0 comments on commit 139d66a

Please sign in to comment.