Skip to content

Commit

Permalink
wip more +2
Browse files Browse the repository at this point in the history
  • Loading branch information
levb committed Oct 9, 2024
1 parent 4b46cf1 commit 82fde85
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 10 deletions.
9 changes: 1 addition & 8 deletions src/micro.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ void micro_release_on_endpoint_complete(void *closure)
microService *m = NULL;
natsSubscription *sub = NULL;
microDoneHandler doneHandler = NULL;
bool destroyEndpoint = false;
bool finalize = false;

if (ep == NULL)
Expand All @@ -323,15 +322,10 @@ void micro_release_on_endpoint_complete(void *closure)
if ((m == NULL) || (m->service_mu == NULL))
return;


micro_lock_endpoint(ep);
ep->is_draining = false;
sub = ep->sub;
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);

natsSubscription_Destroy(sub);

_lock_service(m);
Expand Down Expand Up @@ -363,8 +357,7 @@ void micro_release_on_endpoint_complete(void *closure)

_unlock_service(m);

if (destroyEndpoint)
micro_destroy_endpoint(ep);
micro_release_endpoint(ep);

if (finalize)
{
Expand Down
1 change: 0 additions & 1 deletion src/micro_endpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ micro_subscribe_endpoint(microEndpoint *ep)
micro_lock_endpoint(ep);
ep->refs++;
ep->sub = sub;
ep->is_draining = false;
micro_unlock_endpoint(ep);

natsSubscription_SetOnCompleteCB(sub, micro_release_on_endpoint_complete, ep);
Expand Down
1 change: 0 additions & 1 deletion src/microp.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ struct micro_endpoint_s
// Mutex for starting/stopping the endpoint, and for updating the stats.
natsMutex *endpoint_mu;
int refs;
bool is_draining;

// The subscription for the endpoint. If NULL, the endpoint is stopped.
natsSubscription *sub;
Expand Down

0 comments on commit 82fde85

Please sign in to comment.