Module: kamailio
Branch: master
Commit: 3dc960b6db3dc5807814fc73887f985bf2ff91d7
URL: https://github.com/kamailio/kamailio/commit/3dc960b6db3dc5807814fc73887f985…
Author: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Committer: Victor Seva <linuxmaniac(a)torreviejawireless.org>
Date: 2020-05-12T14:38:43+02:00
xprint: use ctime_r() for a safer multi-thread usage
> The reentrant version ctime_r() does the same, but stores
> the string in a user-supplied buffer which should have
> room for at least 26 bytes.
---
Modified: src/modules/xprint/xp_lib.c
---
Diff: https://github.com/kamailio/kamailio/commit/3dc960b6db3dc5807814fc73887f985…
Patch: https://github.com/kamailio/kamailio/commit/3dc960b6db3dc5807814fc73887f985…
---
diff --git a/src/modules/xprint/xp_lib.c b/src/modules/xprint/xp_lib.c
index bbe2ceaafe..5771b77399 100644
--- a/src/modules/xprint/xp_lib.c
+++ b/src/modules/xprint/xp_lib.c
@@ -164,7 +164,7 @@ static int xl_get_times(struct sip_msg *msg, str *res, str *hp, int hi, int hf)
}
static int xl_get_timef(struct sip_msg *msg, str *res, str *hp, int hi, int hf)
{
- char *ch = NULL;
+ char ch[26] = {0};
if(msg==NULL || res==NULL)
return -1;
@@ -174,7 +174,7 @@ static int xl_get_timef(struct sip_msg *msg, str *res, str *hp, int hi, int hf)
msg_id = msg->id;
}
- ch = ctime(&msg_tm);
+ ctime_r(&msg_tm, ch);
res->s = ch;
res->len = strlen(ch)-1;
Module: kamailio
Branch: master
Commit: 90275e02faf75454026597c1e720487b5d845f79
URL: https://github.com/kamailio/kamailio/commit/90275e02faf75454026597c1e720487…
Author: Kamailio Dev <kamailio.dev(a)kamailio.org>
Committer: Kamailio Dev <kamailio.dev(a)kamailio.org>
Date: 2020-05-12T14:16:12+02:00
modules: readme files regenerated - keepalive ... [skip ci]
---
Modified: src/modules/keepalive/README
---
Diff: https://github.com/kamailio/kamailio/commit/90275e02faf75454026597c1e720487…
Patch: https://github.com/kamailio/kamailio/commit/90275e02faf75454026597c1e720487…
---
diff --git a/src/modules/keepalive/README b/src/modules/keepalive/README
index 4437803128..f69641e421 100644
--- a/src/modules/keepalive/README
+++ b/src/modules/keepalive/README
@@ -56,7 +56,7 @@ Yasin CANER
1. Available Functions
1.1. add_destination(uri, owner, flags, ping_interval,
- [callback, [user_attr]])
+ [statechanged_clb, response_clb, [user_attr]])
1.2. Examples
@@ -324,8 +324,8 @@ Chapter 2. Developer Guide
1. Available Functions
- 1.1. add_destination(uri, owner, flags, ping_interval, [callback,
- [user_attr]])
+ 1.1. add_destination(uri, owner, flags, ping_interval,
+ [statechanged_clb, response_clb, [user_attr]])
1.2. Examples
@@ -338,13 +338,13 @@ Chapter 2. Developer Guide
1. Available Functions
- 1.1. add_destination(uri, owner, flags, ping_interval, [callback,
- [user_attr]])
+ 1.1. add_destination(uri, owner, flags, ping_interval,
+ [statechanged_clb, response_clb, [user_attr]])
1.2. Examples
-1.1. add_destination(uri, owner, flags, ping_interval, [callback,
-[user_attr]])
+1.1. add_destination(uri, owner, flags, ping_interval, [statechanged_clb,
+response_clb, [user_attr]])
This function registers a new destination to monitor. Monitoring of the
destination starts as soon as it returns with success (0 value).
@@ -361,7 +361,7 @@ Chapter 2. Developer Guide
* flags (integer) - destination flags (unused for now, use 0 value)
* ping_interval (integer) - Pinging interval in seconds for this
destination
- * callback (ka_statechanged_f, optional) - callback function,
+ * statechanged_clb (ka_statechanged_f, optional) - callback function,
executed on destination's state change.
The callback function is of type void (*ka_statechanged_f)(str
*uri, int state, void *user_attr);. Use NULL to set no callback.
@@ -370,9 +370,17 @@ Chapter 2. Developer Guide
waiting first ping replies or timeout)
+ 1 - destination is UP
+ 2 - destination is DOWN
- * user_attr (void * pointer, optional) - If callback function is
- setup, this parameter will be forwarded to it, as last parameter.
- Use NULL to set no user_attr parameter.
+ * response_clb (ka_response_f, optional) - callback function,
+ executed on destination's response provided.
+ The callback function is of type void (*ka_response_f)(str *uri,
+ struct tmcb_params *ps, void *user_attr);. Use NULL to set no
+ callback.
+ ps is a pack structure with all params passed to callback function.
+ Defined in t_hooks.h
+ * user_attr (void * pointer, optional) - If any callback function is
+ setup, this parameter will be forwarded to it (or both callbacks in
+ both are defined), as last parameter. Use NULL to set no user_attr
+ parameter.
Returned values:
* 0 if ok
@@ -395,17 +403,18 @@ if (bind_keepalive( &ka_api ) != 0) {
}
...
...
-/* callback function */
-void my_callback(str uri, int state, void *user_attr) {
-
+/* callback function (on state changed) */
+void my_state_changed_clb(str uri, int state, void *user_attr) {
printf("%.*s new state is: %d\n", uri.len, uri.str, state)
}
-/* register a new destination */
-str dest = str_init("sip:192.168.10.21:5060");
-str owner = str_init("mymodule");
+/* callback function (on each response received) */
+void my_response_clb(str *uri, struct tmcb_params *ps, void *user_attr) {
+ printf("response [%d] from %.*s\n", ps->code, uri.len, uri.str)
+}
-if (ka_api.add_destination(dest, owner, 0, 60, my_callback, NULL) != 0) {
+if (ka_api.add_destination(dest, owner, 0, 60, my_state_changed_clb,
+ my_response_clb, NULL) != 0) {
LM_ERR("can't add destination\n");
goto error;
}
#### Pre-Submission Checklist
<!-- If you're unsure about any of these, don't hesitate to ask on sr-dev mailing list -->
- [x] Commit message has the format required by CONTRIBUTING guide
- [x] Commits are split per component (core, individual modules, libs, utils, ...)
- [x] Each component has a single commit (if not, squash them into one commit)
- [x] No commits to README files for modules (changes must be done to docbook files
in `doc/` subfolder, the README file is autogenerated)
#### Type Of Change
- [ ] Small bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds new functionality)
- [ ] Breaking change (fix or feature that would change existing functionality)
#### Checklist:
- [ ] PR should be backported to stable branches
- [x] Tested changes locally
- [ ] Related to issue #XXXX (replace XXXX with an open issue number)
#### Description
Expose current state of keepalive monitor in rpc response so that the response can be parsed easlily and used to populate external dashboards
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/2323
-- Commit Summary --
* keepalive: update rpc response
-- File Changes --
M src/modules/keepalive/keepalive_rpc.c (2)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/2323.patchhttps://github.com/kamailio/kamailio/pull/2323.diff
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/2323