While checking with ab, I found
commit 30cdb3ac8f
Author: Justin Chen <justinchen00@github.invalid.com>
Date: Thu Apr 14 21:40:53 2016 +0800
recv treat zero return as error
https://github.com/warmcat/libwebsockets/issues/475
turned ab performance to crap, reverting it made everything fast again.
recv manpage says there is three ways to get zero returned
1) When a stream socket peer has performed an orderly shutdown, the return value will be 0 (the traditional "end-of-file"
return).
2) Datagram sockets in various domains (e.g., the UNIX and Internet domains) permit zero-length datagrams. When such a
datagram is received, the return value is 0.
3) The value 0 may also be returned if the requested number of bytes to receive from a stream socket was 0.
we can't just assume it means the peer shut down.
If the peer shut down, then the event loop should get an event on the socket like POLLHUP and deal with it that way.
So the patch mentioned above is simply reverted here.
Signed-off-by: Andy Green <andy@warmcat.com>
AG: adapt to use switch on existing test-server-libuv app
AG: correct the foreign lifecycle to be valgrind clean
This adds a switch -f --foreign that makes the test-server-libuv test
create his own libuv loop outside of lws, and use lws on it before
destroying lws and then his own loop.
If selected, the foreign loop runs for 5s before lws and 10s after
lws is stopped, for testing purposes.
Signed-off-by: Denis Osvald <denis.osvald@sartura.hr>
If OOT lws plugins will be packaged as separate projects,
they're going to want to install their plugins somewhere
that makes sense for the package instead of one big lws
plugin dir.
This patch changes info to have a const char ** to a NULL
terminated array of directories it should search for
plugins. lwsws knows about this and you can add to the
dir array using config fragments like
{
"global": {
"plugin-dir": "/usr/local/share/coherent-timeline/plugins"
}
}
if the config fragment in /etc/lwsws/conf.d/ is also managed by the
package with the plugin, it can very cleanly add and remove itself
from lwsws based on package install status.
Signed-off-by: Andy Green <andy@warmcat.com>
Move the dummy stub protocol into the library as the default
if NULL protocols given, since that is likely to become popular.
Signed-off-by: Andy Green <andy@warmcat.com>
No dependency on test-server.h (just libwebsockets.h and getopt.h / syslog.h)
No need for any user callback code and all in one short file.
Signed-off-by: Andy Green <andy@warmcat.com>
There's no reason to not have the mounts linked list init also in the info
struct, rather than provide as a paramater to lws_create_vhost(). Now
is a good time to normalize that since this api only exists in master.
This also allows oldstyle "do everything at context creation time in one
vhost" guys to leverage mounts.
Also there's no reason the mounts linked-list pointer and all uses in lws
are non-const, so make them all explicitly const *.
Update the info struct docs to clarify which members are used when creating
a vhost and which for context creation.
Signed-off-by: Andy Green <andy@warmcat.com>
https://github.com/warmcat/libwebsockets/issues/501
This demonstrates how to do a 303 redirect on POST and provide
the results there, in both libwebsockets-test-server and the
plugin version.
Signed-off-by: Andy Green <andy@warmcat.com>
Ah a real bug... well done coverity, that could have been nasty.
readlink unusually doesn't NUL terminate the result... take care about it.
Signed-off-by: Andy Green <andy@warmcat.com>
resource_path is configured at cmake time (it's like /usr/share/libwebsockets-test-server)
it's true if you gave a >255 char path there it would blow up.
It's fixed but again not network-accessible.
Signed-off-by: Andy Green <andy@warmcat.com>
Just test app argument string handling, it is "HIGH" impact as Coverity
says but it's not network-accessible or in the library.
Signed-off-by: Andy Green <andy@warmcat.com>
This allows mounts to define the caching policy of the files inside them.
Support is added in lwsws for controlling it from the config files.
The api for serializing a mount struct opaquely is removed and lws_http_mount struct
made public... it was getting out of control trying to hide the options.
Signed-off-by: Andy Green <andy@warmcat.com>