vhost collect rx tx stats

Signed-off-by: Andy Green <andy@warmcat.com>
This commit is contained in:
Andy Green 2016-04-15 13:02:25 +08:00
parent 868b9f2ecb
commit 57f2007105
3 changed files with 4 additions and 69 deletions

View file

@ -667,6 +667,7 @@ struct lws_vhost {
#ifndef LWS_NO_EXTENSIONS
const struct lws_extension *extensions;
#endif
unsigned long rx, tx;
int listen_port;
unsigned int http_proxy_port;

View file

@ -173,6 +173,9 @@ lws_ssl_capable_read(struct lws *wsi, unsigned char *buf, int len)
return LWS_SSL_CAPABLE_ERROR;
}
if (wsi->vhost)
wsi->vhost->rx += n;
/*
* if it was our buffer that limited what we read,
* check if SSL has additional data pending inside SSL buffers.

View file

@ -265,75 +265,6 @@ int callback_http(struct lws *wsi, enum lws_callback_reasons reason, void *user,
return -1;
break;
}
#endif
#if 0
if (pss->client_finished)
return -1;
if (pss->fd == LWS_INVALID_FILE)
goto try_to_reuse;
/*
* we can send more of whatever it is we were sending
*/
sent = 0;
do {
/* we'd like the send this much */
n = sizeof(buffer) - LWS_PRE;
/* but if the peer told us he wants less, we can adapt */
m = lws_get_peer_write_allowance(wsi);
/* -1 means not using a protocol that has this info */
if (m == 0)
/* right now, peer can't handle anything */
goto later;
if (m != -1 && m < n)
/* he couldn't handle that much */
n = m;
n = lws_plat_file_read(wsi, pss->fd,
&amount, buffer + LWS_PRE, n);
/* problem reading, close conn */
if (n < 0) {
lwsl_err("problem reading file\n");
goto bail;
}
n = (int)amount;
/* sent it all, close conn */
if (n == 0)
goto penultimate;
/*
* To support HTTP2, must take care about preamble space
*
* identification of when we send the last payload frame
* is handled by the library itself if you sent a
* content-length header
*/
m = lws_write(wsi, buffer + LWS_PRE, n, LWS_WRITE_HTTP);
if (m < 0) {
lwsl_err("write failed\n");
/* write failed, close conn */
goto bail;
}
if (m) /* while still active, extend timeout */
lws_set_timeout(wsi, PENDING_TIMEOUT_HTTP_CONTENT, 5);
sent += m;
} while (!lws_send_pipe_choked(wsi) && (sent < 1024 * 1024));
later:
lws_callback_on_writable(wsi);
break;
penultimate:
lws_plat_file_close(wsi, pss->fd);
pss->fd = LWS_INVALID_FILE;
goto try_to_reuse;
bail:
lws_plat_file_close(wsi, pss->fd);
return -1;
#endif
break;