1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

instrument latency

Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
Andy Green 2013-01-29 12:37:35 +08:00
parent d636e35c2b
commit e000a709b3
3 changed files with 14 additions and 2 deletions

View file

@ -127,7 +127,9 @@ int lws_client_socket_service(struct libwebsocket_context *context, struct libwe
}
if (wsi->use_ssl) {
lws_latency_pre(context, wsi);
n = SSL_connect(wsi->ssl);
lws_latency(context, wsi, "SSL_connect LWS_CONNMODE_WS_CLIENT_ISSUE_HANDSHAKE", n, n > 0);
if (n < 0) {
n = SSL_get_error(wsi->ssl, n);
@ -165,7 +167,9 @@ int lws_client_socket_service(struct libwebsocket_context *context, struct libwe
return 0;
}
lws_latency_pre(context, wsi);
n = SSL_get_verify_result(wsi->ssl);
lws_latency(context, wsi, "SSL_get_verify_result LWS_CONNMODE_WS_CLIENT_ISSUE_HANDSHAKE", n, n > 0);
if ((n != X509_V_OK) && (
n != X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT ||
wsi->use_ssl != 2)) {
@ -190,12 +194,14 @@ int lws_client_socket_service(struct libwebsocket_context *context, struct libwe
/* send our request to the server */
lws_latency_pre(context, wsi);
#ifdef LWS_OPENSSL_SUPPORT
if (wsi->use_ssl)
n = SSL_write(wsi->ssl, pkt, p - pkt);
else
#endif
n = send(wsi->sock, pkt, p - pkt, 0);
lws_latency(context, wsi, "send or SSL_write LWS_CONNMODE_WS_CLIENT_ISSUE_HANDSHAKE", n, n >= 0);
if (n < 0) {
lwsl_debug("ERROR writing to client socket\n");

View file

@ -92,6 +92,7 @@ void lwsl_hexdump(void *vbuf, size_t len)
int lws_issue_raw(struct libwebsocket *wsi, unsigned char *buf, size_t len)
{
struct libwebsocket_context *context = wsi->protocol->owning_server;
int n;
#ifndef LWS_NO_EXTENSIONS
int m;
@ -132,9 +133,11 @@ int lws_issue_raw(struct libwebsocket *wsi, unsigned char *buf, size_t len)
lws_hexdump(buf, len);
#endif
lws_latency_pre(context, wsi);
#ifdef LWS_OPENSSL_SUPPORT
if (wsi->ssl) {
n = SSL_write(wsi->ssl, buf, len);
lws_latency(context, wsi, "SSL_write lws_issue_raw", n, n >= 0);
if (n < 0) {
lwsl_debug("ERROR writing to socket\n");
return -1;
@ -142,6 +145,7 @@ int lws_issue_raw(struct libwebsocket *wsi, unsigned char *buf, size_t len)
} else {
#endif
n = send(wsi->sock, buf, len, MSG_NOSIGNAL);
lws_latency(context, wsi, "send lws_issue_raw", n, n == len);
if (n != len) {
lwsl_debug("ERROR writing len %d to socket %d\n", len, n);
return -1;

View file

@ -214,8 +214,10 @@ int lws_server_socket_service(struct libwebsocket_context *context,
/* listen socket got an unencrypted connection... */
clilen = sizeof(cli_addr);
lws_latency_pre(context, wsi);
accept_fd = accept(pollfd->fd, (struct sockaddr *)&cli_addr,
&clilen);
lws_latency(context, wsi, "unencrypted accept LWS_CONNMODE_SERVER_LISTENER", accept_fd, accept_fd >= 0);
if (accept_fd < 0) {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
lwsl_debug("accept asks to try again\n");
@ -321,9 +323,9 @@ int lws_server_socket_service(struct libwebsocket_context *context,
LWS_CALLBACK_CLEAR_MODE_POLL_FD,
(void *)(long)wsi->sock, NULL, POLLOUT);
//lwsl_notice("LWS_CONNMODE_SSL_ACK_PENDING: pre\n");
lws_latency_pre(context, wsi);
n = SSL_accept(wsi->ssl);
//lwsl_notice("LWS_CONNMODE_SSL_ACK_PENDING: post %d\n", n);
lws_latency(context, wsi, "SSL_accept LWS_CONNMODE_SSL_ACK_PENDING\n", n, n == 1);
if (n != 1) {
m = SSL_get_error(wsi->ssl, n);