under load, writing packet sizes to the socket that are normally fine
can do partial writes, eg asking to write 4096 may only take 2800 of
it and return 2800 from the actual send.
Until now lws assumed that if it was safe to send, it could take any
size buffer, that's not the case under load.
This patch changes lws_write to return the amount actually taken...
that and the meaning of it becomes tricky when dealing with
compressed links, the amount taken and the amount sent differ. Also
there is no way to recover at the moment from a protocol-encoded
frame only being partially accepted... however for http file send
content it can and does recover now.
Small frames don't have to take any care about it but large atomic
sends (> 2K) have been seen to fail under load.
Signed-off-by: Andy Green <andy.green@linaro.org>
More flexible this way... NULL for the new member means use
the ssl library default set of ciphers, so as long as your info
struct is zerod by bss or memset, you don't need to do anything
about this change unless you want to set the cipher list.
Signed-off-by: Andy Green <andy.green@linaro.org>
- "make dist" will now produce a tar.gz file. This includes everything (not really what we want but a start).
- Got rid of a bunch of defines and variables that aren't used.
- Added the option LINK_TESTAPPS_DYNAMIC that enables linking to the shared library version of the lib for the test apps, instead of doing it statically like the default is.
- Fixed proper support for the --prefix stuff (-DCMAKE_INSTALL_PREFIX for cmake). (Don't specify /usr/local explicitly, that is the default anyway and will break other platforms).
- Note: I noticed a problem with the "INSTALL_DATADIR" define used by the test-apps. Since we hard code the path to the certs using this, doing "DESTDIR=/bla make install" will result in not being able to use the SSL mode for the test-apps since they won't find the certs. (This also applies to the autoconf project). Fixed this by setting "../share" as the default location instead of using the prefix.
Appending to the TEST_APP_LIST variable function did not work from within the create_test_app function (It would create a function scope variable with the same name and discard it). We instead need to use a macro for this.
The previous commit also removed the duplicate install for the test-apps (because we want all the install steps in one place in the file for clarity). That change made it obvious that the TEST_APP_LIST never gets populated.
Fixed so that the build options for the CMake project works:
- The test apps used the LWS_NO_EXTENSIONS define, so they needed lws_config.h included when building using CMake.
- Rename some options so that individual test apps can be turned off.
- Separate building the test-client/test-server and compiling the server/client parts into the lib.
- Don't include server or client specific sources into the build if they shouldn't be built.
- Added an error if both client and server parts are excluded at the same time (makes no sense).
- Removed duplicate install targets for the test apps.
- Commented out the WITH_LIBCRYPTO option since it isn't used at the moment.
Don't require the user to enable using the built-in BSD getifaddrs implementation on systems such as uclibc that lacks it manually.
Instead if getifaddrs doesn't exist, use the BSD one automatically, except if the user explicitly tells the user not to do this using WITHOUT_BUILTIN_GETIFADDRS (which will result in a compilation error, but at least with a nice error message explaining why).
While looking at http://libwebsockets.org/trac/ticket/18
noticed the flow for timeout in service_fd will do bad things
if the fd we came to service has timed out. It gets freed and
then "serviced'.
Reported-by: Joakim Soderberg <joakim.soderberg@gmail.com>
Signed-off-by: Andy Green <andy.green@linaro.org>
- Does everything as the autoconf script does (I think).
- Generates SSL certs for the test-server
- Installs all test apps.
- Defaults to /usr/local/
- "DESTDIR=/bla make install" works
- Append "libwebsockets" to start of the test-app names like the autoconf stuff does.
- Only tested on OSX so far...
The function has a logical problem when the size of the requested
allocation is 0, it will return NULL which is overloaded as
failure.
Actually the whole function is evil as an api, this patch moves
it out of the public API space and fixes it to return 0 for
success or 1 for fail. Private code does not need to to return
wsi->user_space and public code should only get that from the
callback as discussed on trac recently.
Thanks to Edwin for debugging the problem.
Reported-by: Edwin van den Oetelaar <oetelaar.automatisering@gmail.com>
Signed-off-by: Andy Green <andy.green@linaro.org>
send() is able to complete but not send everything asked...
we don't deal with that yet. On an ARM9 board, leaf.jpg
failed because the send() only accepted 7240 of 8192... not
a failure but it implies reporting partial send to the
caller. Work around by keeping the send buffer at 4096.
Signed-off-by: Andy Green <andy.green@linaro.org>
The header name buffer and its max length handling has actually
been unused since the minilex parser was introduced. We hold
parsing state in the lex-type parts and don't need to store or
worry about max length, since the parser will let us know as
soon as it can't be a match for the valid header names.
This strips it out reducing the per-connection allocation for
x86_64 with default configure from 224 to 160.
Signed-off-by: Andy Green <andy.green@linaro.org>
There's no proper transition to http union state until now.
It only becomes apparant there's a problem when you try to
return -1 from the HTTP callback, during the close action
it will try to close() a nonsense, nonzero fd pointer in
the uninitialized u.http union member.
This patch takes a copy of the allocated headers struct from
the u.hdr union state, transitions to u.http clearing down u
and then calls the HTTP callback with URI args pointing to
the still-in-scope ah allocation. After the call, the copy ah
is freed.
That makes sure we are in the correct union state while still
giving the HTTP callback access to the URI without having to
copy it around.
Reported-by: Edwin can den Oetelaar <oetelaar.automatisering@gmail.com>
Signed-off-by: Andy Green <andy.green@linaro.org>
The client spams the server with mirror protocol content
and then closes the connection. However the server wants to
send that content back to all the mirror protocol
connections, including the one that closed.
The result is during the send back phase we usually see an
error trying to send to the close client connection. Because
we don't return -1, we don't close it on server side and the
error repeats a lot before finally closing. This is a side-
effect of a recent patch to drain pending input before
really closing a dead connection.
This patch just changes it to return -1 on the failed send
attempt assertively closing the connection.
Signed-off-by: Andy Green <andy.green@linaro.org>
This adds a demonstration of how to use the http nonblocking
send action to the test server.
If you ask for /leaf.jpg from the test server, it will send
"by hand" a 2.4MB jpeg in HTTP, including the headers. See
the test server sources to see how it is done.
Although it's a file, and a jpeg image, actually the exact
same scheme will work for any data or mime type.
Signed-off-by: Andy Green <andy.green@linaro.org>
This now exercises the code for dealing with rx that spills over
the rx buffer. Single fraggle uses the default rx buffer size
of 4096, it also now exercises code around that.
Signed-off-by: Andy Green <andy.green@linaro.org>