Skip to content

Commit

Permalink
wip ++4
Browse files Browse the repository at this point in the history
  • Loading branch information
levb committed Oct 30, 2024
1 parent 91b8cc1 commit 4c9a566
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/micro.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ void micro_release_endpoint_when_unsubscribed(void *closure)
microEndpoint *ep = (microEndpoint *)closure;
microService *m = NULL;
natsSubscription *sub = NULL;
natsConnection *nc = NULL;
microDoneHandler doneHandler = NULL;
int refs = 0;

Expand All @@ -307,23 +308,27 @@ void micro_release_endpoint_when_unsubscribed(void *closure)
// If this is the last endpoint, we need to notify the service's done
// callback.
_lock_service(m);

m->numEndpoints--;
// <>/<> TODO Remove ep from m's list

if (refs == 0)
micro_free_endpoint(ep);

m->numEndpoints--;
if (m->numEndpoints == 0)
{
m->stopped = true;
doneHandler = m->cfg->DoneHandler;
}
refs = m->refs;
nc = m->nc;
_unlock_service(m);

if (doneHandler != NULL)
{
printf("<>/<> micro_release_endpoint_when_unsubscribed %s last in service, DONE\n", sub->subject);
doneHandler(m);
natsConn_removeService(m->nc, m);
natsConn_removeService(nc, m);

if (refs == 0)
_free_service(m);
Expand Down

0 comments on commit 4c9a566

Please sign in to comment.