refactor: move times API to utils.h

This commit is contained in:
luwenpeng
2024-08-16 10:19:36 +08:00
parent 5c0a40638c
commit bfa5564558
9 changed files with 34 additions and 143 deletions

View File

@@ -10,7 +10,7 @@
#include "log.h"
#include "logo.h"
#include "times.h"
#include "utils.h"
#include "packet_io.h"
#include "packet_def.h"
#include "packet_utils.h"
@@ -209,7 +209,7 @@ static void *work_thread(void *arg)
* Note: Modifying the system time will affect the timing wheel, impacting session expiration, IP reassembly expiration, and TCP reassembly expiration.
* Suggestion: After modifying the system time, restart the service to ensure consistent timing.
*/
now_ms = stellar_get_real_time_msec();
now_ms = clock_get_real_time_ms();
nr_recv = packet_io_ingress(packet_io, thr_idx, packets, RX_BURST_MAX);
if (nr_recv == 0)
{
@@ -398,7 +398,7 @@ static int all_session_have_freed(struct stellar_runtime *runtime, struct stella
static int stellar_thread_init(struct stellar_runtime *runtime, struct stellar_config *config)
{
uint64_t now_ms = stellar_get_real_time_msec();
uint64_t now_ms = clock_get_real_time_ms();
for (uint16_t i = 0; i < config->pkt_io_opts.nr_threads; i++)
{
struct stellar_thread *thread = &runtime->threads[i];
@@ -543,12 +543,12 @@ int stellar_run(int argc __attribute__((unused)), char **argv __attribute__((unu
goto error_out;
}
runtime->stat_last_output_ts = stellar_get_real_time_msec();
runtime->stat_last_output_ts = clock_get_real_time_ms();
while (!ATOMIC_READ(&need_exit))
{
if (stellar_get_real_time_msec() - runtime->stat_last_output_ts > config->sched_opts.output_stat_interval)
if (clock_get_real_time_ms() - runtime->stat_last_output_ts > config->sched_opts.output_stat_interval)
{
runtime->stat_last_output_ts = stellar_get_real_time_msec();
runtime->stat_last_output_ts = clock_get_real_time_ms();
stellar_stat_output(runtime->stat);
}
usleep(1000); // 1ms