adopt test

Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
Andy Green 2016-02-26 09:22:12 +08:00
parent 701d8e8c43
commit 55da5d46a5
2 changed files with 30 additions and 3 deletions

View file

@ -1130,9 +1130,35 @@ try_pollout:
break;
}
if (!lws_adopt_socket(context, accept_fd))
/* already closed cleanly as necessary */
return 1;
{
static const char *taken = "GET /default HTTP/1.1\r\n"
"Host: server.example.com\r\n"
"Upgrade: websocket\r\n"
"Connection: Upgrade\r\n"
"Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==\r\n"
"Sec-WebSocket-Protocol: default\r\n"
"Sec-WebSocket-Version: 13\r\n"
"Origin: http://example.com\r\n\r\n";
struct lws *w;
char discard[2000];
lwsl_err("adopt test *********\n");
/* drain the real headers that may be there or
* will shortly come on the socket
*/
n = 0;
while (!n)
n = read(accept_fd, discard, sizeof(discard));
lwsl_err("discarded %d from real socket\n", n);
w = lws_adopt_socket_readbuf(context,
accept_fd, taken, strlen(taken));
lwsl_err("adopt test: returns %p", w);
}
#if LWS_POSIX
} while (pt->fds_count < context->fd_limit_per_thread - 1 &&

View file

@ -460,6 +460,7 @@ lws_service_flag_pending(struct lws_context *context, int tsi)
for (n = 0; n < context->max_http_header_pool; n++)
if (pt->ah_pool[n].rxpos != pt->ah_pool[n].rxlen &&
!pt->ah_pool[n].wsi->hdr_parsing_completed) {
lwsl_err("forcing POLLIN\n");
pt->fds[pt->ah_pool[n].wsi->position_in_fds_table].revents |=
pt->fds[pt->ah_pool[n].wsi->position_in_fds_table].events &
LWS_POLLIN;