Commit Graph

284 Commits

Author SHA1 Message Date
Stephen Seo 510156bc58 Have forgejo action/workflow use "any_archLinux"
Publish doxygen documentation to seodisparate.com / doxygen-gen-and-publish (push) Successful in 1s Details
Run UnitTests / build-and-run-tests (push) Successful in 44s Details
2024-01-22 11:12:58 +09:00
Stephen Seo 2cef0d541c std::atomic doesn't need volatile
Publish doxygen documentation to seodisparate.com / doxygen-gen-and-publish (push) Successful in 0s Details
Run UnitTests / build-and-run-tests (push) Successful in 25s Details
2024-01-14 10:31:38 +09:00
Stephen Seo ef164561c1 Reduce verbosity of unit test logs
Publish doxygen documentation to seodisparate.com / doxygen-gen-and-publish (push) Successful in 0s Details
Run UnitTests / build-and-run-tests (push) Successful in 22s Details
2024-01-12 16:36:01 +09:00
Stephen Seo 5738ff4ec0 Allow move for TSLQIter
Publish doxygen documentation to seodisparate.com / doxygen-gen-and-publish (push) Successful in 1s Details
Run UnitTests / build-and-run-tests (push) Successful in 18s Details
Should fix builds of UDPConnection.cpp with "-std=c++11".
2024-01-12 16:32:42 +09:00
Stephen Seo b781257a17 Github action: ensure current ref is checked out
Publish doxygen documentation to seodisparate.com / doxygen-gen-and-publish (push) Successful in 1s Details
Run UnitTests / build-and-run-tests (push) Successful in 21s Details
2024-01-12 14:31:36 +09:00
Stephen Seo 5de9fcfb22 Use apt-get, add libsodium dep to github action 2024-01-12 14:29:49 +09:00
Stephen Seo 6634a0bfdb Add Github action to run UnitTests 2024-01-12 14:26:11 +09:00
Stephen Seo 848bb98926 Add action/workflow to run UnitTest
Publish doxygen documentation to seodisparate.com / doxygen-gen-and-publish (push) Successful in 0s Details
Run UnitTests / build-and-run-tests (push) Successful in 30s Details
2024-01-12 14:06:14 +09:00
Stephen Seo 3f2c49572b Add UnitTest file for CXX11_shared_spin_lock
Publish doxygen documentation to seodisparate.com / doxygen-gen-and-publish (push) Successful in 0s Details
2024-01-12 13:55:28 +09:00
Stephen Seo 56ee5c3aed Tweak compare_exchange_weak(...) in spin-lock
Publish doxygen documentation to seodisparate.com / doxygen-gen-and-publish (push) Successful in 0s Details
2024-01-12 13:32:05 +09:00
Stephen Seo 07c7a405ae Fix invalid use of mutex in TSLQueue
Mutex was removed in favor of the custom SharedSpinLock.
2024-01-12 13:32:05 +09:00
Stephen Seo 4917fc47f6 Don't fail on "try" fns if failed to get spinLock
In SharedSpinLock: Only fail on "try" fns after spinLock was acquired
and condition is not met.
2024-01-12 13:32:05 +09:00
Stephen Seo a0f8bf0b41 Refactor shared-spin-lock to use atomic "spinLock" 2024-01-12 13:32:05 +09:00
Stephen Seo d1354b13d5 Minor refactorings 2024-01-12 13:32:05 +09:00
Stephen Seo 05087406b1 Reland C++11 "shared_lock" with iter remove fix
On iterator remove, the iterator will trade the read lock for a write
lock, and trade back for a read lock once the remove has been completed.
2024-01-12 13:32:05 +09:00
Stephen Seo 02651c793e Add note in docs about update for UDPC_init(...)
Publish doxygen documentation to seodisparate.com / doxygen-gen-and-publish (push) Successful in 0s Details
2024-01-12 13:31:36 +09:00
Stephen Seo 894a564774 Update LICENSE year
Publish doxygen documentation to seodisparate.com / doxygen-gen-and-publish (push) Successful in 0s Details
2024-01-11 21:05:21 +09:00
Stephen Seo bf84a1f2d4 Update debug optimization flag 2024-01-11 21:05:02 +09:00
Stephen Seo c03eae1c15 UnitTest for start/stop threaded update and fix
Publish doxygen documentation to seodisparate.com / doxygen-gen-and-publish (push) Successful in 0s Details
2024-01-11 20:07:25 +09:00
Stephen Seo de2848004f Enforce thread-safety on destroy context 2024-01-11 19:40:15 +09:00
Stephen Seo 186f2edf0f Use mutex when enabling/disabling threaded-update 2024-01-11 19:00:27 +09:00
Stephen Seo 74341e83d4 Use atomic_bool for auto-updating "flag" 2024-01-11 18:45:14 +09:00
Stephen Seo 5d24c4b5e6 Add note about usage of UDPC header in docs
Publish doxygen documentation to seodisparate.com / doxygen-gen-and-publish (push) Successful in 0s Details
2024-01-01 17:15:55 +09:00
Stephen Seo f4ed1aa136 Note in documentation about thread safety
Publish doxygen documentation to seodisparate.com / doxygen-gen-and-publish (push) Successful in 0s Details
Basically, all functions should be thread-safe unless mentioned
otherwise.
2024-01-01 12:25:04 +09:00
Stephen Seo ad0e62f718 Fixes to .forgejo/workflows/doxygen.yaml
Publish doxygen documentation to seodisparate.com / doxygen-gen-and-publish (push) Successful in 1s Details
2023-12-19 16:44:18 +09:00
Stephen Seo cb9d42e301 Update README.md
Publish doxygen documentation to seodisparate.com / doxygen-gen-and-publish (push) Successful in 0s Details
2023-12-19 12:59:10 +09:00
Stephen Seo a0100b1ed9 Use rsync setting up seodisparate doxygen docs
Publish doxygen documentation to seodisparate.com / doxygen-gen-and-publish (push) Successful in 0s Details
2023-12-19 12:54:52 +09:00
Stephen Seo 7227895240 Add Forgejo workflow for doxygen docs
Publish doxygen documentation to seodisparate.com / doxygen-gen-and-publish (push) Successful in 0s Details
2023-12-19 12:52:44 +09:00
Stephen Seo 611287b377 Revert "Impl "RWLock" for use in TSLQueue"
This reverts commit cf27a6bb76.

