Commit graph

1880 commits

Author SHA1 Message Date
Andy Green
6f047eea6c ensure accept is nonblocking
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-28 11:23:52 +08:00
Andy Green
52f28ce67a autocreate foreign broadcast sockets on broadcast
Also introduce libwebsockets_broadcast_foreign() separate from libwebsockets_broadcast()

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-25 17:52:16 +08:00
Andy Green
fefc6585db trac 5 sa_restorer deprecated
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-23 08:32:03 +08:00
Andy Green
d88146da6a trac 3 document write and context_user
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-22 23:09:01 +08:00
Andy Green
75006171d7 trac 4 correct libebsocket_service_fd
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-22 12:32:11 +08:00
Andy Green
ab40eaa8db update numbers for minimal build footprint
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-21 13:20:33 +08:00
Andy Green
35f332bb46 more LWS_NO_DAEMONIZE
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-21 13:06:38 +08:00
Andy Green
5c54d622ff use correct LWS_NO_DAEMONIZE on test server
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-21 12:58:04 +08:00
Andy Green
bdd6bf3ccd bind gcc debug generation to_DEBUG
Either generate debug sections in output or optimize aggressively,
controlled by the existing --disable-debug

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-21 12:19:30 +08:00
Andy Green
623a98dab0 unionize mutually exclusive wsi members
Large chunks of struct libwebsocket members actually have a mutually
exclusive lifecycle, eg, once the http headers are finished they sit
there unused until the instance is destroyed.

This makes a big improvement in memory efficiency by making four
categories of member: always needed, needed for header processing,
needed for http processing, and needed for ws processing.  The last
three are mutually exclusive and bound into a union inside the wsi.

Care needs taking now at "union transitions", although we zeroed down
the struct at init, the other union siblings have been writing the
same memory by the time later member siblings start to use it.  So
it must be cleared down appropriately when we cross from one
mutually-exclusive use to another.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-21 11:06:34 +08:00
Andy Green
80f168b4ee key_b64 doesnt need to be in wsi
It's only used in some client code and never seen again

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-21 11:04:49 +08:00
Andy Green
f862463e2e avoid PATH_MAX in bss in daemonize
PATH_MAX is typically 4KB, let's malloc space for the
actual path instead and just have the pointer in bss

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-21 10:36:12 +08:00
Andy Green
5738c0e838 remove all support for pre v13 protocols
Since v13 was defined as the released ietf version the older versions
are deprecated.  This patch strips out everything to do with the older
versions and gets rid of the option to send stuff unmasked.

The in-tree md5 implementation is then also deleted as nothing needs
it any more, 1280 loc are shed in all

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-21 09:53:35 +08:00
Andy Green
f5bc1306ef disable private broadcast sockets if enable no fork config option
The whole thing about count_protocols + 1 broadcast sockets and
associated dummy wsis is a workaround for getting a broadcast from
a different process context, if we are running with --enable-no-fork
then we don't need any of it in.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-21 09:09:52 +08:00
Edwin van den Oetelaar
596b220c40 align test server extpoll with library dynamic approach
Signed-off-by: Edwin van den Oetelaar <oetelaar.automatisering@gmail.com>
2013-01-20 20:51:14 +08:00
Andy Green
5c81e804fa document memory efficiency
This puts some numbers of library size with the various --without
and --disable options and about dynamic memory allocation
performance

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-20 20:24:30 +08:00
Andy Green
a17c692cd3 log major dynamic allocation info
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-20 20:21:54 +08:00
Andy Green
13ba5bbc63 zlib not needed if no extensions
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-20 18:26:20 +08:00
Andy Green
3182ece3a4 introduce without extensions
The new --without-extensions config flag completely removes all code
and data related to extensions from the build throughout the library
when given.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-20 17:08:31 +08:00
Andy Green
6c1f64e992 refactor README
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-20 11:28:06 +08:00
Edwin van den Oetelaar
f6eeabc749 syslog requires format string
Signed-off-by: Edwin van den Oetelaar <oetelaar.automatisering@gmail.com>
2013-01-19 20:01:01 +08:00
Andy Green
f431247270 revert zlib update 1.2.7
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-19 15:11:23 +08:00
Andy Green
24cba92c7e make use of lock file
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-19 14:39:24 +08:00
FNA
0bf3ef605d windows compatibility changes for private libwebsockets
Signed-off-by: FNA <aqiruse@gmail.com>
2013-01-19 13:58:06 +08:00
Andy Green
fd6764a1fb test server add daemonization flag
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-19 13:13:48 +08:00
Andy Green
058ba81017 test server use syslog logging
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-19 13:11:26 +08:00
Andy Green
69e436444e allow_use_of_lwsl_logging in user code
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-19 13:11:24 +08:00
Andy Green
c11db201cf helper api: log through syslog
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-19 13:11:10 +08:00
Andy Green
b3a614add9 logging select some lwsl_info usage to be lwsl_notice
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-19 13:08:17 +08:00
Andy Green
7c19c34f9a add lwsl_notice
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-19 12:18:07 +08:00
Andy Green
0b31909cce expose log level in emit
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-19 11:53:45 +08:00
Andy Green
3662b663bc change bitfield setting to avoid gcc warnings
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-19 11:53:41 +08:00
Andy Green
10601c1fba improve frame_is_binary setting
Gregory Junker <ggjunker@gmail.com> noticed the binary flag is not
getting set right, or at all on client side.  This should improve
matters.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-19 10:39:35 +08:00
Andy Green
acbaee649a add lws_confirm_legit_wsi
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-18 22:00:22 +08:00
Andy Green
a1ce6be947 refactor and introduce without server configure option
Move server-only stuff into their own files and make building
that depend on not having --without-server on the configure

