Skip to content

Commit

Permalink
Update rtrouteBase.c
Browse files Browse the repository at this point in the history
  • Loading branch information
NetajiPanigrahi authored Nov 18, 2024
1 parent 50886df commit 9cc37f6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/rtmessage/rtrouteBase.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,17 @@ rtRouteBase_BindListener(char const* socket_name, int no_delay, int indefinite_r
unsigned int num_retries = 1;

listener = (rtListener *)rt_malloc(sizeof(rtListener));
if (!listener)
return rtErrorFromErrno(ENOMEM);
listener->fd = -1;
memset(&listener->local_endpoint, 0, sizeof(struct sockaddr_storage));

err = rtSocketStorage_FromString(&listener->local_endpoint, socket_name);
if (err != RT_OK)
return err;
{
free(listener);
return err;
}

rtLog_Debug("binding listener:%s", socket_name);

Expand Down Expand Up @@ -130,7 +135,7 @@ rtRouteBase_BindListener(char const* socket_name, int no_delay, int indefinite_r
{
rtLog_Warn("failed to set socket to listen mode. %s", rtStrError(errno));
rtRouteBase_CloseListener(listener);
free(listener);
free(listener);
return RT_FAIL;
}

Expand Down Expand Up @@ -577,6 +582,8 @@ rtRouteDirect_StartInstance(const char* socket_name, rtDriectClientHandler messa
}

route = (rtRouteEntry *)rt_malloc(sizeof(rtRouteEntry));
if (!route)
return rtErrorFromErrno(ENOMEM);
route->subscription = NULL;
strncpy(route->expression, "_RTDIRECT>", RTMSG_MAX_EXPRESSION_LEN-1);
route->message_handler = _rtdirect_OnMessage;
Expand Down

0 comments on commit 9cc37f6

Please sign in to comment.