The use of "shared_lock" in TSLQueue is unsafe because of two things:

  - The TSLQueue iterator takes a "read" lock.
  - The TSLQueue iterator can erase the current element.
2023-07-22 17:28:33 +09:00
Stephen Seo ce092f81f9 Revert "Replace unnecessary use of atomic in "shared_lock""
This reverts commit b50e50b5fb.
2023-07-22 17:28:13 +09:00
Stephen Seo b50e50b5fb Replace unnecessary use of atomic in "shared_lock" 2023-07-22 16:46:38 +09:00
Stephen Seo cf27a6bb76 Impl "RWLock" for use in TSLQueue
This project supports C++11, and std::shared_lock was made available in
C++17, thus a "shared_spin_lock" was created with similar functionality.
This "shared_spin_lock" is used in TSLQueue.
2023-07-22 16:33:09 +09:00
Stephen Seo 64a0995e21 Fix CMakeLists.txt, handle -Weffc++ warnings 2023-07-22 13:25:43 +09:00
Stephen Seo 56465c280c Update README.md 2023-07-19 11:35:28 +09:00
Stephen Seo 97f030a3a3 Add docs for UDPC_no* functions 2023-07-04 11:41:45 +09:00
Stephen Seo 4887cc2ae5 Update README.md 2023-07-03 12:03:52 +09:00
Stephen Seo 972ec73e88 Refactor addr logprint via template specialization 2023-06-26 14:01:42 +09:00
Stephen Seo 77d69cabbc Impl "unsafe" versions of UDPC_atostr(...)
These "unsafe" versions are guaranteed to not have the returned address
strings be overwritten by UDPC, but they must be manually free'd later
(as mentioned in the documentation).
2023-06-22 13:25:26 +09:00
Stephen Seo 4abd9fddcb Conditionally use UDPC_atostr internally
Previous implementation used UDPC_atostr() frequently. This commit
changes the implementation to only call UDPC_atostr() if the log level
of the code logging to output will cause the log to be output.
2023-06-22 12:39:11 +09:00
Stephen Seo 390f3972f8 Add documentation for UDPC_atostr... 2023-06-22 12:07:26 +09:00
Stephen Seo 2495396d76 Fix potential memory corruption bug
UDPC_atostr(...) uses a uint32_t as an offset into a buffer inside the
UDPC Context such that there can be at most 32 different addr-strings.
The call is thread-safe, up to a point (at most 32 concurrent calls will
return correct strings). The problem was that the offset was not being
reset to 0 and was always being incremented by 40. Should the offset
overflow, the offset into the buffer will be "mis-aligned" such that the
32nd offset into the buffer can possibly overwrite memory past the
buffer's end if the addr string is long enough.

The fix is to use a mutex instead of an atomic uint32_t to lock a
code-block that will always prevent overflow (using modulus operator).

I think the speed-loss is negligable (using a lock instead of an atomic
uint32_t) since it isn't expected for programs using UDPC to use
UDPC_atostr(...) very frequently.
2023-06-21 13:23:26 +09:00
Stephen Seo 211715fc56 Fix potential nullptr deref in free_PacketInfo_ptr 2023-04-19 19:11:03 +09:00
Stephen Seo 3fac706d86 Add UDPC_free_PacketInfo_ptr(...)
Also add unit test for this function.
2023-04-19 18:50:26 +09:00
Stephen Seo 00b249bdc8 Update LICENSE year 2023-04-18 14:05:52 +09:00
Stephen Seo f18e87903a Refactor UDPC::get_empty_pinfo() 2023-04-18 14:03:31 +09:00
Stephen Seo 087d3cfc6f Impl handling Ctrl-C for Windows in NetworkTest 2023-01-10 12:14:57 +09:00
Stephen Seo 577ab0bc52 Better handling of receiving packets in recv loop
On error processing a received packet, continue to receive packets in
the loop. If no packet was received, the loop ends.
2023-01-10 11:51:54 +09:00
Stephen Seo a8ef89d9b1 Update documentation about UDPC_update(ctx) 2022-12-08 16:54:02 +09:00
Stephen Seo 77ac7f88a5 Receive packets in loop til none left in interval
Also some formatting fixes (max 80 chars in edited code).
2022-12-04 19:58:13 +09:00
Stephen Seo b7cd3a00c7 Update LICENSE 2022-11-23 14:14:05 +09:00