Make fragments in other places conditional as well

Remove client-related members from struct libwebscket when
building LWS_NO_CLIENT

Apps:

normal: build test server, client, fraggle, ping
--without-client: build test server
--without-server: build test client, ping

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-18 11:43:21 +08:00
Andy Green
2fd3f2f78f introdice tracking if frame is binary
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-18 09:49:20 +08:00
Edwin van den Oetelaar
759c9ac465 different compiler warning fixes
Solve some unchecked return codes in the new daemonization file

AG adapted a bit

Signed-off-by: Edwin van den Oetelaar <oetelaar.automatisering@gmail.com>
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-18 09:20:54 +08:00
Andy Green
6d1fcb7a95 add lexical parser for headers
Profiling what happens during the ab test, one of the hotspots
was strcasecmp in a loop looking for header name matches each time.

This patch introduces a lexical parser that creates a state machine
in 276 bytes that encodes all the known header names.  The fsm is
walked bytewise as chaacters come in... most states do not need any
recursion to match or fail.

The state machine output is cut-and-pasted into parsers.c as an
unsigned char array.

The fsm generator is a bit rough and ready, included in the tree but
not built since normal mortals won't need to touch it.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-18 01:55:48 +08:00
Andy Green
4a673a38ca deprecate x google mux
Unfortunately this code is beginning to rot due to lack of demand to
provide it and it being disabled by default.

If demand appears we can revert this and resume work on it, otherwise
let's bite the bullet for the moment.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-17 19:53:16 +08:00
Andy Green
706961dbb5 solve flowcontrol problems
Problems with rx flow control implementation were the underlying cause
of the connection stalling issue that was covered up with the udelay()
patch that was removed recently.

This get rx flow control working properly and corrects problems with
fifo management in the test server mirror protocol code too.

The rxfow control api has been changed to just set a flag, so it's very cheap
to call from user code.  After the callbacks that might use the rxflow control
api the flag is checked and any pending actions done.

rx flow control now stops any rx packet coming immediately, with compessed
connections "just what was left in the pipe" might be hundreds of KBytes.  To
implement that the current packet being decoded is copied into a malloc'd buffer
by the rx processing code now.

When rxflow is allows to come again, the buffer is drained and freed before any
new packet content is accepted.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-17 17:18:55 +08:00
Andy Green
0303db482e check errors on shutdown close
Also make sure CLOSE doesn't go through extension munging

Reduce wait for close ack to 1s

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-17 17:07:52 +08:00
Andy Green
dfb2304168 replace hashtable polltable management
This rips out the connection hashtable implementation along with
MAX_CLIENTS and replaces it with a dynamically allocated fds array
and lookup table along the same lines as the new extpoll implementation
from Edwin van den Oetelaar.

It detects the max number of file descriptors possible at context init
time and allocates accordingly; this can be externally controlled by
ulimit and the server run as a specific user to facilitate targeting
specific ulimit rules at it.

Many operations that translated between socket descriptors and struct
websocket or pollfd objects have had iteration removed by this patch
and under load will be a lot faster.

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-17 15:50:10 +08:00
Edwin van der Oetelaar
6c720c4440 use simple lookup table for extpoll
Hash stuff is overkill since Edwin found a max connection limit of 30000 on his
box anyway.  Just use a simple preallocated lookup table and fds array.

AG Modified for style and removed debugging bits

Signed-off-by: Edwin van der Oetelaar <oetelaar.automatisering@gmail.com>
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-17 15:50:09 +08:00
Andy Green
b2de95d2d4 include daemonization file whoops
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-17 15:49:27 +08:00
Andy Green
eff73742bc portability dont assume size of tv.t_usec
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-17 15:02:02 +08:00
Andy Green
6304686509 add disable debug to README configuration options list
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-17 10:15:52 +08:00
Peter Young
27b3237392 including assert h needed on osx
Signed-off-by: Peter Young <young40@qq.com>
2013-01-17 10:10:10 +08:00
Peter Young
26757a75bc just use limits.h directly
Signed-off-by: Peter Young <young40@qq.com>
2013-01-17 10:08:16 +08:00
Andy Green
279a303662 introduce daemonize
Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-17 10:05:39 +08:00
Andy Green
d32bb9128b client allow remote server to accept with no protocol set
Needed if our clientside can connect to, eg, echo.websocket.org

Signed-off-by: Andy Green <andy.green@linaro.org>
2013-01-17 00:50:48 +08:00