Skip to content

Commit

Permalink
adjustments, +3
Browse files Browse the repository at this point in the history
  • Loading branch information
levb committed Nov 3, 2024
1 parent 541e2ea commit 11be61c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/micro.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,19 +394,17 @@ void micro_release_endpoint_when_unsubscribed(void *closure)
if ((m == NULL) || (m->service_mu == NULL))
return;

_lock_service(m);
micro_lock_endpoint(ep);

_detach_endpoint_from_service(m, ep);
sub = ep->sub;
ep->sub = NULL; // Force the subscription to be destroyed now, so NULL out the pointer to avoid a double free.
refs = --(ep->refs);
micro_unlock_endpoint(ep);

natsSubscription_Destroy(sub);
natsSubscription_Destroy(sub); // <>/<> do I need this hack?

// If this is the last endpoint, we need to notify the service's done
// callback.
_lock_service(m);

_detach_endpoint_from_service(m, ep);
if (refs == 0)
micro_free_endpoint(ep);
if (m->numEndpoints == 0)
Expand Down

0 comments on commit 11be61c

Please sign in to comment.