1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-16 00:00:07 +01:00
libwebsockets/test-apps
Andy Green 48366de1d1 unix plat: add minimal wsi fd map option
An lws context usually contains a processwide fd -> wsi lookup table.

This allows any possible fd returned by a *nix type OS to be immediately
converted to a wsi just by indexing an array of struct lws * the size of
the highest possible fd, as found by ulimit -n or similar.

This works modestly for Linux type systems where the default ulimit -n for
a process is 1024, it means a 4KB or 8KB lookup table for 32-bit or
64-bit systems.

However in the case your lws usage is much simpler, like one outgoing
client connection and no serving, this represents increasing waste.  It's
made much worse if the system has a much larger default ulimit -n, eg 1M,
the table is occupying 4MB or 8MB, of which you will only use one.

Even so, because lws can't be sure the OS won't return a socket fd at any
number up to (ulimit -n - 1), it has to allocate the whole lookup table
at the moment.

This patch looks to see if the context creation info is setting
info->fd_limit_per_thread... if it leaves it at the default 0, then
everything is as it was before this patch.  However if finds that
(info->fd_limit_per_thread * actual_number_of_service_threads) where
the default number of service threads is 1, is less than the fd limit
set by ulimit -n, lws switches to a slower lookup table scheme, which
only allocates the requested number of slots.  Lookups happen then by
iterating the table and comparing rather than indexing the array
directly, which is obviously somewhat of a performance hit.

However in the case where you know lws will only have a very few wsi
maximum, this method can very usefully trade off speed to be able to
avoid the allocation sized by ulimit -n.

minimal examples for client that can make use of this are also modified
by this patch to use the smaller context allocations.
2019-05-18 12:10:19 +01:00
..
android align private LWS_NO_EXTENSIONS to be same as public LWS_WITHOUT_EXTENSIONS 2018-04-06 10:38:03 +08:00
private clean up top level of project 2017-09-27 08:24:05 +08:00
1.png minimal client: add different paths to multi 2018-06-04 07:14:49 +08:00
2.png minimal client: add different paths to multi 2018-06-04 07:14:49 +08:00
3.png minimal client: add different paths to multi 2018-06-04 07:14:49 +08:00
4.png minimal client: add different paths to multi 2018-06-04 07:14:49 +08:00
5.png minimal client: add different paths to multi 2018-06-04 07:14:49 +08:00
6.png minimal client: add different paths to multi 2018-06-04 07:14:49 +08:00
7.png minimal client: add different paths to multi 2018-06-04 07:14:49 +08:00
8.png minimal client: add different paths to multi 2018-06-04 07:14:49 +08:00
candide.zip clean up top level of project 2017-09-27 08:24:05 +08:00
favicon.ico clean up top level of project 2017-09-27 08:24:05 +08:00
http2.png wss-over-h2: show feedback in test page if active 2018-04-06 10:38:03 +08:00
leaf.jpg clean up top level of project 2017-09-27 08:24:05 +08:00
libwebsockets-test-server.service clean up top level of project 2017-09-27 08:24:05 +08:00
libwebsockets.org-logo.png clean up top level of project 2017-09-27 08:24:05 +08:00
libwebsockets.org-logo.svg docs: cleanups 2018-11-21 17:03:29 +08:00
lws-cgi-test.sh http2: make usable 2017-10-16 17:13:49 +08:00
lws-common.js codacy: minor fixes 2018-10-13 08:16:27 +08:00
lws-ssh-test-keys Plugins: add ssh-base ssh server plugin 2017-10-16 16:59:57 +08:00
lws-ssh-test-keys.pub Plugins: add ssh-base ssh server plugin 2017-10-16 16:59:57 +08:00
test-client.c unix plat: add minimal wsi fd map option 2019-05-18 12:10:19 +01:00
test-lejp.c lejp: make sure child object close is not mistaken for parent 2019-05-02 09:28:38 +01:00
test-server.c cc0: align dedication to CC0 FAQ recommended format 2019-05-02 09:29:01 +01:00
test-sshd.c cc0: align dedication to CC0 FAQ recommended format 2019-05-02 09:29:01 +01:00
test.css test-app: upgrade test.html to have separate css and js for CSP 2018-09-11 18:27:59 +08:00
test.html minimal examples: update for CSP best practices 2018-11-21 17:03:29 +08:00
test.js codacy: minor fixes 2018-10-13 08:16:27 +08:00
wss-over-h2.png wss-over-h2: show feedback in test page if active 2018-04-06 10:38:03 +08:00