Module: kamailio
Branch: master
Commit: 94eb9fed8b1d4a0aaaf76506e339f2d6a9e34e7d
URL:
https://github.com/kamailio/kamailio/commit/94eb9fed8b1d4a0aaaf76506e339f2d…
Author: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Committer: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Date: 2020-05-12T16:45:23+02:00
keepalive: use ctime_r() for a safer multi-thread usage
---
Modified: src/modules/keepalive/keepalive_rpc.c
---
Diff:
https://github.com/kamailio/kamailio/commit/94eb9fed8b1d4a0aaaf76506e339f2d…
Patch:
https://github.com/kamailio/kamailio/commit/94eb9fed8b1d4a0aaaf76506e339f2d…
---
diff --git a/src/modules/keepalive/keepalive_rpc.c
b/src/modules/keepalive/keepalive_rpc.c
index 3a72b31474..e6a64dbcd1 100644
--- a/src/modules/keepalive/keepalive_rpc.c
+++ b/src/modules/keepalive/keepalive_rpc.c
@@ -78,24 +78,19 @@ static void keepalive_rpc_list(rpc_t *rpc, void *ctx)
{
void *sub;
ka_dest_t *dest;
- char *_ctime;
- char *_utime;
- char *_dtime;
+ char t_buf[26] = {0};
for(dest = ka_destinations_list->first; dest != NULL; dest = dest->next) {
rpc->add(ctx, "{", &sub);
rpc->struct_add(sub, "SS", "uri", &dest->uri,
"owner", &dest->owner);
- _ctime = ctime(&dest->last_checked);
- _ctime[strlen(_ctime) - 1] = '\0';
- rpc->struct_add(sub, "s", "last checked", _ctime);
- _utime = ctime(&dest->last_up);
- _utime[strlen(_utime) - 1] = '\0';
- rpc->struct_add(sub, "s", "last up", _utime);
- _dtime = ctime(&dest->last_down);
- _dtime[strlen(_dtime) - 1] = '\0';
- rpc->struct_add(sub, "s", "last down", _dtime);
+ ctime_r(&dest->last_checked, t_buf);
+ rpc->struct_add(sub, "s", "last checked", t_buf);
+ ctime_r(&dest->last_up, t_buf);
+ rpc->struct_add(sub, "s", "last up", t_buf);
+ ctime_r(&dest->last_down, t_buf);
+ rpc->struct_add(sub, "s", "last down", t_buf);
rpc->struct_add(sub, "d", "state", (int) dest->state);
}