mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
use context service buffer instead of stack for server_socket_service
Reduces lws_server_socket_service from 4208 to 80 stack allocation on x86_64 Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
parent
5f348a80a0
commit
0390608a39
1 changed files with 3 additions and 5 deletions
|
@ -126,8 +126,6 @@ libwebsocket_create_new_server_wsi(struct libwebsocket_context *context)
|
|||
int lws_server_socket_service(struct libwebsocket_context *context,
|
||||
struct libwebsocket *wsi, struct pollfd *pollfd)
|
||||
{
|
||||
unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 1 +
|
||||
LWS_MAX_SOCKET_IO_BUF + LWS_SEND_BUFFER_POST_PADDING];
|
||||
struct libwebsocket *new_wsi;
|
||||
int accept_fd;
|
||||
unsigned int clilen;
|
||||
|
@ -153,10 +151,10 @@ int lws_server_socket_service(struct libwebsocket_context *context,
|
|||
|
||||
#ifdef LWS_OPENSSL_SUPPORT
|
||||
if (wsi->ssl)
|
||||
len = SSL_read(wsi->ssl, buf, sizeof buf);
|
||||
len = SSL_read(wsi->ssl, context->service_buffer, sizeof context->service_buffer);
|
||||
else
|
||||
#endif
|
||||
len = recv(pollfd->fd, buf, sizeof buf, 0);
|
||||
len = recv(pollfd->fd, context->service_buffer, sizeof context->service_buffer, 0);
|
||||
|
||||
if (len < 0) {
|
||||
lwsl_debug("Socket read returned %d\n", len);
|
||||
|
@ -171,7 +169,7 @@ int lws_server_socket_service(struct libwebsocket_context *context,
|
|||
return 0;
|
||||
}
|
||||
|
||||
n = libwebsocket_read(context, wsi, buf, len);
|
||||
n = libwebsocket_read(context, wsi, context->service_buffer, len);
|
||||
if (n < 0)
|
||||
/* we closed wsi */
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue