The existing lib_v handling copied around to each change_pollfd instance
can be easily missed off if new change_pollfd uses are added. Instead
migrate it directly into change_pollfd to guarantee it is handled and
simplify the code.
Signed-off-by: Andy Green <andy.green@linaro.org>
Enforce no more internal use of deprecated apis (esp in the test apps)
Also signal clearly to users what is on the way out.
Signed-off-by: Andy Green <andy.green@linaro.org>
This adds support for multithreaded service to lws without adding any
threading or locking code in the library.
At context creation time you can request split the service part of the
context into n service domains, which are load-balanced so that the most
idle one gets the next listen socket accept.
There's a single listen socket on one port still.
User code may then spawn n threads doing n service loops / poll()s
simultaneously. Locking is only required (I think) in the existing
FD lock callbacks already handled by the pthreads server example,
and that locking takes place in user code. So the library remains
completely agnostic about the threading / locking scheme.
And by default, it's completely compatible with one service thread
so no changes are required by people uninterested in multithreaded
service.
However for people interested in extremely lightweight mass http[s]/
ws[s] service with minimum provisioning, the library can now do
everything out of the box.
To test it, just try
$ libwebsockets-test-server-pthreads -j 8
where -j controls the number of service threads
Signed-off-by: Andy Green <andy.green@linaro.org>
This adds redirect support to the client side. Lws will follow
server redirects (301) up to three deep.
Signed-off-by: Andy Green <andy.green@linaro.org>
- Mainly symbol length reduction
- Whitespace clean
- Code refactor for linear flow
- Audit @Context for API docs vs changes
Signed-off-by: Andy Green <andy.green@linaro.org>
Extend the cleanout caused by wsi having a context pointer
into the public api.
There's no point keeping the 1.5 compatibility work,
we have changed the api in several places and
rebuilt wasn't going to be enough a while ago.
Signed-off-by: Andy Green <andy.green@linaro.org>
Now we bit the bullet and gave each wsi an lws_context *, many
internal apis that take both a context and wsi parameter only
need the wsi.
Also simplify parser code by making a temp var for
allocated_headers * instead of the longwinded
dereference chain everywhere.
Signed-off-by: Andy Green <andy.green@linaro.org>
Because getaddrinfo will return error on Android when
AI_V4MAPPED is specified. So we should use old implemntation.
Android support of IPv6 is very poor.
This nukes all the oldstyle prefixes except in the compatibility code.
struct libwebsockets becomes struct lws too.
The api docs are updated accordingly as are the READMEs that mention
those apis.
Signed-off-by: Andy Green <andy.green@linaro.org>
Between changing to lws_ a few years ago and the previous two
patches migrating the public apis, there are only a few
internal functions left using libwebsocket_*.
Change those to also use lws_ without regard to compatibility
since they were never visible outside the library.
Signed-off-by: Andy Green <andy.green@linaro.org>
Change all internal uses of rationalized public apis to reflect the
new names.
Theer are a few things that got changed as side effect of search/replace
matches, but these are almost all internal. I added a compatibility define
for the public enum that got renamed.
Theoretically existing code should not notice the difference from these
two patches. And new code will find the new names.
https://github.com/warmcat/libwebsockets/issues/357
Signed-off-by: Andy Green <andy.green@linaro.org>
Simplifies proxy code to use the existing libwebsocket_set_proxy.
Enables libwebsocket_set_proxy() to parse username:password@ at front of
servername in both http_proxy and info->http_proxy_address.
If given the base64 version of the credentials are sent in the CONNECT
header to the proxy.
Port is now taken from info->http_proxy_address server:port syntax, but if
a port is given in the now deprecated info->http_proxy_port (ie, is nonzero)
then it is allowed to be missed out and the info port used instead for
backwards compatibility.
Signed-off-by: Andy Green <andy.green@linaro.org>
Improvemed patches to address travis and appveyor build errors
Reduced WINVER and _WIN32_WINNT to 0x0501 to be less restrictive
Refined CMakeLists.txt to allow for normal Windows and MinGW-specific OpenSSL certificate generation
Simplified include path to gettimeofday.h
Removed unnecessary list(APPEND LWS_LIBRARIES zlib_internal) export
Added back #include <windows.h> to gettimeofday.c to fix build for normal Windows
Made sure that pollfd gets defined on libwebsockets side when _WIN32_WINNT < 0x0600
Made sure that WINVER and _WIN32_WINNT don't get overridden by libwebsockets headers when already set to something greater than 0x0501
Added missing declaration of WSAPoll function for WINVER < 0x0600 in libwebsockets.h, eliminated invalid usages of pollfd instead of libwebsocket_pollfd in test-server.c
Cleaned up duplicate content in gettimeofday.c, removed header inclusions from gettimeofday.h and fixed include order in test-echo.c, test-ping.c and test-server.c to enable build with normal Windows and MinGW
Re-enabled debug_level in test-echo.c and made sure that the call to lws_set_log_level() is also active under Windows (just like in test-server.c); replaced all WIN32 occurrences by _WIN32 in test-echo.c, test-ping.c, and test-server.c
Removed build-msys.sh and added new section about how to build libwebsockets using MinGW to README.build.md
See: https://msdn.microsoft.com/en-us/library/windows/desktop/ms737625(v=vs.85).aspx
Specifically the section reading:
"Until the connection attempt completes on a nonblocking socket, all subsequent calls to connect on the same socket will fail with the error code WSAEALREADY, and WSAEISCONN when the connection completes successfully. Due to ambiguities in version 1.1 of the Windows Sockets specification, error codes returned from connect while a connection is already pending may vary among implementations. As a result, it is not recommended that applications use multiple calls to connect to detect connection completion. If they do, they must be prepared to handle WSAEINVAL and WSAEWOULDBLOCK error values the same way that they handle WSAEALREADY, to assure robust operation."
Maybe it will be better to move all lws_libev_io() inside
lws_change_pollfd() to avoid similar problems in future.
The same for lws_libev_accept() and insert_wsi_socket_into_fds().
This replaces gethostbyname in libwebsockets_get_peer_addresses and
in the client handshake path.
There's one left in lws-plat-win but that can be done another time.
Let's see how much damage that did to the cross-platform and option
builds...
Signed-off-by: Andy Green <andy.green@linaro.org>
This gets rid of all the platform-dependent #ifdef stuff and
migrates it into the new lws-plat-xxx.c files.
These are then included in a one-time test in libwebsockets.c
according basically to Windows or not.
The idea is from now on, all Windows-specific code should go in
lws-plat-win.c, where any kind of Windows perversion like DWORD
is fine.
Any new functions going in there should be named lws_plat_...
and be defined in all the lws-plat-xxx.c file (currently just
win32 and unix platforms are supported).
Signed-off-by: Andy Green <andy.green@linaro.org>
This provides a single place for pollfd event changing,
external locking for that and extpoll management.
It saves about 85 lines of duplication and simplifies the callers.
Signed-off-by: Andy Green <andy.green@linaro.org>