replace ifdefs around close socket with compatible_close

Signed-off-by: Andy Green <andy.green@linaro.org>
logging ensure everyone has a newline

Signed-off-by: Andy Green <andy.green@linaro.org>
add longlived option to test client

Needed to confirm pending timeouts won't kill the connection, by default
it spams the server with connections that live less than 5s

Signed-off-by: Andy Green <andy.green@linaro.org>
deal with SSL_ERROR_WANT_ in client connect action

"4b0e01f Retry SSL_connect when SSL_get_error requests it. " from David Galeano
noticed the problem that client connect may receive SSL_ERROR_WANT_* from
SSL_connect, which is basically WOULDBLOCK.  That patch tried to deal with it
by blocking in a while(1) until the condition went away.

That's problematic because of it blocks service of anything else (including
the host application sockets in the external socket poll sharing case) for
up to 5s controlled by conditions at one client.

After fiddling with and researching this, the actual problem with the code is
we are not getting the SSL layer error correctly, it is not contained in the
code returned from the Connect api directly.

I was unable to get a renegotiation forced on my modern SSL libs, it complained
about protocol error are reopened the connection instead.  So I think the stuff
found in the docs and the web about the SSL_ERROR_WANT_ is probably not something
we will see in reality (if we check the right error code...)

Signed-off-by: Andy Green <andy.green@linaro.org>
optimize extpoll fd delete

Previous method of shifting back array by one to cover the deleted
item could be expensive when the list was large and the deleted item
appeared early in it.

This scheme swaps the last guy into the vacant space and reduces the
list size by one.

(AG adapted for style and not to care if n is end guy)

Signed-off-by: Edwin van der Oetelaar <oetelaar.automatisering@gmail.com>
Signed-off-by: Andy Green <andy.green@linaro.org>
merge test server extpoll into test server

the -extpoll version of the test server was starting to rot compared to
the test-server.c it was originally based on.

This patch deletes the -extpoll.c version and instead has the test-server.c
source built two different ways in the makefile, once with the define
EXTERNAL_POLL which forces non-fork mode and enables the "by hand"
pollfd array handling.  The resulting binary of that is still called
libwebsockets-test-server-extpoll.

Another problem was that the pollfd array length needs to match MAX_CLIENTS, that
now happens during the build.

Signed-off-by: Andy Green <andy.green@linaro.org>
http service break into outer loop states

Previously we sat and looped to dump a file over http protocol.

Actually that's a source of blocking to the other sockets being serviced.

This patch breaks up the file service into a roundtrip around the poll()
loop for each 512-byte packet.  It doesn't make much difference if the
server is idle, but if it's busy it makes sure everyone else is getting
service while the file is sent.

It doesn't try to optimize multiple users of the file or to keep the
descriptor open, the point of this patch is to establish the breaking up
of the file send action into the poll loop.

On the user side, there are two differences:

 - context is now needed in the first argument to libwebsockets_serve_http_file()
that's not too bad since we provide context in the callback.

 - file send is now asynchronous to the user code, you get a new callback coming
in protocol 0 when it's done, LWS_CALLBACK_HTTP_FILE_COMPLETION

libwebsockets-test-server is updated accordingly.

Signed-off-by: Andy Green <andy.green@linaro.org>
extpoll break out of loop when set or clear finds fd

Signed-off-by: Edwin van der Oetelaar <oetelaar.automatisering@gmail.com>
make sure we have PATH_MAX on some linux toolchains
(AG modified a bit)


Signed-off-by: Jack Mitchell <ml@communistcode.co.uk>
allow building just the library not the testapps

From an idea by Jack Mitchell <ml@communistcode.co.uk>

Use --without-testapps at configure time to suppress building them

Signed-off-by: Andy Green <andy.green@linaro.org>
extpoll use hashtable for fd tracking

This implements a much faster, hashtable-based tracking scheme for
external poll fds.

Signed-off-by: Andy Green <andy.green@linaro.org>
allow LWS_SOMAXCONN to be defined at configuretime

Default remains at SOMAXCONN, you can force it at configure time
along these lines

./configure CFLAGS="-DLWS_SOMAXCONN=16384"

Signed-off-by: Andy Green <andy.green@linaro.org>
add empty m4 dir as workaround for autoreconf issue

Signed-off-by: Andy Green <andy.green@linaro.org>