mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
lws_time_in_microseconds: export
Rename time_in_microseconds() and export the internal api as lws_time_in_microseconds()
This commit is contained in:
parent
d702b83d10
commit
da444d04d1
15 changed files with 29 additions and 22 deletions
|
@ -70,6 +70,12 @@ enum pending_timeout {
|
|||
PENDING_TIMEOUT_USER_REASON_BASE = 1000
|
||||
};
|
||||
|
||||
/**
|
||||
* lws_time_in_microseconds() - Returns the unix time in microseconds
|
||||
*/
|
||||
LWS_VISIBLE LWS_EXTERN uint64_t
|
||||
lws_time_in_microseconds(void);
|
||||
|
||||
#define LWS_TO_KILL_ASYNC -1
|
||||
/**< If LWS_TO_KILL_ASYNC is given as the timeout sec in a lws_set_timeout()
|
||||
* call, then the connection is marked to be killed at the next timeout
|
||||
|
|
|
@ -1641,7 +1641,7 @@ lws_latency(struct lws_context *context, struct lws *wsi, const char *action,
|
|||
unsigned long long u;
|
||||
char buf[256];
|
||||
|
||||
u = time_in_microseconds();
|
||||
u = lws_time_in_microseconds();
|
||||
|
||||
if (!action) {
|
||||
wsi->latency_start = u;
|
||||
|
@ -2022,7 +2022,7 @@ lwsl_timestamp(int level, char *p, int len)
|
|||
for (n = 0; n < LLL_COUNT; n++) {
|
||||
if (level != (1 << n))
|
||||
continue;
|
||||
now = time_in_microseconds() / 100;
|
||||
now = lws_time_in_microseconds() / 100;
|
||||
if (ptm)
|
||||
n = lws_snprintf(p, len,
|
||||
"[%04d/%02d/%02d %02d:%02d:%02d:%04d] %s: ",
|
||||
|
|
|
@ -434,7 +434,7 @@ lws_callback_on_writable(struct lws *wsi)
|
|||
lws_stats_atomic_bump(wsi->context, pt, LWSSTATS_C_WRITEABLE_CB_REQ, 1);
|
||||
#if defined(LWS_WITH_STATS)
|
||||
if (!wsi->active_writable_req_us) {
|
||||
wsi->active_writable_req_us = time_in_microseconds();
|
||||
wsi->active_writable_req_us = lws_time_in_microseconds();
|
||||
lws_stats_atomic_bump(wsi->context, pt,
|
||||
LWSSTATS_C_WRITEABLE_CB_EFF_REQ, 1);
|
||||
}
|
||||
|
|
|
@ -1442,8 +1442,6 @@ lws_plat_init(struct lws_context *context,
|
|||
const struct lws_context_creation_info *info);
|
||||
LWS_EXTERN void
|
||||
lws_plat_drop_app_privileges(const struct lws_context_creation_info *info);
|
||||
LWS_EXTERN unsigned long long
|
||||
time_in_microseconds(void);
|
||||
LWS_EXTERN const char * LWS_WARN_UNUSED_RESULT
|
||||
lws_plat_inet_ntop(int af, const void *src, char *dst, int cnt);
|
||||
LWS_EXTERN int LWS_WARN_UNUSED_RESULT
|
||||
|
|
|
@ -30,7 +30,7 @@ lws_callback_as_writeable(struct lws *wsi)
|
|||
lws_stats_atomic_bump(wsi->context, pt, LWSSTATS_C_WRITEABLE_CB, 1);
|
||||
#if defined(LWS_WITH_STATS)
|
||||
if (wsi->active_writable_req_us) {
|
||||
uint64_t ul = time_in_microseconds() -
|
||||
uint64_t ul = lws_time_in_microseconds() -
|
||||
wsi->active_writable_req_us;
|
||||
|
||||
lws_stats_atomic_bump(wsi->context, pt,
|
||||
|
|
|
@ -261,7 +261,7 @@ get_txt_param(const mdns_result_t *mr, const char *param, char *result, int len)
|
|||
|
||||
static void lws_esp32_mdns_timer_cb(TimerHandle_t th)
|
||||
{
|
||||
uint64_t now = time_in_microseconds();
|
||||
uint64_t now = lws_time_in_microseconds();
|
||||
struct lws_group_member *p, **p1;
|
||||
const mdns_result_t *r = mdns_results_head;
|
||||
|
||||
|
@ -484,7 +484,7 @@ passthru:
|
|||
static void
|
||||
lws_set_genled(int n)
|
||||
{
|
||||
lws_esp32.genled_t = time_in_microseconds();
|
||||
lws_esp32.genled_t = lws_time_in_microseconds();
|
||||
lws_esp32.genled = n;
|
||||
}
|
||||
|
||||
|
@ -494,7 +494,7 @@ lws_esp32_leds_network_indication(void)
|
|||
uint64_t us, r;
|
||||
int n, fadein = 100, speed = 1199, div = 1, base = 0;
|
||||
|
||||
r = time_in_microseconds();
|
||||
r = lws_time_in_microseconds();
|
||||
us = r - lws_esp32.genled_t;
|
||||
|
||||
switch (lws_esp32.genled) {
|
||||
|
|
|
@ -21,7 +21,8 @@
|
|||
|
||||
#include "core/private.h"
|
||||
|
||||
unsigned long long time_in_microseconds(void)
|
||||
uint64_t
|
||||
lws_time_in_microseconds(void)
|
||||
{
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
|
|
|
@ -28,7 +28,8 @@ lws_plat_pipe_close(struct lws *wsi)
|
|||
|
||||
void TEE_GenerateRandom(void *randomBuffer, uint32_t randomBufferLen);
|
||||
|
||||
unsigned long long time_in_microseconds(void)
|
||||
uint64_t
|
||||
lws_time_in_microseconds(void)
|
||||
{
|
||||
return ((unsigned long long)time(NULL)) * 1000000;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,8 @@
|
|||
#include "core/private.h"
|
||||
|
||||
|
||||
unsigned long long time_in_microseconds(void)
|
||||
uint64_t
|
||||
lws_time_in_microseconds(void)
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
#include "core/private.h"
|
||||
|
||||
|
||||
unsigned long long
|
||||
time_in_microseconds()
|
||||
uint64_t
|
||||
lws_time_in_microseconds()
|
||||
{
|
||||
#ifndef DELTA_EPOCH_IN_MICROSECS
|
||||
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
|
||||
|
@ -56,7 +56,7 @@ time_in_microseconds()
|
|||
#ifdef _WIN32_WCE
|
||||
time_t time(time_t *t)
|
||||
{
|
||||
time_t ret = time_in_microseconds() / 1000000;
|
||||
time_t ret = lws_time_in_microseconds() / 1000000;
|
||||
|
||||
if(t != NULL)
|
||||
*t = ret;
|
||||
|
|
|
@ -462,7 +462,7 @@ try_pollout:
|
|||
LWSSTATS_C_WRITEABLE_CB, 1);
|
||||
#if defined(LWS_WITH_STATS)
|
||||
if (wsi->active_writable_req_us) {
|
||||
uint64_t ul = time_in_microseconds() -
|
||||
uint64_t ul = lws_time_in_microseconds() -
|
||||
wsi->active_writable_req_us;
|
||||
|
||||
lws_stats_atomic_bump(wsi->context, pt,
|
||||
|
|
|
@ -109,7 +109,7 @@ try_pollout:
|
|||
LWSSTATS_C_WRITEABLE_CB, 1);
|
||||
#if defined(LWS_WITH_STATS)
|
||||
if (wsi->active_writable_req_us) {
|
||||
uint64_t ul = time_in_microseconds() -
|
||||
uint64_t ul = lws_time_in_microseconds() -
|
||||
wsi->active_writable_req_us;
|
||||
|
||||
lws_stats_atomic_bump(wsi->context, pt,
|
||||
|
|
|
@ -78,7 +78,7 @@ lws_ssl_capable_read(struct lws *wsi, unsigned char *buf, int len)
|
|||
if (!wsi->seen_rx && wsi->accept_start_us) {
|
||||
lws_stats_atomic_bump(wsi->context, pt,
|
||||
LWSSTATS_MS_SSL_RX_DELAY,
|
||||
time_in_microseconds() - wsi->accept_start_us);
|
||||
lws_time_in_microseconds() - wsi->accept_start_us);
|
||||
lws_stats_atomic_bump(wsi->context, pt,
|
||||
LWSSTATS_C_SSL_CONNS_HAD_RX, 1);
|
||||
wsi->seen_rx = 1;
|
||||
|
|
|
@ -218,7 +218,7 @@ lws_ssl_capable_read(struct lws *wsi, unsigned char *buf, int len)
|
|||
#if defined(LWS_WITH_STATS)
|
||||
if (!wsi->seen_rx && wsi->accept_start_us) {
|
||||
lws_stats_atomic_bump(wsi->context, pt, LWSSTATS_MS_SSL_RX_DELAY,
|
||||
time_in_microseconds() - wsi->accept_start_us);
|
||||
lws_time_in_microseconds() - wsi->accept_start_us);
|
||||
lws_stats_atomic_bump(wsi->context, pt, LWSSTATS_C_SSL_CONNS_HAD_RX, 1);
|
||||
wsi->seen_rx = 1;
|
||||
}
|
||||
|
|
|
@ -314,7 +314,7 @@ lws_server_socket_service_ssl(struct lws *wsi, lws_sockfd_type accept_fd)
|
|||
#if defined(LWS_WITH_STATS)
|
||||
/* only set this the first time around */
|
||||
if (!wsi->accept_start_us)
|
||||
wsi->accept_start_us = time_in_microseconds();
|
||||
wsi->accept_start_us = lws_time_in_microseconds();
|
||||
#endif
|
||||
errno = 0;
|
||||
lws_stats_atomic_bump(wsi->context, pt,
|
||||
|
@ -344,8 +344,8 @@ lws_server_socket_service_ssl(struct lws *wsi, lws_sockfd_type accept_fd)
|
|||
if (wsi->accept_start_us)
|
||||
lws_stats_atomic_bump(wsi->context, pt,
|
||||
LWSSTATS_MS_SSL_CONNECTIONS_ACCEPTED_DELAY,
|
||||
time_in_microseconds() - wsi->accept_start_us);
|
||||
wsi->accept_start_us = time_in_microseconds();
|
||||
lws_time_in_microseconds() - wsi->accept_start_us);
|
||||
wsi->accept_start_us = lws_time_in_microseconds();
|
||||
#endif
|
||||
|
||||
accepted:
|
||||
|
|
Loading…
Add table
Reference in a new issue