Module: kamailio
Branch: master
Commit: 1ed6671c802e525046ca56008bdc3d52f2bbd46d
URL: 
https://github.com/kamailio/kamailio/commit/1ed6671c802e525046ca56008bdc3d52f2bbd46d

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2025-02-05T09:30:55+01:00

websocket: use helper function to get signed int time

---

Modified: src/modules/websocket/ws_conn.c
Modified: src/modules/websocket/ws_frame.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/1ed6671c802e525046ca56008bdc3d52f2bbd46d.diff
Patch: 
https://github.com/kamailio/kamailio/commit/1ed6671c802e525046ca56008bdc3d52f2bbd46d.patch

---

diff --git a/src/modules/websocket/ws_conn.c b/src/modules/websocket/ws_conn.c
index b41cb2e91d9..9fa3125343c 100644
--- a/src/modules/websocket/ws_conn.c
+++ b/src/modules/websocket/ws_conn.c
@@ -28,6 +28,7 @@
 
 #include "../../core/locking.h"
 #include "../../core/str.h"
+#include "../../core/ut.h"
 #include "../../core/tcp_conn.h"
 #include "../../core/fmsg.h"
 #include "../../core/counters.h"
@@ -219,7 +220,7 @@ int wsconn_add(struct receive_info *rcv, unsigned int 
sub_protocol)
        wsconn_listadd(wsconn_id_hash[wsc->id_hash], wsc, id_next, id_prev);
 
        /* Add to the end of the WebSocket used list */
-       wsc->last_used = (int)time(NULL);
+       wsc->last_used = ksr_time_sint(NULL, NULL);
        if(wsconn_used_list->head == NULL)
                wsconn_used_list->head = wsconn_used_list->tail = wsc;
        else {
@@ -358,7 +359,7 @@ int wsconn_update(ws_connection_t *wsc)
        }
 
        WSCONN_LOCK;
-       wsc->last_used = (int)time(NULL);
+       wsc->last_used = ksr_time_sint(NULL, NULL);
        if(wsconn_used_list->tail == wsc)
                /* Already at the end of the list */
                goto end;
@@ -742,7 +743,7 @@ static int ws_rpc_add_node(
 
                pong = wsc->awaiting_pong ? "awaiting Pong, " : "";
 
-               interval = (int)time(NULL) - wsc->last_used;
+               interval = ksr_time_sint(NULL, NULL) - wsc->last_used;
                if(wsc->sub_protocol == SUB_PROTOCOL_SIP)
                        sub_protocol = "sip";
                else if(wsc->sub_protocol == SUB_PROTOCOL_MSRP)
diff --git a/src/modules/websocket/ws_frame.c b/src/modules/websocket/ws_frame.c
index 04a4132f13d..e7e97b40ce4 100644
--- a/src/modules/websocket/ws_frame.c
+++ b/src/modules/websocket/ws_frame.c
@@ -37,6 +37,7 @@
 #include "../../core/events.h"
 #include "../../core/receive.h"
 #include "../../core/str.h"
+#include "../../core/ut.h"
 #include "../../core/tcp_conn.h"
 #include "../../core/tcp_read.h"
 #include "../../core/tcp_server.h"
@@ -796,8 +797,8 @@ static int ws_send_crlf(ws_connection_t *wsc, int opcode)
 
 void ws_keepalive(unsigned int ticks, void *param)
 {
-       int check_time =
-                       (int)time(NULL) - cfg_get(websocket, ws_cfg, 
keepalive_timeout);
+       int check_time = ksr_time_sint(NULL, NULL)
+                                        - cfg_get(websocket, ws_cfg, 
keepalive_timeout);
 
        ws_connection_id_t *list_head = NULL;
        ws_connection_t *wsc = NULL;

_______________________________________________
Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to