Skip to content
Snippets Groups Projects
Commit ba119e90 authored by Andy Green's avatar Andy Green
Browse files

lws_adopt_socket

parent 8c1f6026
No related branches found
No related tags found
No related merge requests found
...@@ -208,9 +208,17 @@ discover how many threads were actually allowed when the context was created. ...@@ -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 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. libwebsockets-test-server-pthread does it, for the FD locking callbacks.
There is no knowledge or dependency in lws itself about pthreads. How the If LWS_MAX_SMP=1, then there is no code related to pthreads compiled in the
locking is implemented is entirely up to the user code. 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 User api changes
---------------- ----------------
......
...@@ -1673,6 +1673,9 @@ lws_client_connect_extended(struct lws_context *clients, const char *address, ...@@ -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_VISIBLE LWS_EXTERN struct lws * LWS_WARN_UNUSED_RESULT
lws_client_connect_via_info(struct lws_client_connect_info * ccinfo); 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_VISIBLE LWS_EXTERN const char * LWS_WARN_UNUSED_RESULT
lws_canonical_hostname(struct lws_context *context); lws_canonical_hostname(struct lws_context *context);
......
...@@ -702,9 +702,16 @@ lws_http_transaction_completed(struct lws *wsi) ...@@ -702,9 +702,16 @@ lws_http_transaction_completed(struct lws *wsi)
return 0; return 0;
} }
/* /**
* either returns new wsi bound to accept_fd, or closes accept_fd and * lws_adopt_socket() - adopt foreign socket as if listen socket accepted it
* returns NULL, having cleaned up any new wsi pieces * @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 * LWS_VISIBLE struct lws *
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment