Commit graph

1087 commits

Author SHA1 Message Date
Andy Green
5dc62ead9d trac 40 client connection properly nonblocking
As spotted by JM on Trac#40

http://libwebsockets.org/trac/libwebsockets/ticket/40

client connect didn't do anything about being truly nonblocking.  This patch
should hopefully solve that.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-09-20 20:26:12 +08:00
Fujii Bunichiroh
e92947680a force failed header parse to act
''...Websocket servers return failure responses other than HTTP Status 101 in the case of
mismatches of WebSocket version or additional header data etc...
It seems that libwebsockets shows "WARN: problems parsing header" error in such cases without
calling any callbacks or returning error code. Is this right?
I modified lib/client.c to handle this.''

Signed-off-by: Fujii Bunichiroh <Bunichiroh.Fujii@jp.sony.com>
2013-09-18 21:01:02 +08:00
Andy Green
8eda4117dd remove bae64 decode and selftest
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-09-18 20:57:59 +08:00
Andy Green
512c246338 trac #39: allow fd 0 for connection
Reported (with fix) by Martijn The http://libwebsockets.org/trac/ticket/39

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-09-18 12:59:33 +08:00
Andy Green
9beedc163c trac 36 make libwebsocket_set_timeout public
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-09-18 08:47:15 +08:00
Andy Green
96d48fdc28 change LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION user param usage
Also audit the bail_nuke_ah usage as Daniel Griscom suggested.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-09-18 08:32:55 +08:00
David Gauchard
6c58228577 fix http incomplete send handling
Signed-off-by: David Gauchard <gauchard@laas.fr>
2013-06-29 10:24:16 +08:00
Joachim Bauch
8294c1fa4f Request "send" not to trigger SIGPIPE on errors. 2013-06-29 10:22:09 +08:00
Niall T. Davidson
db761be972 Added additional LWS_CALLBACK_CLOSED_HTTP callback to just_kill_connection branch of close_and_free_session 2013-06-29 10:16:18 +08:00
Joachim Bauch
d727e9f698 Support empty ping and pong packets. 2013-06-23 14:47:26 +08:00
Joachim Bauch
d8b8542d59 Declare "sha1_init" statically to avoid naming conflicts if linked statically with other libraries providing a method with the same name (e.g. OpenSSL). 2013-06-23 14:45:15 +08:00
Andy Green
0c9563bbd2 add LWS_CALLBACK_CLOSED_HTTP
Adds a callback to allow handling HTTP protocol connections
closing.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-06-10 22:54:40 +08:00
Andy Green
7cf6cb00c2 trac 28 - differentiate between http serving and accepted http connection
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-05-19 14:04:10 +08:00
Simon Wulf
502b9948f2 trac 28 brackets around POLLIN flag test
Signed-off-by: Simon Wulf <simonwulf.lund@bredband.net>
2013-05-06 06:14:03 +08:00
Andy Green
66986b2e85 log err if unable to open http file
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-05-03 21:13:35 +08:00
Andy Green
4e414e65bb trac 29 win32 EWOULDBLOCK
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-04-27 08:33:26 +08:00
Andy Green
3661d7be53 Trac 29: win32 fix LWS_VISIBLE issue
Reported-by: davetaflin
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-04-26 07:37:16 +08:00
Bob Roberts
ac04911dde cygwin compatibility
Signed-off-by: Bob Roberts <bobroberts177@gmail.com>
2013-04-25 09:16:30 +08:00
Peter Pentchev
9a4fef7ed6 Hide private library symbols
Signed-off-by: Peter Pentchev <roam@ringlet.net>
2013-03-30 09:52:21 +08:00
Andy Green
01b206e804 SOL_SNDBUF set to protocol rx size
This tells the OS to reserve a TX buffer at least the size of the biggest RX frame
expected, for both server and client connections.

In Linux, the OS reserves 2 x the requested amount.

This is aimed at reducing the partial large atomic frame send problem to the point
it's only coming at large atomic frames the OS balks at reserving the size for.

If you have a lot of data to send, it is better to split it into multiple writes,
and use the FIN / CONTINUATION websocket stuff to manage it.

See the "fraggle" test app for example code of how to do that.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-03-23 09:53:17 +08:00
Andy Green
98ba9e01b4 cosmetic debug improvements
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-03-23 09:44:47 +08:00
Andy Green
b55451c6d2 introduce api for unthrottle all connections of protocol
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-03-16 12:43:22 +08:00
Andy Green
ca0a129065 rxflow remove recursion and simplify
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-03-16 11:24:23 +08:00
Tobias Maier
37029d9081 replaced last remaining close on wsi->sock with compatible_close
Signed-off-by: Tobias Maier <tobias.maier@netplace.com>
2013-03-15 07:26:19 +08:00
Andy Green
2577c831f4 update service_fd comment and api docs
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-03-11 20:37:03 +08:00
Andy Green
0097a99082 remove autotools build
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-03-09 13:06:37 +08:00
Andy Green
b1a5e6c377 clear down wsi_lookup on allocation and clear pollfd revents if serviced
This should get rid of a valgrind uninitialized report when using extpoll,
and gives a new way to share the poll loop with external sockets.

