Commit graph

132 commits

Author SHA1 Message Date
Andy Green
891628b33c lws_plat_fd add wsi to fops and helpers
Having the lws_context alone doesn't let us track state or act different
by wsi, which is the most interesting usecase.  Eg not only simply track
file position / decompression state per wsi but also act differently
according to wsi authentication state / associated cookies.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-14 06:43:35 +08:00
Andy Green
8203be6742 lws_get_ctx conversion
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-14 06:43:24 +08:00
Andy Green
95181d96a7 osx fix unsigned signed compare error
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-10 12:50:10 +08:00
Andy Green
4e442b7743 lws_plat_fd implement platform default handlers
This is a rewrite of the patch from Soapyman here

https://github.com/warmcat/libwebsockets/pull/363

The main changes compared to Soapyman's original patch are

 - There's no new stuff in the info struct user code does any overrides
   it may want to do explicitly after lws_context_create returns

 - User overrides for file ops can call through (subclass) to the original
   platform implementation using lws_get_fops_plat()

 - A typedef is provided for plat-specific fd type

 - Public helpers are provided to allow user code to be platform-independent
   about file access, using the lws platform file operations underneath:

static inline lws_filefd_type
lws_plat_file_open(struct lws_plat_file_ops *fops, const char *filename,
		   unsigned long *filelen, int flags)

static inline int
lws_plat_file_close(struct lws_plat_file_ops *fops, lws_filefd_type fd)

static inline unsigned long
lws_plat_file_seek_cur(struct lws_plat_file_ops *fops, lws_filefd_type fd,
		       long offset_from_cur_pos)

static inline int
lws_plat_file_read(struct lws_plat_file_ops *fops, lws_filefd_type fd,
		   unsigned long *amount, unsigned char *buf, unsigned long len)

static inline int
lws_plat_file_write(struct lws_plat_file_ops *fops, lws_filefd_type fd,
		    unsigned long *amount, unsigned char *buf, unsigned long len)

There's example documentation and implementation in the test server.

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-10 11:01:59 +08:00
Andy Green
1cc03887f4 clean reduce windows build warnings
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-06 08:00:03 +08:00
Andy Green
d607bb9bfe clean more whitespace 2
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-06 05:52:09 +08:00
Andy Green
5c9660da61 clean tidy the worst whitespace alignment probs due to mass token name length changes
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-12-04 11:30:53 +08:00
Andy Green
4b85c1d4ac api rationalization: eliminate all libwebsocket[s]_ prefixes
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>
2015-12-04 11:08:32 +08:00
Andy Green
3ef579b4f9 api rationalization eliminate oldstyle internal api names
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>
2015-12-04 09:23:56 +08:00
Andy Green
6230476455 api rationalization use new names internally
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>
2015-12-04 08:43:54 +08:00
Andy Green
11f27345d2 mbed3 workable plus or minus mbed3 net stack bug
https://github.com/ARMmbed/sockets/issues/35

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-11-14 16:33:21 +08:00
Andy Green
8c0d3c035c mbed3 plat
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-11-14 16:31:59 +08:00
Andy Green
2cd3074746 mbed3 warning cleaning
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-11-14 16:31:01 +08:00
Andy Green
fc772ccc00 win use platform invalid socket api elsewhere too
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-11-14 13:48:58 +08:00
Andrejs Hanins
140ac6e9cb Subject: [PATCH] Fix for close ack sending
It was forgotten in two places that pending close ack should be
processed when wsi state is WSI_STATE_RETURNED_CLOSE_ALREADY, but
not WSI_STATE_ESTABLISHED. As a result, close ack wasn't sent out
to the peer.
2015-11-07 07:04:46 +08:00
Stephan Eberle
b820e2c2cc Implemented fixes allowing libwebsockets to be built under Windows using MinGM/MSYS
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
2015-10-30 00:16:40 +01:00
Andy Green
c6f95d3f27 keepalive close file when send completes dont wait for wsi close processing
Signed-off-by: Andy Green <andy.green@linaro.org>
2015-10-27 07:07:14 +08:00
Mark Likness
dbe624de76 allow EAGAIN and friends on straight read 2015-10-15 21:21:06 +08:00
Andy Green
6f1e8849bd use send MSG_NOSIGNAL
after

810dbadd6b

Signed-off-by: Andy Green <andy.green@linaro.org>
2015-10-12 08:43:36 +08:00
=?UTF-8?q?Jos=C3=A9=20Luis=20Mill=C3=A1n?=
4c0ba02771 fix #309. Receive large messages over WSS
Read the full incoming TLS/SSL record at once in libwebsocket_service_fd().

