mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
stats: move to pt and improve presentation
This commit is contained in:
parent
498a4e2bd7
commit
2fc35ef6bd
37 changed files with 336 additions and 260 deletions
|
@ -47,6 +47,12 @@ extern "C" {
|
|||
#define LWS_US_PER_MS 1000
|
||||
#define LWS_NS_PER_US 1000
|
||||
|
||||
#define LWS_KI (1024)
|
||||
#define LWS_MI (LWS_KI * 1024)
|
||||
#define LWS_GI (LWS_MI * 1024)
|
||||
#define LWS_TI ((uint64_t)LWS_GI * 1024)
|
||||
#define LWS_PI ((uint64_t)LWS_TI * 1024)
|
||||
|
||||
#define LWS_US_TO_MS(x) ((x + (LWS_US_PER_MS / 2)) / LWS_US_PER_MS)
|
||||
|
||||
#if defined(LWS_HAS_INTPTR_T)
|
||||
|
|
|
@ -885,4 +885,38 @@ lws_get_ssl(struct lws *wsi);
|
|||
LWS_VISIBLE LWS_EXTERN void
|
||||
lws_explicit_bzero(void *p, size_t len);
|
||||
|
||||
typedef struct lws_humanize_unit {
|
||||
const char *name; /* array ends with NULL name */
|
||||
uint64_t factor;
|
||||
} lws_humanize_unit_t;
|
||||
|
||||
LWS_VISIBLE LWS_EXTERN const lws_humanize_unit_t humanize_schema_si[];
|
||||
LWS_VISIBLE LWS_EXTERN const lws_humanize_unit_t humanize_schema_si_bytes[];
|
||||
LWS_VISIBLE LWS_EXTERN const lws_humanize_unit_t humanize_schema_us[];
|
||||
|
||||
/**
|
||||
* lws_humanize() - Convert possibly large number to himan-readable uints
|
||||
*
|
||||
* \param buf: result string buffer
|
||||
* \param len: remaining length in \p buf
|
||||
* \param value: the uint64_t value to represent
|
||||
* \param schema: and array of scaling factors and units
|
||||
*
|
||||
* This produces a concise string representation of \p value, referening the
|
||||
* schema \p schema of scaling factors and units to find the smallest way to
|
||||
* render it.
|
||||
*
|
||||
* Three schema are exported from lws for general use, humanize_schema_si, which
|
||||
* represents as, eg, " 22.130Gi" or " 128 "; humanize_schema_si_bytes
|
||||
* which is the same but shows, eg, " 22.130GiB", and humanize_schema_us,
|
||||
* which represents a count of us as a human-readable time like " 14.350min",
|
||||
* or " 1.500d".
|
||||
*
|
||||
* You can produce your own schema.
|
||||
*/
|
||||
|
||||
LWS_VISIBLE LWS_EXTERN int
|
||||
lws_humanize(char *buf, int len, uint64_t value,
|
||||
const lws_humanize_unit_t *schema);
|
||||
|
||||
///@}
|
||||
|
|
|
@ -161,7 +161,8 @@ lws_seq_check_wsi(lws_seq_t *seq, struct lws *wsi);
|
|||
* sequencer
|
||||
*
|
||||
* \param seq: The sequencer to set the timeout on
|
||||
* \param us: How many us in the future to fire the timeout (0 = disable)
|
||||
* \param us: How many us in the future to fire the timeout
|
||||
* LWS_SET_TIMER_USEC_CANCEL = cancel any existing timeout
|
||||
*
|
||||
* This api allows the sequencer to ask to be informed if it has not completed
|
||||
* or disabled its timeout after secs seconds. Lws will send a LWSSEQ_TIMED_OUT
|
||||
|
@ -199,16 +200,16 @@ LWS_VISIBLE LWS_EXTERN lws_seq_t *
|
|||
lws_seq_from_user(void *u);
|
||||
|
||||
/**
|
||||
* lws_seq_secs_since_creation(): elapsed seconds since sequencer created
|
||||
* lws_seq_us_since_creation(): elapsed seconds since sequencer created
|
||||
*
|
||||
* \param seq: pointer to the lws_seq_t
|
||||
*
|
||||
* Returns the number of seconds elapsed since the lws_seq_t was
|
||||
* Returns the number of us elapsed since the lws_seq_t was
|
||||
* created. This is useful to calculate sequencer timeouts for the current
|
||||
* step considering a global sequencer lifetime limit.
|
||||
*/
|
||||
LWS_VISIBLE LWS_EXTERN int
|
||||
lws_seq_secs_since_creation(lws_seq_t *seq);
|
||||
LWS_VISIBLE LWS_EXTERN lws_usec_t
|
||||
lws_seq_us_since_creation(lws_seq_t *seq);
|
||||
|
||||
/**
|
||||
* lws_seq_name(): get the name of this sequencer
|
||||
|
|
|
@ -42,22 +42,27 @@ enum {
|
|||
LWSSTATS_C_WRITEABLE_CB, /**< count of writable callbacks */
|
||||
LWSSTATS_C_SSL_CONNECTIONS_FAILED, /**< count of failed SSL connections */
|
||||
LWSSTATS_C_SSL_CONNECTIONS_ACCEPTED, /**< count of accepted SSL connections */
|
||||
LWSSTATS_C_SSL_CONNECTIONS_ACCEPT_SPIN, /**< count of SSL_accept() attempts */
|
||||
LWSSTATS_C_SSL_ACCEPT_SPIN, /**< count of SSL_accept() attempts */
|
||||
LWSSTATS_C_SSL_CONNS_HAD_RX, /**< count of accepted SSL conns that have had some RX */
|
||||
LWSSTATS_C_TIMEOUTS, /**< count of timed-out connections */
|
||||
LWSSTATS_C_SERVICE_ENTRY, /**< count of entries to lws service loop */
|
||||
LWSSTATS_B_READ, /**< aggregate bytes read */
|
||||
LWSSTATS_B_WRITE, /**< aggregate bytes written */
|
||||
LWSSTATS_B_PARTIALS_ACCEPTED_PARTS, /**< aggreate of size of accepted write data from new partials */
|
||||
LWSSTATS_MS_SSL_CONNECTIONS_ACCEPTED_DELAY, /**< aggregate delay in accepting connection */
|
||||
LWSSTATS_MS_WRITABLE_DELAY, /**< aggregate delay between asking for writable and getting cb */
|
||||
LWSSTATS_MS_WORST_WRITABLE_DELAY, /**< single worst delay between asking for writable and getting cb */
|
||||
LWSSTATS_MS_SSL_RX_DELAY, /**< aggregate delay between ssl accept complete and first RX */
|
||||
LWSSTATS_US_SSL_ACCEPT_LATENCY_AVG, /**< aggregate delay in accepting connection */
|
||||
LWSSTATS_US_WRITABLE_DELAY_AVG, /**< aggregate delay between asking for writable and getting cb */
|
||||
LWSSTATS_US_WORST_WRITABLE_DELAY, /**< single worst delay between asking for writable and getting cb */
|
||||
LWSSTATS_US_SSL_RX_DELAY_AVG, /**< aggregate delay between ssl accept complete and first RX */
|
||||
LWSSTATS_C_PEER_LIMIT_AH_DENIED, /**< number of times we would have given an ah but for the peer limit */
|
||||
LWSSTATS_C_PEER_LIMIT_WSI_DENIED, /**< number of times we would have given a wsi but for the peer limit */
|
||||
LWSSTATS_C_CONNECTIONS_CLIENT, /**< attempted client conns */
|
||||
LWSSTATS_C_CONNECTIONS_CLIENT_FAILED, /**< failed client conns */
|
||||
|
||||
/* Add new things just above here ---^
|
||||
* This is part of the ABI, don't needlessly break compatibility */
|
||||
* This is part of the ABI, don't needlessly break compatibility
|
||||
*
|
||||
* UPDATE stat_names in stats.c in sync with this!
|
||||
*/
|
||||
LWSSTATS_SIZE
|
||||
};
|
||||
|
||||
|
|
|
@ -64,17 +64,14 @@ enum pending_timeout {
|
|||
PENDING_TIMEOUT_THREADPOOL = 29,
|
||||
PENDING_TIMEOUT_THREADPOOL_TASK = 30,
|
||||
PENDING_TIMEOUT_KILLED_BY_PROXY_CLIENT_CLOSE = 31,
|
||||
PENDING_TIMEOUT_USER_OK = 32,
|
||||
|
||||
/****** add new things just above ---^ ******/
|
||||
|
||||
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_time_in_microseconds lws_now_usecs
|
||||
|
||||
#define LWS_TO_KILL_ASYNC -1
|
||||
/**< If LWS_TO_KILL_ASYNC is given as the timeout sec in a lws_set_timeout()
|
||||
|
|
|
@ -125,7 +125,7 @@ lws_adopt_descriptor_vhost(struct lws_vhost *vh, lws_adoption_type type,
|
|||
peer->count_wsi >= context->ip_limit_wsi) {
|
||||
lwsl_notice("Peer reached wsi limit %d\n",
|
||||
context->ip_limit_wsi);
|
||||
lws_stats_atomic_bump(context, &context->pt[0],
|
||||
lws_stats_bump(&context->pt[0],
|
||||
LWSSTATS_C_PEER_LIMIT_WSI_DENIED,
|
||||
1);
|
||||
return NULL;
|
||||
|
@ -153,7 +153,7 @@ lws_adopt_descriptor_vhost(struct lws_vhost *vh, lws_adoption_type type,
|
|||
lws_peer_add_wsi(context, peer, new_wsi);
|
||||
#endif
|
||||
pt = &context->pt[(int)new_wsi->tsi];
|
||||
lws_stats_atomic_bump(context, pt, LWSSTATS_C_CONNECTIONS, 1);
|
||||
lws_stats_bump(pt, LWSSTATS_C_CONNECTIONS, 1);
|
||||
|
||||
if (parent) {
|
||||
new_wsi->parent = parent;
|
||||
|
|
|
@ -150,7 +150,7 @@ __lws_close_free_wsi(struct lws *wsi, enum lws_close_status reason,
|
|||
|
||||
context = wsi->context;
|
||||
pt = &context->pt[(int)wsi->tsi];
|
||||
lws_stats_atomic_bump(wsi->context, pt, LWSSTATS_C_API_CLOSE, 1);
|
||||
lws_stats_bump(pt, LWSSTATS_C_API_CLOSE, 1);
|
||||
|
||||
#if !defined(LWS_NO_CLIENT)
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ lws_client_connect_via_info(const struct lws_client_connect_info *i)
|
|||
if (!i->context->protocol_init_done)
|
||||
if (lws_protocol_init(i->context))
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
* If we have .local_protocol_name, use it to select the local protocol
|
||||
* handler to bind to. Otherwise use .protocol if http[s].
|
||||
|
@ -109,6 +110,10 @@ lws_client_connect_via_info(const struct lws_client_connect_info *i)
|
|||
*/
|
||||
|
||||
lws_context_unlock(i->context);
|
||||
|
||||
lws_stats_bump(&i->context->pt[tid], LWSSTATS_C_CONNECTIONS_CLIENT, 1);
|
||||
#else
|
||||
lws_stats_bump(&i->context->pt[0], LWSSTATS_C_CONNECTIONS_CLIENT, 1);
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
|
@ -124,7 +124,9 @@ lws_callback_ws_proxy(struct lws *wsi, enum lws_callback_reasons reason,
|
|||
case LWS_CALLBACK_CLIENT_CLOSED:
|
||||
lwsl_user("%s: client closed: parent %p\n", __func__, wsi->parent);
|
||||
if (wsi->parent)
|
||||
lws_set_timeout(wsi->parent, 1, LWS_TO_KILL_ASYNC);
|
||||
lws_set_timeout(wsi->parent,
|
||||
PENDING_TIMEOUT_KILLED_BY_PROXY_CLIENT_CLOSE,
|
||||
LWS_TO_KILL_ASYNC);
|
||||
break;
|
||||
|
||||
case LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER:
|
||||
|
@ -582,8 +584,9 @@ lws_callback_http_dummy(struct lws *wsi, enum lws_callback_reasons reason,
|
|||
if (!lws_get_parent(wsi))
|
||||
break;
|
||||
lwsl_err("%s: LWS_CALLBACK_CLOSED_CLIENT_HTTP\n", __func__);
|
||||
lws_set_timeout(lws_get_parent(wsi), LWS_TO_KILL_ASYNC,
|
||||
PENDING_TIMEOUT_KILLED_BY_PROXY_CLIENT_CLOSE);
|
||||
lws_set_timeout(lws_get_parent(wsi),
|
||||
PENDING_TIMEOUT_KILLED_BY_PROXY_CLIENT_CLOSE,
|
||||
LWS_TO_KILL_ASYNC);
|
||||
break;
|
||||
|
||||
case LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER:
|
||||
|
|
|
@ -48,7 +48,7 @@ int lws_issue_raw(struct lws *wsi, unsigned char *buf, size_t len)
|
|||
(unsigned long)len);
|
||||
}
|
||||
|
||||
lws_stats_atomic_bump(wsi->context, pt, LWSSTATS_C_API_WRITE, 1);
|
||||
lws_stats_bump(pt, LWSSTATS_C_API_WRITE, 1);
|
||||
|
||||
/* just ignore sends after we cleared the truncation buffer */
|
||||
if (lwsi_state(wsi) == LRS_FLUSHING_BEFORE_CLOSE &&
|
||||
|
@ -200,9 +200,8 @@ int lws_issue_raw(struct lws *wsi, unsigned char *buf, size_t len)
|
|||
real_len - m) < 0)
|
||||
return -1;
|
||||
|
||||
lws_stats_atomic_bump(wsi->context, pt, LWSSTATS_C_WRITE_PARTIALS, 1);
|
||||
lws_stats_atomic_bump(wsi->context, pt,
|
||||
LWSSTATS_B_PARTIALS_ACCEPTED_PARTS, m);
|
||||
lws_stats_bump(pt, LWSSTATS_C_WRITE_PARTIALS, 1);
|
||||
lws_stats_bump(pt, LWSSTATS_B_PARTIALS_ACCEPTED_PARTS, m);
|
||||
|
||||
#if !defined(LWS_WITH_ESP32) && !defined(LWS_PLAT_OPTEE)
|
||||
if (lws_wsi_is_udp(wsi)) {
|
||||
|
@ -223,7 +222,7 @@ LWS_VISIBLE int lws_write(struct lws *wsi, unsigned char *buf, size_t len,
|
|||
{
|
||||
struct lws_context_per_thread *pt = &wsi->context->pt[(int)wsi->tsi];
|
||||
|
||||
lws_stats_atomic_bump(wsi->context, pt, LWSSTATS_C_API_LWS_WRITE, 1);
|
||||
lws_stats_bump(pt, LWSSTATS_C_API_LWS_WRITE, 1);
|
||||
|
||||
if ((int)len < 0) {
|
||||
lwsl_err("%s: suspicious len int %d, ulong %lu\n", __func__,
|
||||
|
@ -231,7 +230,7 @@ LWS_VISIBLE int lws_write(struct lws *wsi, unsigned char *buf, size_t len,
|
|||
return -1;
|
||||
}
|
||||
|
||||
lws_stats_atomic_bump(wsi->context, pt, LWSSTATS_B_WRITE, len);
|
||||
lws_stats_bump(pt, LWSSTATS_B_WRITE, len);
|
||||
|
||||
#ifdef LWS_WITH_ACCESS_LOG
|
||||
wsi->http.access_log.sent += len;
|
||||
|
@ -253,7 +252,7 @@ lws_ssl_capable_read_no_ssl(struct lws *wsi, unsigned char *buf, int len)
|
|||
struct lws_context_per_thread *pt = &context->pt[(int)wsi->tsi];
|
||||
int n = 0;
|
||||
|
||||
lws_stats_atomic_bump(context, pt, LWSSTATS_C_API_READ, 1);
|
||||
lws_stats_bump(pt, LWSSTATS_C_API_READ, 1);
|
||||
|
||||
errno = 0;
|
||||
if (lws_wsi_is_udp(wsi)) {
|
||||
|
@ -279,7 +278,7 @@ lws_ssl_capable_read_no_ssl(struct lws *wsi, unsigned char *buf, int len)
|
|||
|
||||
if (wsi->vhost)
|
||||
wsi->vhost->conn_stats.rx += n;
|
||||
lws_stats_atomic_bump(context, pt, LWSSTATS_B_READ, n);
|
||||
lws_stats_bump(pt, LWSSTATS_B_READ, n);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
|
|
@ -481,12 +481,11 @@ lws_callback_on_writable(struct lws *wsi)
|
|||
|
||||
pt = &wsi->context->pt[(int)wsi->tsi];
|
||||
|
||||
lws_stats_atomic_bump(wsi->context, pt, LWSSTATS_C_WRITEABLE_CB_REQ, 1);
|
||||
lws_stats_bump(pt, LWSSTATS_C_WRITEABLE_CB_REQ, 1);
|
||||
#if defined(LWS_WITH_STATS)
|
||||
if (!wsi->active_writable_req_us) {
|
||||
wsi->active_writable_req_us = lws_time_in_microseconds();
|
||||
lws_stats_atomic_bump(wsi->context, pt,
|
||||
LWSSTATS_C_WRITEABLE_CB_EFF_REQ, 1);
|
||||
wsi->active_writable_req_us = lws_now_usecs();
|
||||
lws_stats_bump(pt, LWSSTATS_C_WRITEABLE_CB_EFF_REQ, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -292,6 +292,8 @@ struct lws_context_per_thread {
|
|||
lws_sorted_usec_list_t sul_plat;
|
||||
#endif
|
||||
#if defined(LWS_WITH_STATS)
|
||||
uint64_t lws_stats[LWSSTATS_SIZE];
|
||||
int updated;
|
||||
lws_sorted_usec_list_t sul_stats;
|
||||
#endif
|
||||
#if defined(LWS_WITH_PEER_LIMITS)
|
||||
|
@ -1062,18 +1064,16 @@ lws_broadcast(struct lws_context_per_thread *pt, int reason, void *in, size_t le
|
|||
|
||||
#if defined(LWS_WITH_STATS)
|
||||
void
|
||||
lws_stats_atomic_bump(struct lws_context * context,
|
||||
struct lws_context_per_thread *pt, int index, uint64_t bump);
|
||||
lws_stats_bump(struct lws_context_per_thread *pt, int i, uint64_t bump);
|
||||
void
|
||||
lws_stats_atomic_max(struct lws_context * context,
|
||||
struct lws_context_per_thread *pt, int index, uint64_t val);
|
||||
lws_stats_max(struct lws_context_per_thread *pt, int index, uint64_t val);
|
||||
#else
|
||||
static LWS_INLINE uint64_t lws_stats_atomic_bump(struct lws_context * context,
|
||||
static LWS_INLINE uint64_t lws_stats_bump(
|
||||
struct lws_context_per_thread *pt, int index, uint64_t bump) {
|
||||
(void)context; (void)pt; (void)index; (void)bump; return 0; }
|
||||
static LWS_INLINE uint64_t lws_stats_atomic_max(struct lws_context * context,
|
||||
(void)pt; (void)index; (void)bump; return 0; }
|
||||
static LWS_INLINE uint64_t lws_stats_max(
|
||||
struct lws_context_per_thread *pt, int index, uint64_t val) {
|
||||
(void)context; (void)pt; (void)index; (void)val; return 0; }
|
||||
(void)pt; (void)index; (void)val; return 0; }
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -290,7 +290,7 @@ lws_seq_sul_timeout_cb(lws_sorted_usec_list_t *sul)
|
|||
lws_seq_queue_event(s, LWSSEQ_TIMED_OUT, NULL, NULL);
|
||||
}
|
||||
|
||||
/* set secs to zero to remove timeout */
|
||||
/* set us to LWS_SET_TIMER_USEC_CANCEL to remove timeout */
|
||||
|
||||
int
|
||||
lws_seq_timeout_us(lws_seq_t *seq, lws_usec_t us)
|
||||
|
@ -313,14 +313,10 @@ lws_seq_name(lws_seq_t *seq)
|
|||
return seq->name;
|
||||
}
|
||||
|
||||
int
|
||||
lws_seq_secs_since_creation(lws_seq_t *seq)
|
||||
lws_usec_t
|
||||
lws_seq_us_since_creation(lws_seq_t *seq)
|
||||
{
|
||||
time_t now;
|
||||
|
||||
time(&now);
|
||||
|
||||
return now - seq->time_created;
|
||||
return lws_now_usecs() - seq->time_created;
|
||||
}
|
||||
|
||||
struct lws_context *
|
||||
|
|
|
@ -27,16 +27,14 @@ lws_callback_as_writeable(struct lws *wsi)
|
|||
struct lws_context_per_thread *pt = &wsi->context->pt[(int)wsi->tsi];
|
||||
int n, m;
|
||||
|
||||
lws_stats_atomic_bump(wsi->context, pt, LWSSTATS_C_WRITEABLE_CB, 1);
|
||||
lws_stats_bump(pt, LWSSTATS_C_WRITEABLE_CB, 1);
|
||||
#if defined(LWS_WITH_STATS)
|
||||
if (wsi->active_writable_req_us) {
|
||||
uint64_t ul = lws_time_in_microseconds() -
|
||||
uint64_t ul = lws_now_usecs() -
|
||||
wsi->active_writable_req_us;
|
||||
|
||||
lws_stats_atomic_bump(wsi->context, pt,
|
||||
LWSSTATS_MS_WRITABLE_DELAY, ul);
|
||||
lws_stats_atomic_max(wsi->context, pt,
|
||||
LWSSTATS_MS_WORST_WRITABLE_DELAY, ul);
|
||||
lws_stats_bump(pt, LWSSTATS_US_WRITABLE_DELAY_AVG, ul);
|
||||
lws_stats_max(pt, LWSSTATS_US_WORST_WRITABLE_DELAY, ul);
|
||||
wsi->active_writable_req_us = 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -27,122 +27,134 @@
|
|||
LWS_VISIBLE LWS_EXTERN uint64_t
|
||||
lws_stats_get(struct lws_context *context, int index)
|
||||
{
|
||||
struct lws_context_per_thread *pt = &context->pt[0];
|
||||
|
||||
if (index >= LWSSTATS_SIZE)
|
||||
return 0;
|
||||
|
||||
return context->lws_stats[index];
|
||||
return pt->lws_stats[index];
|
||||
}
|
||||
|
||||
static const char * stat_names[] = {
|
||||
"C_CONNECTIONS",
|
||||
"C_API_CLOSE",
|
||||
"C_API_READ",
|
||||
"C_API_LWS_WRITE",
|
||||
"C_API_WRITE",
|
||||
"C_WRITE_PARTIALS",
|
||||
"C_WRITEABLE_CB_REQ",
|
||||
"C_WRITEABLE_CB_EFF_REQ",
|
||||
"C_WRITEABLE_CB",
|
||||
"C_SSL_CONNECTIONS_FAILED",
|
||||
"C_SSL_CONNECTIONS_ACCEPTED",
|
||||
"C_SSL_CONNECTIONS_ACCEPT_SPIN",
|
||||
"C_SSL_CONNS_HAD_RX",
|
||||
"C_TIMEOUTS",
|
||||
"C_SERVICE_ENTRY",
|
||||
"B_READ",
|
||||
"B_WRITE",
|
||||
"B_PARTIALS_ACCEPTED_PARTS",
|
||||
"US_SSL_ACCEPT_LATENCY_AVG",
|
||||
"US_WRITABLE_DELAY_AVG",
|
||||
"US_WORST_WRITABLE_DELAY",
|
||||
"US_SSL_RX_DELAY_AVG",
|
||||
"C_PEER_LIMIT_AH_DENIED",
|
||||
"C_PEER_LIMIT_WSI_DENIED",
|
||||
"C_CONNECTIONS_CLIENT",
|
||||
"C_CONNECTIONS_CLIENT_FAILED",
|
||||
};
|
||||
|
||||
static int
|
||||
quantify(struct lws_context *context, int tsi, char *p, int len, int idx,
|
||||
uint64_t *sum)
|
||||
{
|
||||
const lws_humanize_unit_t *schema = humanize_schema_si;
|
||||
struct lws_context_per_thread *pt = &context->pt[tsi];
|
||||
uint64_t u, u1;
|
||||
|
||||
lws_pt_stats_lock(pt);
|
||||
u = pt->lws_stats[idx];
|
||||
|
||||
/* it's supposed to be an average? */
|
||||
|
||||
switch (idx) {
|
||||
case LWSSTATS_US_SSL_ACCEPT_LATENCY_AVG:
|
||||
u1 = pt->lws_stats[LWSSTATS_C_SSL_CONNECTIONS_ACCEPTED];
|
||||
if (u1)
|
||||
u = u / u1;
|
||||
break;
|
||||
case LWSSTATS_US_SSL_RX_DELAY_AVG:
|
||||
u1 = pt->lws_stats[LWSSTATS_C_SSL_CONNS_HAD_RX];
|
||||
if (u1)
|
||||
u = u / u1;
|
||||
break;
|
||||
case LWSSTATS_US_WRITABLE_DELAY_AVG:
|
||||
u1 = pt->lws_stats[LWSSTATS_C_WRITEABLE_CB];
|
||||
if (u1)
|
||||
u = u / u1;
|
||||
break;
|
||||
}
|
||||
lws_pt_stats_unlock(pt);
|
||||
|
||||
*sum += u;
|
||||
|
||||
switch (stat_names[idx][0]) {
|
||||
case 'U':
|
||||
schema = humanize_schema_us;
|
||||
break;
|
||||
case 'B':
|
||||
schema = humanize_schema_si_bytes;
|
||||
break;
|
||||
}
|
||||
|
||||
return lws_humanize(p, len, u, schema);
|
||||
}
|
||||
|
||||
|
||||
LWS_VISIBLE LWS_EXTERN void
|
||||
lws_stats_log_dump(struct lws_context *context)
|
||||
{
|
||||
struct lws_vhost *v = context->vhost_list;
|
||||
int n;
|
||||
#if defined(LWS_WITH_PEER_LIMITS)
|
||||
int m;
|
||||
#endif
|
||||
uint64_t summary[LWSSTATS_SIZE];
|
||||
char bufline[128], *p, *end = bufline + sizeof(bufline) - 1;
|
||||
int n, m;
|
||||
|
||||
if (!context->updated)
|
||||
return;
|
||||
|
||||
context->updated = 0;
|
||||
memset(summary, 0, sizeof(summary));
|
||||
|
||||
lwsl_notice("\n");
|
||||
lwsl_notice("LWS internal statistics dump ----->\n");
|
||||
lwsl_notice("LWSSTATS_C_CONNECTIONS: %8llu\n",
|
||||
(unsigned long long)lws_stats_get(context,
|
||||
LWSSTATS_C_CONNECTIONS));
|
||||
lwsl_notice("LWSSTATS_C_API_CLOSE: %8llu\n",
|
||||
(unsigned long long)lws_stats_get(context,
|
||||
LWSSTATS_C_API_CLOSE));
|
||||
lwsl_notice("LWSSTATS_C_API_READ: %8llu\n",
|
||||
(unsigned long long)lws_stats_get(context,
|
||||
LWSSTATS_C_API_READ));
|
||||
lwsl_notice("LWSSTATS_C_API_LWS_WRITE: %8llu\n",
|
||||
(unsigned long long)lws_stats_get(context,
|
||||
LWSSTATS_C_API_LWS_WRITE));
|
||||
lwsl_notice("LWSSTATS_C_API_WRITE: %8llu\n",
|
||||
(unsigned long long)lws_stats_get(context,
|
||||
LWSSTATS_C_API_WRITE));
|
||||
lwsl_notice("LWSSTATS_C_WRITE_PARTIALS: %8llu\n",
|
||||
(unsigned long long)lws_stats_get(context,
|
||||
LWSSTATS_C_WRITE_PARTIALS));
|
||||
lwsl_notice("LWSSTATS_C_WRITEABLE_CB_REQ: %8llu\n",
|
||||
(unsigned long long)lws_stats_get(context,
|
||||
LWSSTATS_C_WRITEABLE_CB_REQ));
|
||||
lwsl_notice("LWSSTATS_C_WRITEABLE_CB_EFF_REQ: %8llu\n",
|
||||
(unsigned long long)lws_stats_get(context,
|
||||
LWSSTATS_C_WRITEABLE_CB_EFF_REQ));
|
||||
lwsl_notice("LWSSTATS_C_WRITEABLE_CB: %8llu\n",
|
||||
(unsigned long long)lws_stats_get(context,
|
||||
LWSSTATS_C_WRITEABLE_CB));
|
||||
lwsl_notice("LWSSTATS_C_SSL_CONNECTIONS_ACCEPT_SPIN: %8llu\n",
|
||||
(unsigned long long)lws_stats_get(context,
|
||||
LWSSTATS_C_SSL_CONNECTIONS_ACCEPT_SPIN));
|
||||
lwsl_notice("LWSSTATS_C_SSL_CONNECTIONS_FAILED: %8llu\n",
|
||||
(unsigned long long)lws_stats_get(context,
|
||||
LWSSTATS_C_SSL_CONNECTIONS_FAILED));
|
||||
lwsl_notice("LWSSTATS_C_SSL_CONNECTIONS_ACCEPTED: %8llu\n",
|
||||
(unsigned long long)lws_stats_get(context,
|
||||
LWSSTATS_C_SSL_CONNECTIONS_ACCEPTED));
|
||||
lwsl_notice("LWSSTATS_C_SSL_CONNS_HAD_RX: %8llu\n",
|
||||
(unsigned long long)lws_stats_get(context,
|
||||
LWSSTATS_C_SSL_CONNS_HAD_RX));
|
||||
lwsl_notice("LWSSTATS_C_PEER_LIMIT_AH_DENIED: %8llu\n",
|
||||
(unsigned long long)lws_stats_get(context,
|
||||
LWSSTATS_C_PEER_LIMIT_AH_DENIED));
|
||||
lwsl_notice("LWSSTATS_C_PEER_LIMIT_WSI_DENIED: %8llu\n",
|
||||
(unsigned long long)lws_stats_get(context,
|
||||
LWSSTATS_C_PEER_LIMIT_WSI_DENIED));
|
||||
for (n = 0; n < (int)LWS_ARRAY_SIZE(stat_names); n++) {
|
||||
uint64_t u = 0;
|
||||
|
||||
lwsl_notice("LWSSTATS_C_TIMEOUTS: %8llu\n",
|
||||
(unsigned long long)lws_stats_get(context,
|
||||
LWSSTATS_C_TIMEOUTS));
|
||||
lwsl_notice("LWSSTATS_C_SERVICE_ENTRY: %8llu\n",
|
||||
(unsigned long long)lws_stats_get(context,
|
||||
LWSSTATS_C_SERVICE_ENTRY));
|
||||
lwsl_notice("LWSSTATS_B_READ: %8llu\n",
|
||||
(unsigned long long)lws_stats_get(context, LWSSTATS_B_READ));
|
||||
lwsl_notice("LWSSTATS_B_WRITE: %8llu\n",
|
||||
(unsigned long long)lws_stats_get(context, LWSSTATS_B_WRITE));
|
||||
lwsl_notice("LWSSTATS_B_PARTIALS_ACCEPTED_PARTS: %8llu\n",
|
||||
(unsigned long long)lws_stats_get(context,
|
||||
LWSSTATS_B_PARTIALS_ACCEPTED_PARTS));
|
||||
lwsl_notice("LWSSTATS_MS_SSL_CONNECTIONS_ACCEPTED_DELAY: %8llums\n",
|
||||
(unsigned long long)lws_stats_get(context,
|
||||
LWSSTATS_MS_SSL_CONNECTIONS_ACCEPTED_DELAY) / 1000);
|
||||
if (lws_stats_get(context, LWSSTATS_C_SSL_CONNECTIONS_ACCEPTED))
|
||||
lwsl_notice(" Avg accept delay: %8llums\n",
|
||||
(unsigned long long)(lws_stats_get(context,
|
||||
LWSSTATS_MS_SSL_CONNECTIONS_ACCEPTED_DELAY) /
|
||||
lws_stats_get(context,
|
||||
LWSSTATS_C_SSL_CONNECTIONS_ACCEPTED)) / 1000);
|
||||
lwsl_notice("LWSSTATS_MS_SSL_RX_DELAY: %8llums\n",
|
||||
(unsigned long long)lws_stats_get(context,
|
||||
LWSSTATS_MS_SSL_RX_DELAY) / 1000);
|
||||
if (lws_stats_get(context, LWSSTATS_C_SSL_CONNS_HAD_RX))
|
||||
lwsl_notice(" Avg accept-rx delay: %8llums\n",
|
||||
(unsigned long long)(lws_stats_get(context,
|
||||
LWSSTATS_MS_SSL_RX_DELAY) /
|
||||
lws_stats_get(context,
|
||||
LWSSTATS_C_SSL_CONNS_HAD_RX)) / 1000);
|
||||
/* if it's all zeroes, don't report it */
|
||||
|
||||
lwsl_notice("LWSSTATS_MS_WRITABLE_DELAY: %8lluus\n",
|
||||
(unsigned long long)lws_stats_get(context,
|
||||
LWSSTATS_MS_WRITABLE_DELAY));
|
||||
lwsl_notice("LWSSTATS_MS_WORST_WRITABLE_DELAY: %8lluus\n",
|
||||
(unsigned long long)lws_stats_get(context,
|
||||
LWSSTATS_MS_WORST_WRITABLE_DELAY));
|
||||
if (lws_stats_get(context, LWSSTATS_C_WRITEABLE_CB))
|
||||
lwsl_notice(" Avg writable delay: %8lluus\n",
|
||||
(unsigned long long)(lws_stats_get(context,
|
||||
LWSSTATS_MS_WRITABLE_DELAY) /
|
||||
lws_stats_get(context, LWSSTATS_C_WRITEABLE_CB)));
|
||||
lwsl_notice("Simultaneous SSL restriction: %8d/%d\n",
|
||||
for (m = 0; m < context->count_threads; m++) {
|
||||
struct lws_context_per_thread *pt = &context->pt[m];
|
||||
|
||||
u |= pt->lws_stats[n];
|
||||
}
|
||||
if (!u)
|
||||
continue;
|
||||
|
||||
p = bufline;
|
||||
p += lws_snprintf(p, lws_ptr_diff(end, p), "%28s: ",
|
||||
stat_names[n]);
|
||||
|
||||
for (m = 0; m < context->count_threads; m++)
|
||||
quantify(context, m, p, lws_ptr_diff(end, p), n, &summary[n]);
|
||||
|
||||
lwsl_notice("%s\n", bufline);
|
||||
}
|
||||
|
||||
lwsl_notice("Simultaneous SSL restriction: %8d/%d\n",
|
||||
context->simultaneous_ssl,
|
||||
context->simultaneous_ssl_restriction);
|
||||
|
||||
lwsl_notice("Live wsi: %8d\n",
|
||||
lwsl_notice("Live wsi: %8d\n",
|
||||
context->count_wsi_allocated);
|
||||
|
||||
context->updated = 1;
|
||||
|
@ -236,24 +248,25 @@ lws_stats_log_dump(struct lws_context *context)
|
|||
}
|
||||
|
||||
void
|
||||
lws_stats_atomic_bump(struct lws_context * context,
|
||||
struct lws_context_per_thread *pt, int index, uint64_t bump)
|
||||
lws_stats_bump(struct lws_context_per_thread *pt, int i, uint64_t bump)
|
||||
{
|
||||
lws_pt_stats_lock(pt);
|
||||
context->lws_stats[index] += bump;
|
||||
if (index != LWSSTATS_C_SERVICE_ENTRY)
|
||||
context->updated = 1;
|
||||
pt->lws_stats[i] += bump;
|
||||
if (i != LWSSTATS_C_SERVICE_ENTRY) {
|
||||
pt->updated = 1;
|
||||
pt->context->updated = 1;
|
||||
}
|
||||
lws_pt_stats_unlock(pt);
|
||||
}
|
||||
|
||||
void
|
||||
lws_stats_atomic_max(struct lws_context * context,
|
||||
struct lws_context_per_thread *pt, int index, uint64_t val)
|
||||
lws_stats_max(struct lws_context_per_thread *pt, int index, uint64_t val)
|
||||
{
|
||||
lws_pt_stats_lock(pt);
|
||||
if (val > context->lws_stats[index]) {
|
||||
context->lws_stats[index] = val;
|
||||
context->updated = 1;
|
||||
if (val > pt->lws_stats[index]) {
|
||||
pt->lws_stats[index] = val;
|
||||
pt->updated = 1;
|
||||
pt->context->updated = 1;
|
||||
}
|
||||
lws_pt_stats_unlock(pt);
|
||||
}
|
||||
|
|
|
@ -76,13 +76,15 @@ lws_sul_wsitimeout_cb(lws_sorted_usec_list_t *sul)
|
|||
struct lws *wsi = lws_container_of(sul, struct lws, sul_timeout);
|
||||
struct lws_context_per_thread *pt = &wsi->context->pt[(int)wsi->tsi];
|
||||
|
||||
lws_stats_atomic_bump(wsi->context, pt, LWSSTATS_C_TIMEOUTS, 1);
|
||||
if (wsi->pending_timeout != PENDING_TIMEOUT_USER_OK)
|
||||
lws_stats_bump(pt, LWSSTATS_C_TIMEOUTS, 1);
|
||||
|
||||
/* no need to log normal idle keepalive timeout */
|
||||
// if (wsi->pending_timeout != PENDING_TIMEOUT_HTTP_KEEPALIVE_IDLE)
|
||||
#if defined(LWS_ROLE_H1) || defined(LWS_ROLE_H2)
|
||||
if (wsi->pending_timeout != PENDING_TIMEOUT_USER_OK)
|
||||
lwsl_info("wsi %p: TIMEDOUT WAITING on %d "
|
||||
"(did hdr %d, ah %p, wl %d\n",
|
||||
"(did hdr %d, ah %p, wl %d)\n",
|
||||
(void *)wsi, wsi->pending_timeout,
|
||||
wsi->hdr_parsing_completed, wsi->http.ah,
|
||||
pt->http.ah_wait_list_length);
|
||||
|
@ -91,8 +93,9 @@ lws_sul_wsitimeout_cb(lws_sorted_usec_list_t *sul)
|
|||
lwsl_notice("CGI timeout: %s\n", wsi->http.cgi->summary);
|
||||
#endif
|
||||
#else
|
||||
lwsl_info("wsi %p: TIMEDOUT WAITING on %d ", (void *)wsi,
|
||||
wsi->pending_timeout);
|
||||
if (wsi->pending_timeout != PENDING_TIMEOUT_USER_OK)
|
||||
lwsl_info("wsi %p: TIMEDOUT WAITING on %d ", (void *)wsi,
|
||||
wsi->pending_timeout);
|
||||
#endif
|
||||
/* cgi timeout */
|
||||
if (wsi->pending_timeout != PENDING_TIMEOUT_HTTP_KEEPALIVE_IDLE)
|
||||
|
|
|
@ -756,7 +756,7 @@ lws_latency(struct lws_context *context, struct lws *wsi, const char *action,
|
|||
unsigned long long u;
|
||||
char buf[256];
|
||||
|
||||
u = lws_time_in_microseconds();
|
||||
u = lws_now_usecs();
|
||||
|
||||
if (!action) {
|
||||
wsi->latency_start = u;
|
||||
|
|
|
@ -95,27 +95,6 @@ int lws_open(const char *__file, int __oflag, ...)
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if !(defined(LWS_PLAT_OPTEE) && !defined(LWS_WITH_NETWORK))
|
||||
|
||||
LWS_VISIBLE lws_usec_t
|
||||
lws_now_usecs(void)
|
||||
{
|
||||
#if defined(LWS_HAVE_CLOCK_GETTIME)
|
||||
struct timespec ts;
|
||||
|
||||
if (clock_gettime(CLOCK_MONOTONIC, &ts))
|
||||
return 0;
|
||||
|
||||
return (ts.tv_sec * LWS_US_PER_SEC) + (ts.tv_nsec / LWS_NS_PER_US);
|
||||
#else
|
||||
struct timeval now;
|
||||
|
||||
gettimeofday(&now, NULL);
|
||||
return (now.tv_sec * 1000000ll) + now.tv_usec;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
lws_pthread_self_to_tsi(struct lws_context *context)
|
||||
{
|
||||
|
@ -911,3 +890,47 @@ lws_cmdline_option(int argc, const char **argv, const char *val)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
const lws_humanize_unit_t humanize_schema_si[] = {
|
||||
{ "Pi ", LWS_PI }, { "Ti ", LWS_TI }, { "Gi ", LWS_GI },
|
||||
{ "Mi ", LWS_MI }, { "Ki ", LWS_KI }, { " ", 1 },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
const lws_humanize_unit_t humanize_schema_si_bytes[] = {
|
||||
{ "PiB", LWS_PI }, { "TiB", LWS_TI }, { "GiB", LWS_GI },
|
||||
{ "MiB", LWS_MI }, { "KiB", LWS_KI }, { "B ", 1 },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
const lws_humanize_unit_t humanize_schema_us[] = {
|
||||
{ "y ", (uint64_t)365 * 24 * 3600 * LWS_US_PER_SEC },
|
||||
{ "d ", (uint64_t)24 * 3600 * LWS_US_PER_SEC },
|
||||
{ "hr ", (uint64_t)3600 * LWS_US_PER_SEC },
|
||||
{ "min", 60 * LWS_US_PER_SEC },
|
||||
{ "s ", LWS_US_PER_SEC },
|
||||
{ "ms ", LWS_US_PER_MS },
|
||||
{ "us ", 1 },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
int
|
||||
lws_humanize(char *p, int len, uint64_t v, const lws_humanize_unit_t *schema)
|
||||
{
|
||||
do {
|
||||
if (v >= schema->factor || schema->factor == 1) {
|
||||
if (schema->factor == 1)
|
||||
return lws_snprintf(p, len,
|
||||
" %4"PRIu64"%s ",
|
||||
v / schema->factor, schema->name);
|
||||
|
||||
return lws_snprintf(p, len, " %4"PRIu64".%03"PRIu64"%s",
|
||||
v / schema->factor,
|
||||
(v % schema->factor) / (schema->factor / 1000),
|
||||
schema->name);
|
||||
}
|
||||
schema++;
|
||||
} while (schema->name);
|
||||
|
||||
assert(0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ lwsl_timestamp(int level, char *p, int len)
|
|||
for (n = 0; n < LLL_COUNT; n++) {
|
||||
if (level != (1 << n))
|
||||
continue;
|
||||
now = lws_time_in_microseconds() / 100;
|
||||
now = lws_now_usecs() / 100;
|
||||
if (ptm)
|
||||
n = lws_snprintf(p, len,
|
||||
"[%04d/%02d/%02d %02d:%02d:%02d:%04d] %s: ",
|
||||
|
|
|
@ -345,10 +345,6 @@ struct lws_context {
|
|||
char worst_latency_info[256];
|
||||
#endif
|
||||
|
||||
#if defined(LWS_WITH_STATS)
|
||||
uint64_t lws_stats[LWSSTATS_SIZE];
|
||||
int updated;
|
||||
#endif
|
||||
#if defined(LWS_WITH_ESP32)
|
||||
unsigned long time_last_state_dump;
|
||||
uint32_t last_free_heap;
|
||||
|
@ -398,6 +394,10 @@ struct lws_context {
|
|||
unsigned short deprecation_pending_listen_close_count;
|
||||
|
||||
uint8_t max_fi;
|
||||
|
||||
#if defined(LWS_WITH_STATS)
|
||||
uint8_t updated;
|
||||
#endif
|
||||
};
|
||||
|
||||
int
|
||||
|
|
|
@ -390,7 +390,7 @@ lws_fts_search(struct lws_fts_file *jtf, struct lws_fts_search_params *ftsp)
|
|||
uint32_t children, instances, co, sl, agg, slt, chunk,
|
||||
fileofs_tif_start, desc, agg_instances;
|
||||
int pos = 0, n, m, nl, bp, base = 0, ra, palm, budget, sp, ofd = -1;
|
||||
unsigned long long tf = lws_time_in_microseconds();
|
||||
unsigned long long tf = lws_now_usecs();
|
||||
struct lws_fts_result_autocomplete **pac = NULL;
|
||||
char stasis, nac = 0, credible, needle[32];
|
||||
struct lws_fts_result_filepath *fp;
|
||||
|
@ -595,7 +595,7 @@ ensure:
|
|||
}
|
||||
} while(1);
|
||||
|
||||
result->duration_ms = (int)((lws_time_in_microseconds() - tf) / 1000);
|
||||
result->duration_ms = (int)((lws_now_usecs() - tf) / 1000);
|
||||
|
||||
if (!instances && !children)
|
||||
return result;
|
||||
|
|
|
@ -540,7 +540,7 @@ int
|
|||
lws_fts_fill(struct lws_fts *t, uint32_t file_index, const char *buf,
|
||||
size_t len)
|
||||
{
|
||||
unsigned long long tf = lws_time_in_microseconds();
|
||||
unsigned long long tf = lws_now_usecs();
|
||||
unsigned char c, linetable[256], vlibuf[8];
|
||||
struct lws_fts_entry *e, *e1, *dcl;
|
||||
struct lws_fts_instance_file *tif;
|
||||
|
@ -1083,7 +1083,7 @@ after:
|
|||
|
||||
/* dump the collected per-input instance and line data, and free it */
|
||||
|
||||
t->agg_trie_creation_us += lws_time_in_microseconds() - tf;
|
||||
t->agg_trie_creation_us += lws_now_usecs() - tf;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1094,7 +1094,7 @@ int
|
|||
lws_fts_serialize(struct lws_fts *t)
|
||||
{
|
||||
struct lws_fts_filepath *fp = t->filepath_list, *ofp;
|
||||
unsigned long long tf = lws_time_in_microseconds();
|
||||
unsigned long long tf = lws_now_usecs();
|
||||
struct lws_fts_entry *e, *e1, *s[256];
|
||||
unsigned char buf[8192], stasis;
|
||||
int n, bp, sp = 0, do_parent;
|
||||
|
@ -1354,7 +1354,7 @@ lws_fts_serialize(struct lws_fts *t)
|
|||
(int)(t->agg_trie_creation_us / 1000),
|
||||
(int)(lwsac_total_alloc(t->lwsac_head) / 1024),
|
||||
(int)(t->worst_lwsac_input_size / 1024),
|
||||
(int)((lws_time_in_microseconds() - tf) / 1000),
|
||||
(int)((lws_now_usecs() - tf) / 1000),
|
||||
(int)(t->c / 1024));
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -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 = lws_time_in_microseconds();
|
||||
uint64_t now = lws_now_usecs();
|
||||
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 = lws_time_in_microseconds();
|
||||
lws_esp32.genled_t = lws_now_usecs();
|
||||
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 = lws_time_in_microseconds();
|
||||
r = lws_now_usecs();
|
||||
us = r - lws_esp32.genled_t;
|
||||
|
||||
switch (lws_esp32.genled) {
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
|
||||
#include "core/private.h"
|
||||
|
||||
uint64_t
|
||||
lws_time_in_microseconds(void)
|
||||
lws_usec_t
|
||||
lws_now_usecs(void)
|
||||
{
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
|
|
|
@ -48,7 +48,7 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi)
|
|||
return 1;
|
||||
|
||||
pt = &context->pt[tsi];
|
||||
lws_stats_atomic_bump(context, pt, LWSSTATS_C_SERVICE_ENTRY, 1);
|
||||
lws_stats_bump(pt, LWSSTATS_C_SERVICE_ENTRY, 1);
|
||||
|
||||
{
|
||||
unsigned long m = lws_now_secs();
|
||||
|
|
|
@ -43,7 +43,7 @@ int lws_plat_apply_FD_CLOEXEC(int n)
|
|||
void TEE_GenerateRandom(void *randomBuffer, uint32_t randomBufferLen);
|
||||
#if defined(LWS_WITH_NETWORK)
|
||||
uint64_t
|
||||
lws_time_in_microseconds(void)
|
||||
lws_now_usecs(void)
|
||||
{
|
||||
return ((unsigned long long)time(NULL)) * 1000000;
|
||||
}
|
||||
|
|
|
@ -22,14 +22,22 @@
|
|||
#define _GNU_SOURCE
|
||||
#include "core/private.h"
|
||||
|
||||
|
||||
uint64_t
|
||||
lws_time_in_microseconds(void)
|
||||
lws_usec_t
|
||||
lws_now_usecs(void)
|
||||
{
|
||||
struct timeval tv;
|
||||
#if defined(LWS_HAVE_CLOCK_GETTIME)
|
||||
struct timespec ts;
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
return ((unsigned long long)tv.tv_sec * 1000000LL) + tv.tv_usec;
|
||||
if (clock_gettime(CLOCK_MONOTONIC, &ts))
|
||||
return 0;
|
||||
|
||||
return (ts.tv_sec * LWS_US_PER_SEC) + (ts.tv_nsec / LWS_NS_PER_US);
|
||||
#else
|
||||
struct timeval now;
|
||||
|
||||
gettimeofday(&now, NULL);
|
||||
return (now.tv_sec * 1000000ll) + now.tv_usec;
|
||||
#endif
|
||||
}
|
||||
|
||||
LWS_VISIBLE int
|
||||
|
|
|
@ -45,7 +45,7 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi)
|
|||
pt = &context->pt[tsi];
|
||||
vpt = (volatile struct lws_context_per_thread *)pt;
|
||||
|
||||
lws_stats_atomic_bump(context, pt, LWSSTATS_C_SERVICE_ENTRY, 1);
|
||||
lws_stats_bump(pt, LWSSTATS_C_SERVICE_ENTRY, 1);
|
||||
|
||||
if (timeout_ms < 0)
|
||||
goto faked_service;
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
#include "core/private.h"
|
||||
|
||||
|
||||
uint64_t
|
||||
lws_time_in_microseconds()
|
||||
lws_usec_t
|
||||
lws_now_usecs(void)
|
||||
{
|
||||
#ifndef DELTA_EPOCH_IN_MICROSECS
|
||||
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
|
||||
|
@ -56,7 +56,7 @@ lws_time_in_microseconds()
|
|||
#ifdef _WIN32_WCE
|
||||
time_t time(time_t *t)
|
||||
{
|
||||
time_t ret = lws_time_in_microseconds() / 1000000;
|
||||
time_t ret = lws_now_usecs() / 1000000;
|
||||
|
||||
if(t != NULL)
|
||||
*t = ret;
|
||||
|
|
|
@ -143,7 +143,7 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi)
|
|||
FD_ADDRESS_LIST_CHANGE);
|
||||
|
||||
ev = WSAWaitForMultipleEvents(1, &pt->events, FALSE,
|
||||
timeout_us / LWS_US_PER_MS, FALSE);
|
||||
(DWORD)(timeout_us / LWS_US_PER_MS), FALSE);
|
||||
if (ev == WSA_WAIT_EVENT_0) {
|
||||
EnterCriticalSection(&pt->interrupt_lock);
|
||||
interrupt_requested = pt->interrupt_requested;
|
||||
|
|
|
@ -480,17 +480,15 @@ try_pollout:
|
|||
return LWS_HPI_RET_HANDLED;
|
||||
}
|
||||
|
||||
lws_stats_atomic_bump(wsi->context, pt,
|
||||
LWSSTATS_C_WRITEABLE_CB, 1);
|
||||
lws_stats_bump(pt, LWSSTATS_C_WRITEABLE_CB, 1);
|
||||
#if defined(LWS_WITH_STATS)
|
||||
if (wsi->active_writable_req_us) {
|
||||
uint64_t ul = lws_time_in_microseconds() -
|
||||
uint64_t ul = lws_now_usecs() -
|
||||
wsi->active_writable_req_us;
|
||||
|
||||
lws_stats_atomic_bump(wsi->context, pt,
|
||||
LWSSTATS_MS_WRITABLE_DELAY, ul);
|
||||
lws_stats_atomic_max(wsi->context, pt,
|
||||
LWSSTATS_MS_WORST_WRITABLE_DELAY, ul);
|
||||
lws_stats_bump(pt, LWSSTATS_US_WRITABLE_DELAY_AVG, ul);
|
||||
lws_stats_max(pt,
|
||||
LWSSTATS_US_WORST_WRITABLE_DELAY, ul);
|
||||
wsi->active_writable_req_us = 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -270,8 +270,7 @@ lws_header_table_attach(struct lws *wsi, int autoservice)
|
|||
if (!n) {
|
||||
n = lws_peer_confirm_ah_attach_ok(context, wsi->peer);
|
||||
if (n)
|
||||
lws_stats_atomic_bump(wsi->context, pt,
|
||||
LWSSTATS_C_PEER_LIMIT_AH_DENIED, 1);
|
||||
lws_stats_bump(pt, LWSSTATS_C_PEER_LIMIT_AH_DENIED, 1);
|
||||
}
|
||||
#endif
|
||||
if (n) {
|
||||
|
@ -405,7 +404,7 @@ int __lws_header_table_detach(struct lws *wsi, int autoservice)
|
|||
#if defined(LWS_WITH_PEER_LIMITS)
|
||||
else
|
||||
if (!(*pwsi)->http.ah_wait_list)
|
||||
lws_stats_atomic_bump(context, pt,
|
||||
lws_stats_bump(pt,
|
||||
LWSSTATS_C_PEER_LIMIT_AH_DENIED, 1);
|
||||
#endif
|
||||
pwsi = &(*pwsi)->http.ah_wait_list;
|
||||
|
|
|
@ -125,17 +125,15 @@ try_pollout:
|
|||
/* clear back-to-back write detection */
|
||||
wsi->could_have_pending = 0;
|
||||
|
||||
lws_stats_atomic_bump(wsi->context, pt,
|
||||
LWSSTATS_C_WRITEABLE_CB, 1);
|
||||
lws_stats_bump(pt, LWSSTATS_C_WRITEABLE_CB, 1);
|
||||
#if defined(LWS_WITH_STATS)
|
||||
if (wsi->active_writable_req_us) {
|
||||
uint64_t ul = lws_time_in_microseconds() -
|
||||
uint64_t ul = lws_now_usecs() -
|
||||
wsi->active_writable_req_us;
|
||||
|
||||
lws_stats_atomic_bump(wsi->context, pt,
|
||||
LWSSTATS_MS_WRITABLE_DELAY, ul);
|
||||
lws_stats_atomic_max(wsi->context, pt,
|
||||
LWSSTATS_MS_WORST_WRITABLE_DELAY, ul);
|
||||
lws_stats_bump(pt, LWSSTATS_US_WRITABLE_DELAY_AVG, ul);
|
||||
lws_stats_max(pt,
|
||||
LWSSTATS_US_WORST_WRITABLE_DELAY, ul);
|
||||
wsi->active_writable_req_us = 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -49,7 +49,7 @@ lws_ssl_capable_read(struct lws *wsi, unsigned char *buf, int len)
|
|||
if (!wsi->tls.ssl)
|
||||
return lws_ssl_capable_read_no_ssl(wsi, buf, len);
|
||||
|
||||
lws_stats_atomic_bump(context, pt, LWSSTATS_C_API_READ, 1);
|
||||
lws_stats_bump(pt, LWSSTATS_C_API_READ, 1);
|
||||
|
||||
errno = 0;
|
||||
n = SSL_read(wsi->tls.ssl, buf, len);
|
||||
|
@ -61,12 +61,9 @@ lws_ssl_capable_read(struct lws *wsi, unsigned char *buf, int len)
|
|||
#endif
|
||||
#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,
|
||||
lws_time_in_microseconds() -
|
||||
wsi->accept_start_us);
|
||||
lws_stats_atomic_bump(wsi->context, pt,
|
||||
LWSSTATS_C_SSL_CONNS_HAD_RX, 1);
|
||||
lws_stats_bump(pt, LWSSTATS_US_SSL_RX_DELAY_AVG,
|
||||
lws_now_usecs() - wsi->accept_start_us);
|
||||
lws_stats_bump(pt, LWSSTATS_C_SSL_CONNS_HAD_RX, 1);
|
||||
wsi->seen_rx = 1;
|
||||
}
|
||||
#endif
|
||||
|
@ -107,7 +104,7 @@ lws_ssl_capable_read(struct lws *wsi, unsigned char *buf, int len)
|
|||
return LWS_SSL_CAPABLE_ERROR;
|
||||
}
|
||||
|
||||
lws_stats_atomic_bump(context, pt, LWSSTATS_B_READ, n);
|
||||
lws_stats_bump(pt, LWSSTATS_B_READ, n);
|
||||
|
||||
if (wsi->vhost)
|
||||
wsi->vhost->conn_stats.rx += n;
|
||||
|
|
|
@ -178,7 +178,7 @@ lws_ssl_capable_read(struct lws *wsi, unsigned char *buf, int len)
|
|||
if (!wsi->tls.ssl)
|
||||
return lws_ssl_capable_read_no_ssl(wsi, buf, len);
|
||||
|
||||
lws_stats_atomic_bump(context, pt, LWSSTATS_C_API_READ, 1);
|
||||
lws_stats_bump(pt, LWSSTATS_C_API_READ, 1);
|
||||
|
||||
errno = 0;
|
||||
ERR_clear_error();
|
||||
|
@ -191,11 +191,10 @@ lws_ssl_capable_read(struct lws *wsi, unsigned char *buf, int len)
|
|||
#endif
|
||||
#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,
|
||||
lws_time_in_microseconds() -
|
||||
lws_stats_bump(pt, LWSSTATS_US_SSL_RX_DELAY_AVG,
|
||||
lws_now_usecs() -
|
||||
wsi->accept_start_us);
|
||||
lws_stats_atomic_bump(wsi->context, pt,
|
||||
LWSSTATS_C_SSL_CONNS_HAD_RX, 1);
|
||||
lws_stats_bump(pt, LWSSTATS_C_SSL_CONNS_HAD_RX, 1);
|
||||
wsi->seen_rx = 1;
|
||||
}
|
||||
#endif
|
||||
|
@ -260,7 +259,7 @@ lws_ssl_capable_read(struct lws *wsi, unsigned char *buf, int len)
|
|||
/* keep on trucking it seems */
|
||||
}
|
||||
|
||||
lws_stats_atomic_bump(context, pt, LWSSTATS_B_READ, n);
|
||||
lws_stats_bump(pt, LWSSTATS_B_READ, n);
|
||||
|
||||
if (wsi->vhost)
|
||||
wsi->vhost->conn_stats.rx += n;
|
||||
|
|
|
@ -382,12 +382,10 @@ 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 = lws_time_in_microseconds();
|
||||
wsi->accept_start_us = lws_now_usecs();
|
||||
#endif
|
||||
errno = 0;
|
||||
lws_stats_atomic_bump(wsi->context, pt,
|
||||
LWSSTATS_C_SSL_CONNECTIONS_ACCEPT_SPIN,
|
||||
1);
|
||||
lws_stats_bump(pt, LWSSTATS_C_SSL_ACCEPT_SPIN, 1);
|
||||
n = lws_tls_server_accept(wsi);
|
||||
lws_latency(context, wsi,
|
||||
"SSL_accept LRS_SSL_ACK_PENDING\n", n, n == 1);
|
||||
|
@ -396,9 +394,7 @@ lws_server_socket_service_ssl(struct lws *wsi, lws_sockfd_type accept_fd)
|
|||
case LWS_SSL_CAPABLE_DONE:
|
||||
break;
|
||||
case LWS_SSL_CAPABLE_ERROR:
|
||||
lws_stats_atomic_bump(wsi->context, pt,
|
||||
LWSSTATS_C_SSL_CONNECTIONS_FAILED,
|
||||
1);
|
||||
lws_stats_bump(pt, LWSSTATS_C_SSL_CONNECTIONS_FAILED, 1);
|
||||
lwsl_info("SSL_accept failed socket %u: %d\n",
|
||||
wsi->desc.sockfd, n);
|
||||
wsi->socket_is_permanently_unusable = 1;
|
||||
|
@ -408,15 +404,14 @@ lws_server_socket_service_ssl(struct lws *wsi, lws_sockfd_type accept_fd)
|
|||
return 0;
|
||||
}
|
||||
|
||||
lws_stats_atomic_bump(wsi->context, pt,
|
||||
LWSSTATS_C_SSL_CONNECTIONS_ACCEPTED, 1);
|
||||
lws_stats_bump(pt, LWSSTATS_C_SSL_CONNECTIONS_ACCEPTED, 1);
|
||||
#if defined(LWS_WITH_STATS)
|
||||
if (wsi->accept_start_us)
|
||||
lws_stats_atomic_bump(wsi->context, pt,
|
||||
LWSSTATS_MS_SSL_CONNECTIONS_ACCEPTED_DELAY,
|
||||
lws_time_in_microseconds() -
|
||||
lws_stats_bump(pt,
|
||||
LWSSTATS_US_SSL_ACCEPT_LATENCY_AVG,
|
||||
lws_now_usecs() -
|
||||
wsi->accept_start_us);
|
||||
wsi->accept_start_us = lws_time_in_microseconds();
|
||||
wsi->accept_start_us = lws_now_usecs();
|
||||
#endif
|
||||
|
||||
/* adapt our vhost to match the SNI SSL_CTX that was chosen */
|
||||
|
|
|
@ -149,7 +149,7 @@ callback_minimal_spam(struct lws *wsi, enum lws_callback_reasons reason,
|
|||
|
||||
return -1;
|
||||
}
|
||||
lws_set_timeout(wsi, 1, LWS_TO_KILL_ASYNC);
|
||||
lws_set_timeout(wsi, PENDING_TIMEOUT_USER_OK, LWS_TO_KILL_ASYNC);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
Loading…
Add table
Reference in a new issue