If a pollfd says it has something, you can just pass it to
libwebsocket_serice_fd() whether it is a socket handled by lws or not.
If it sees it is a lws socket, the traffic will be handled and
pollfd->revents will be zeroed now.

If the socket is foreign to lws, it leaves revents alone.  So you can see
if you should service by checking the pollfd revents after letting
lws try to service it.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-03-09 12:56:35 +08:00
Andy Green
25eddab5c8 reduce httpd close debug spew
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-03-09 12:56:35 +08:00
Alex Rhatushnyak
9f2246eb35 correct example lws_write in header
Signed-off-by: Alex Rhatyshnyak <a.rhatushnyak@klervi.com>
2013-03-09 12:01:47 +08:00
Andy Green
38c570c6d2 dont leak when protocol agreement probs
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-03-09 11:52:18 +08:00
Henrik Abelsson
2bdbe7a969 Fix printf format error
Signed-off-by: Henrik Abelsson <henrik@abelsson.com>
2013-03-09 09:27:49 +08:00
Andy Green
646c98ab42 dont sweat unkknown method for client
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-03-09 09:09:55 +08:00
Andy Green
5a4f3ae7d0 POLLOUT during wait for server response not an error
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-03-09 09:09:46 +08:00
Andy Green
1bc12f9e99 trace 22 fix zero length close from client
close() from javascript api in Chrome and Firefox doesn't do the
right thing.  It's because the payload is zero-length (with a frame
key...)  This fixes it.

Reported-by: 巫书轶
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-28 17:11:29 +08:00
Andy Green
fc7c5e4539 reflect send completeness in lws_write return
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>
2013-02-23 10:50:10 +08:00
Andy Green
2672fb2d68 move ssl cipher list from compiletime to context creation time option
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>
2013-02-22 09:54:35 +08:00
Andy Green
8699cec50f remove MAX_HEADER_NAME_LENGTH from header
Still lurking aound as a ghost after all real usess of it
were removed with the minilex changes.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-22 09:38:54 +08:00
Joakim Soderberg
b82b0dd118 Print SSL error codes as well as the string.
CYASSL doesn't compile with the error strings in some configurations, so
it is nice to have the error code on SSL errors as well.
2013-02-22 09:28:15 +08:00
Joakim Soderberg
3baa08cac3 Fix LWS_NO_SERVER build.
"int n" was used also when server parts are not compiled, so don't put it inside the LWS_NO_SERVER ifdef.
2013-02-22 09:27:59 +08:00
Larry Hayes
bb66ac6ec1 keepalive swap interval and probes
The interval and probes members for setting keepalive options
per-connection on Linux were swapped.

Signed-off-by: Larry Hayes <lhayesg@gmail.com>
2013-02-22 09:16:20 +08:00
Edwin van den Oetelaar
8c8a8e149d provide socketfd at in param for LWS_CALLBACK_FILTER_NETWORK_CONNECTION
Signed-off-by: Edwin van den Oetelaar <oetelaar.automatisering@gmail.com>
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-20 20:56:59 +08:00
Andy Green
1c6e1422e6 trac 18 deal with service connection timing out
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>
2013-02-20 19:11:31 +08:00
Andy Green
0c2f4d865a update missed extpoll calls to use correct args for ssl
http://libwebsockets.org/trac/ticket/15#comment:16

Reported-by: Joakim Soderberg <joakim.soderberg@gmail.com>
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-19 19:19:51 +08:00
Andy Green
c6511a08b4 trac 17 update set_log_level api notice
http://libwebsockets.org/trac/ticket/17

Reported-by: dbrnz
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-19 10:01:48 +08:00
Andy Green
2af4d5b2e2 remove lws_ensure_user_space from public api change return
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>
2013-02-18 16:30:10 +08:00
Andy Green
8dac94da67 trim proxy ads plus hostname stg
128 should be fine for hostname and proxy ads

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-18 12:02:18 +08:00
Andy Green
760c3d4aa5 fix no extensions build
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-18 10:43:18 +08:00
Andy Green
a7521debde migrate client hs and c_port into ah
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-18 10:38:45 +08:00
Andy Green
6636eec8e5 minor type optimizations
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-18 10:34:25 +08:00
Andy Green
3b49848b36 remove current_alloc_len
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-02-18 10:29:22 +08:00