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

use context service buf in place of large stack arrays

Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
Andy Green 2013-02-08 13:01:02 +08:00
parent b8b247d3e1
commit e84652c4ea

View file

@ -719,8 +719,6 @@ libwebsocket_service_fd(struct libwebsocket_context *context,
int n; int n;
int m; int m;
struct timeval tv; struct timeval tv;
unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 1 +
MAX_USER_RX_BUFFER + LWS_SEND_BUFFER_POST_PADDING];
#ifdef LWS_OPENSSL_SUPPORT #ifdef LWS_OPENSSL_SUPPORT
char ssl_err_buf[512]; char ssl_err_buf[512];
#endif #endif
@ -856,15 +854,19 @@ libwebsocket_service_fd(struct libwebsocket_context *context,
#ifdef LWS_OPENSSL_SUPPORT #ifdef LWS_OPENSSL_SUPPORT
read_pending: read_pending:
if (wsi->ssl) { if (wsi->ssl) {
eff_buf.token_len = SSL_read(wsi->ssl, buf, sizeof buf); eff_buf.token_len = SSL_read(wsi->ssl,
context->service_buffer,
sizeof context->service_buffer);
if (!eff_buf.token_len) { if (!eff_buf.token_len) {
n = SSL_get_error(wsi->ssl, eff_buf.token_len); n = SSL_get_error(wsi->ssl, eff_buf.token_len);
lwsl_err("SSL_read returned 0 with reason %s\n", ERR_error_string(n, ssl_err_buf)); lwsl_err("SSL_read returned 0 with reason %s\n",
ERR_error_string(n, ssl_err_buf));
} }
} else } else
#endif #endif
eff_buf.token_len = eff_buf.token_len = recv(pollfd->fd,
recv(pollfd->fd, buf, sizeof buf, 0); context->service_buffer,
sizeof context->service_buffer, 0);
if (eff_buf.token_len < 0) { if (eff_buf.token_len < 0) {
lwsl_debug("Socket read returned %d\n", lwsl_debug("Socket read returned %d\n",
@ -893,7 +895,7 @@ read_pending:
* used then so it is efficient. * used then so it is efficient.
*/ */
eff_buf.token = (char *)buf; eff_buf.token = (char *)context->service_buffer;
#ifndef LWS_NO_EXTENSIONS #ifndef LWS_NO_EXTENSIONS
more = 1; more = 1;
while (more) { while (more) {