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

lws_adopt_socket

Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
Andy Green 2016-01-26 21:40:32 +08:00
parent 8c1f6026a7
commit ba119e9057
4 changed files with 597 additions and 390 deletions

View file

@ -208,9 +208,17 @@ discover how many threads were actually allowed when the context was created.
It's required to implement locking in the user code in the same way that
libwebsockets-test-server-pthread does it, for the FD locking callbacks.
There is no knowledge or dependency in lws itself about pthreads. How the
locking is implemented is entirely up to the user code.
If LWS_MAX_SMP=1, then there is no code related to pthreads compiled in the
library. If more than 1, a small amount of pthread mutex code is built into
the library.
8) New API
LWS_VISIBLE struct lws *
lws_adopt_socket(struct lws_context *context, lws_sockfd_type accept_fd)
allows foreign sockets accepted by non-lws code to be adopted by lws as if they
had just been accepted by lws' own listen socket.
User api changes
----------------

View file

@ -1673,6 +1673,9 @@ lws_client_connect_extended(struct lws_context *clients, const char *address,
LWS_VISIBLE LWS_EXTERN struct lws * LWS_WARN_UNUSED_RESULT
lws_client_connect_via_info(struct lws_client_connect_info * ccinfo);
LWS_VISIBLE LWS_EXTERN struct lws *
lws_adopt_socket(struct lws_context *context, lws_sockfd_type accept_fd);
LWS_VISIBLE LWS_EXTERN const char * LWS_WARN_UNUSED_RESULT
lws_canonical_hostname(struct lws_context *context);

View file

@ -702,9 +702,16 @@ lws_http_transaction_completed(struct lws *wsi)
return 0;
}
/*
* either returns new wsi bound to accept_fd, or closes accept_fd and
* returns NULL, having cleaned up any new wsi pieces
/**
* lws_adopt_socket() - adopt foreign socket as if listen socket accepted it
* @context: lws context
* @accept_fd: fd of already-accepted socket to adopt
*
* Either returns new wsi bound to accept_fd, or closes accept_fd and
* returns NULL, having cleaned up any new wsi pieces.
*
* LWS adopts the socket in http serving mode, it's ready to accept an upgrade
* to ws or just serve http.
*/
LWS_VISIBLE struct lws *

File diff suppressed because it is too large Load diff