Commit graph

24 commits

Author SHA1 Message Date
Nick Hainke
b50f9bff6d network: add timeout for client connections
Somtimes client connetions will not close therfore add a timeout. Add a
new timer that checks every 5s if we did not receive anything from a
client for (default) 60s. Can be configured via client_timeout.

Code is based on the work of ptpt52.

Signed-off-by: Nick Hainke <vincent@systemli.org>
2022-07-20 20:12:04 +02:00
Ian Clowes
9187665f8e treewide: improve maintaince
General revisions to maintain code (no functional changes intended).
Removed unnecessary linked-list length checks.
Fixed some typos on function names / comments.
Changed how test_storage forces SEGV due to new compiler warnings.

Signed-off-by: Ian Clowes <clowes_ian@hotmail.com>
2022-01-17 10:10:47 +01:00
Ian Clowes
6bf9b6df9a memory: Tighten up some memory handling to help spot errors
Set pointers to NULL after free() to help force out memory handling errors.
Add some extra memory / resource tracking to try and chase out latent
bugs / leaks Fixed a couple of memory traces that were misreporting.

Signed-off-by: Ian Clowes <clowes_ian@hotmail.com>
2022-01-17 10:10:47 +01:00
Ian Clowes
4df0c986f1 treewide: improve logging
Provide multi-priority syslog() based logging to improve user and
developer experience. Add dawnlog_* functions and macros to convert
printf() family and perror() logging to syslog() family. Removed
unnecessary sprintf() for building log strings (embed format directly).
Add local config settings for log level. Add command line parameters for
log level and destination. Set default log level to suppress a lot of
previously noisy messages. Restore some previously removed noisy
messages as DEBUG level in case they help in future. Eliminate DAWN_NO_OUTPUT static code checks which are no longer used.

Signed-off-by: Ian Clowes <clowes_ian@hotmail.com>
2022-01-17 10:10:47 +01:00
Eneas U de Queiroz
c9f6684021 Remove some debugging messages
Remove some of the debugging messages, so that, hopefully, only the
relevant ones are shown.

Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
2021-08-05 21:51:44 +02:00
Eneas U de Queiroz
14e0f8386c Don't display debugging output with DAWN_NO_OUTPUT
This adds #infndef DAWN_NO_OUTPUT to messages printed to stdout that are
not warnings or errors.

Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
2021-08-05 21:51:44 +02:00
Ian Clowes
50d54a6253 tcpsocket: leave loop if we read 0 byte
It can happen that the callback is executed but there are 0 bytes to read. If this happens we leave the while-loop.

Ian Clowes:
- fix

Nick:
- commit message
2020-08-07 12:05:27 +02:00
Ian Clowes
dfbaa055a4 tcpsocket: fix read callback function and arbitrary memory allocations
If not all of the message was in the stream after the header was read,
the next bytes remain in the buffer and only the header is removed from
the stream. The next time the callback is called, something that is not
a header will be interpreted as a header, resulting in arbitrary memory
allocations.

Ian Clowes:
- code

Nick:
- commit message
- fix processing of messages
2020-08-06 23:57:06 +02:00
Ian Clowes
34da5328f6 memory auditing: bug fixes to memory auditing and hearing map
memory auditing: refined auditing code and use in main code
hearing map: fixed bug causing it not be be built correctly
datastorage: fixed memory leak from linked list handling
2020-08-05 12:29:47 +02:00
Ian-Clowes
d56c5c4e15 general: add memory auditing
memory_utils: added to wrap memory alloc / free
general: adjusted stabdard and other memory allocs t be audited
2020-08-05 12:28:49 +02:00
Ian Clowes
67c3ed0d0a test_storage: extend test harness; datastorage: two bug fixes
datastorage (bug fix): deleting expired array item would fail to test next item
test_storage: extended to cover all required datastorage entry points
test_storage: added ability to read script file
test_storage: added new and revised test scripts
TESTING.md: added to describe testing approach
general: added various TODO notes on things to come back to
general: revised #includes to make each "self-compiling"
general: revised #includes to minimise usage across source files
general: moved declarations and defintions to simplify and rationalise code
datastorage: refactor to support scalability testing
datastorage: made independent of time() calls to support testing
datastorage: fixed redundant use of both SORT_NUM and SORT_LENGTH defines
datastorage: fake kicking to test clients move between access points
msghandler: new module to reduce compile time interdependencies
mshhandler: (issue #100?) fixed SEGV memcpy() in dump_client() using strncpy()
ubus: merged uface into ubus
mac_utils: new module for MAC address utilites
test_header: added target to help #include rationalisation

Tested-by: Nick Hainke <vincent@systemli.org>
2020-07-12 13:47:23 +02:00
twy_2000
0f63e00c43 tcpsocket: free con after ustream write error and make list each safe list_each is not safe against removal of list entry 2020-06-18 22:16:42 +02:00
twy_2000
a6d0ea3d1d tcpsocket: ustream_pending_data before ustream_read
according to https://github.com/yousong/osocks/blob/master/main.c#L149
and ustream source code, directly ustream_read would make many packge incomplete.
2020-06-18 12:29:29 +02:00
twy_2000
b49c5b8552 malloc: add malloc failure wrapper 2020-06-18 12:29:14 +02:00
twy_2000
b029a40b11 Revert "Revert "tcpsocket: implement client_read_cb with ustream_read my wheels are much worse than offical wheels.""
This reverts commit c2a63293d1.
2020-06-18 12:29:10 +02:00
Polynomialdivision
c2a63293d1 Revert "tcpsocket: implement client_read_cb with ustream_read my wheels are much worse than offical wheels."
This reverts commit f7343a053c.
2020-06-12 10:45:33 +02:00
twy_2000
f7343a053c tcpsocket: implement client_read_cb with ustream_read my wheels are much worse than offical wheels. 2020-06-12 07:12:36 +02:00
David Woodhouse
050c1d7fed tcpsocket: use fixed size and endianness for length prefix of network messages
We can't use host-dependent endianness for network traffic.
The size of size_t also varies from host to host so stick with uint32_t.

Fixes: #92
2020-06-08 13:19:21 +02:00
Polynomialdivision
2151db28ef tcpsocket: fix debug msg format
Fixes: https://github.com/openwrt/packages/issues/12410
2020-06-05 11:08:50 +02:00
twy_2000
653ce9fa56 network/tcpsocket: make sure every msg is complete before handle 2020-05-29 22:51:28 +02:00
Ian Clowes
50d347c233 datastorage: refactor to support scalability testing 2020-05-28 00:29:15 +02:00
twy_2000
6bad02bed7 tcpsocket: fix port print 2020-05-10 09:51:48 +02:00
Polynomialdivision
899eae05f0 survive reboot 2020-04-15 17:37:59 +02:00
Polynomialdivision
f03f55ff92 first version 2020-03-23 21:22:21 +01:00