comparison net/server_event.lua @ 14078:d649d011df45

Use util.time.now() consistently instead of socket.gettime()
author Link Mauve <linkmauve@linkmauve.fr>
date Fri, 30 Jan 2026 14:08:53 +0100
parents dae094b392d1
children 91afc1f07337
comparison
equal deleted inserted replaced
14077:c83aee2a0b11 14078:d649d011df45
52 local levent = require "luaevent.core" 52 local levent = require "luaevent.core"
53 local inet = require "prosody.util.net"; 53 local inet = require "prosody.util.net";
54 local inet_pton = inet.pton; 54 local inet_pton = inet.pton;
55 local sslconfig = require "prosody.util.sslconfig"; 55 local sslconfig = require "prosody.util.sslconfig";
56 local tls_impl = require "prosody.net.tls_luasec"; 56 local tls_impl = require "prosody.net.tls_luasec";
57 57 local time_now = require "prosody.util.time".now;
58 local socket_gettime = socket.gettime
59 58
60 local log = require ("prosody.util.logger").init("socket") 59 local log = require ("prosody.util.logger").init("socket")
61 60
62 local function debug(...) 61 local function debug(...)
63 return log("debug", ("%s "):rep(select('#', ...)), ...) 62 return log("debug", ("%s "):rep(select('#', ...)), ...)
519 local function handleclient( client, ip, port, server, pattern, listener, sslctx, extra ) -- creates an client interface 518 local function handleclient( client, ip, port, server, pattern, listener, sslctx, extra ) -- creates an client interface
520 --vdebug("creating client interfacce...") 519 --vdebug("creating client interfacce...")
521 local interface = { 520 local interface = {
522 type = "client"; 521 type = "client";
523 conn = client; 522 conn = client;
524 currenttime = socket_gettime( ); -- safe the origin 523 currenttime = time_now(); -- safe the origin
525 writebuffer = {}; -- writebuffer 524 writebuffer = {}; -- writebuffer
526 writebufferlen = 0; -- length of writebuffer 525 writebufferlen = 0; -- length of writebuffer
527 send = client.send; -- caching table lookups 526 send = client.send; -- caching table lookups
528 receive = client.receive; 527 receive = client.receive;
529 onconnect = listener.onconnect; -- will be called when client disconnects 528 onconnect = listener.onconnect; -- will be called when client disconnects
916 end 915 end
917 916
918 local function add_task(delay, callback) 917 local function add_task(delay, callback)
919 local event_handle; 918 local event_handle;
920 event_handle = base:addevent(nil, 0, function () 919 event_handle = base:addevent(nil, 0, function ()
921 local ret = callback(socket_gettime()); 920 local ret = callback(time_now());
922 if ret then 921 if ret then
923 return 0, ret; 922 return 0, ret;
924 elseif event_handle then 923 elseif event_handle then
925 return -1; 924 return -1;
926 end 925 end