SSL_read() is called until no more pending data for the current record is buffered in SSL.
SSL_read() is never requested more than the pending data size for the current record
to ensure that the fd is not read again for new data, which would be copied in the SSL buffer otherwise.
2015-10-12 08:07:38 +08:00
=?UTF-8?q?Dalibor=20Ba=C4=8Da?=
5400f47efe [PATCH] added timeout reset in serve_http_file_fragment to prevent timeout on big files 2015-10-11 16:14:11 +08:00
Alejandro Mery
6ff28248aa Subject: [PATCH] Use custom allocator
Signed-off-by: Alejandro Mery <amery@geeks.cl>
2014-12-05 07:26:26 +08:00
Andy Green
7ef4b2e1f2 coverity 83661 output check lseek return
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-11-30 13:10:26 +08:00
Andy Green
1cea5816fa http2 dont use incoming END_STREAM when sending headers
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-10-19 07:36:20 +08:00
Andy Green
b0e2e50c75 http2 working nghttp fetch multi files completely
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-10-18 18:54:04 +08:00
Andy Green
200f385716 http2 track content length add END_STREAM
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-10-18 12:23:05 +08:00
Andy Green
91b0589795 http2 handle flags
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-10-17 09:33:16 +08:00
Andy Green
1e49918a4f trac 89 add flag on fatal send fail to use simple close
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-10-16 08:23:46 +08:00
Andy Green
2add6340d5 http2 hpack basic decode ok including huff
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-10-12 08:38:16 +08:00
Andy Green
1f5c9f0c31 ssl_capable_read add context param
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-10-09 08:14:30 +08:00
Andy Green
095d303b49 http2 fix build when http2 disabled
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-10-08 12:15:29 +08:00
Andy Green
024eb6c80c http2 can keep upgraded connection up
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-10-08 12:00:53 +08:00
Andy Green
822241c2a7 deprecate no_buffer_all_partials
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-08-18 22:21:51 +08:00
Andy Green
f4ffc1e215 fixes for close flush
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-10 17:06:59 +08:00
Andy Green
a1a24d26a6 close should flush any truncated send before really closing
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-10 14:25:24 +08:00
Andy Green
d7340c141f clean=various ifdef reduction
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-10 14:08:10 +08:00
Andy Green
15d56dd9da truncated send always callback on writeable
Suggested by a Windows log where leaf.jpg meets EAGAIN and after
issuing the truncated send buffer, never sends any more

https://github.com/warmcat/libwebsockets/issues/111#issuecomment-39873129

Added note in README.coding about WRITEABLE callbacks able to
be generated by lws.

Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-10 11:23:18 +08:00
Andy Green
485abc1c66 allow signals during send
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-06 12:41:20 +01:00
Andy Green
02138126f2 refactor add ssl read write single implementation
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-06 06:26:35 +01:00
Andy Green
b49a995a8d clean small additional ifdef reduction
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-03 10:11:04 +08:00
Andy Green
2c24ec0211 refactor out most NO_EXTENSIONS
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-02 19:45:42 +08:00
Andy Green
158e804cb7 refactor out WIN32 tests from code
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>
2014-04-02 14:25:10 +08:00
Andy Green
03cf1dde39 truncated send issue independent of LWS_NO_EXTENSIONS 2
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-01 14:20:44 +08:00
Andy Green
5bc002e424 only use clean buffer for failed write if sent something
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-04-01 09:59:39 +08:00
Patrick Gansterer
0fc37b64f6 windows Use WSAWaitForMultipleEvents() instead of poll() on Windows 2014-03-29 09:54:40 +08:00
Andy Green
28b12ad0af ssl output handle want read write
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-03-23 12:02:52 +08:00
Andy Green
e254d9589d truncated send keep and grow truncation buffer
Also change from looking at wsi->truncated_send_malloc to see if we are in the middle of
dealing with a truncated send to looking for nonzero wsi->truncated_send_len

Signed-off-by: Andy Green <andy.green@linaro.org>
2014-03-23 11:41:15 +08:00
Andy Green
27e770b0ef clean output.c a little
Signed-off-by: Andy Green <andy.green@linaro.org>
2014-03-23 11:21:51 +08:00
Patrick Gansterer
2dbd837c41 WSAGetLastError() instead of errno on Windows
Error codes set by Windows Sockets are not made available through the errno
variable. Checking them via WSAGetLastError() is the corret solution.
2014-02-28 20:08:55 +08:00
Patrick Gansterer
e5720a347e Cleanup include statements
Remove useless includes and add some preprocessor conditions for platform specific headers.
2014-02-28 08:51:35 +08:00