913 Commits

Author SHA1 Message Date
Aleksandar Fabijanic
6d602ea6b3 5150 reactor sock remove (#5151)
* fix(NotificationCenter): use RWLock to prevent lock-order-inversion #5150

Change NotificationCenter from Mutex to RWLock to fix TSAN lock-order-inversion
warnings when notification handlers call back into the notification center
(e.g., hasEventHandler() from within a SocketReactor handler).

Key changes:
- Replace Mutex with RWLock for better read concurrency
- Use read locks for hasObserver(), observersToNotify(), hasObservers(),
  countObservers(), backlog()
- Use write locks for addObserver(), removeObserver(), clear()
- observersToNotify() now copies observer list and releases lock before
  calling accepts() to avoid lock cycle with NObserver's internal mutex
- Add clear() method to atomically disable and remove all observers
- Update AsyncNotificationCenter to use RWLock::ScopedLock

Also fixes AsyncNotificationCenter shutdown to properly signal the dequeue
thread via ShutdownNotification instead of relying only on wakeUpAll() #5058

* fix(Net): add SocketReactor::remove() for safe socket cleanup #5150

Add SocketReactor::remove() method that atomically removes a socket
from the poll set and disables all its event handlers. This prevents
race conditions when removing handlers in destructors, where events
could still be dispatched to handlers while other handlers for the
same socket are being removed.

Changes:
- Add SocketReactor::remove(socket) for atomic socket removal
- Add SocketNotifier::disableObservers() to disable all handlers
- Add SocketNotifier::socket() getter
- Skip dispatch for removed sockets in dispatch() methods
- Update tests to use remove() before removeEventHandler()
- Add testSocketReactorRemove() test

* fix(Foundation): improve ProcessRunner robustness #5054

- Fix race condition: set _pPH after _pid to ensure pid() returns
  valid value when running() returns true
- Add upfront invalid PID validation before termination attempt
- Escalate to Process::kill() if requestTermination times out,
  with its own timeout before throwing
- Try to remove stale PID file on timeout instead of throwing
- Wrap start() wait logic in try/catch to kill orphan process
  and reset state if startup fails
- Clear _error under lock after successful stop to prevent
  stale error from affecting next start()

* Update Net/include/Poco/Net/SocketReactor.h

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update Foundation/src/AsyncNotificationCenter.cpp

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update Foundation/include/Poco/AsyncNotificationCenter.h

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update Foundation/src/AsyncNotificationCenter.cpp

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* chore: add TaskManager::testCancel to win ignore list

* chore: few improvements in NotificationCenter and ODBC cmake.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Matej Kenda <matejken@gmail.com>
2026-01-06 19:18:31 +01:00
Aleksandar Fabijanic
bd09152aff feat(ODBC): nix shells for mssql and oracle #5144 (#5145)
* feat(ODBC): nix shells for mssql and oracle #5144

* fix(cmake): not using cppignore #5146

* fix(Data/ODBC): Improve Nix CI container startup and debugging

Oracle (oracle.nix):
- Add --shm-size=1g for Oracle container (requires 1GB shared memory)
- Add container state verification before exec commands
- Add proper error handling with container log output on failure
- Add pre-flight checks in build_and_test to verify container running
- Add Podman environment info for CI debugging
- Add progress indicators during Oracle startup wait
- Exit with error in CI mode if container fails to start

MSSQL (mssql.nix):
- Add ODBCINSTINI environment variable
- Add sync command to flush ODBC configs to disk
- Add odbcinst verification commands

Temporarily disable all ci except nix #5144

* try newer oracle version

* use ubuntu 24.04 for nix ci (podman related)

* chore(c): restore ci.yml

* Update Data/ODBC/oracle.nix

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update Data/ODBC/oracle.nix

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update Data/ODBC/mssql.nix

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update Data/ODBC/oracle.nix

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix(odbc): verify oracle downloads #5144

* chore(doc): update nix documentation #5144

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-05 05:13:58 +01:00
Aleksandar Fabijanic
e45d2067cb fix(Net): TSAN warnings #5147 (#5148) 2026-01-05 05:10:47 +01:00
Matej Kenda
38eb412c9c fix: Move bundled dependency symlinks to library-specific .gitignore files #5048 2025-12-23 18:52:31 +01:00
Matej Kenda
1461ec618b fix: Resolve compiler warnings and fix potential bugs (#5130) 2025-12-22 15:27:11 +01:00
Matej Kenda
8057019f85 fix(Net): Handle negative available() return in receiveBytes (#4537)
Co-Authored-By: Andrew Auclair <mightymalakai33@gmail.com>
2025-12-18 12:59:35 +01:00
Matej Kenda
752343adc7 fix(Net): Detect incomplete chunked transfer encoding (#5032) 2025-12-18 10:59:49 +01:00
Matej Kenda
26054b8f93 fix(Net): Make Socket::select() deprecation conditional (#5055) 2025-12-18 09:57:59 +01:00
SmileGobo
abfd684c03 fix(Net): Dispatch ErrorNotification to socket-specific handler only 2025-12-18 00:38:33 +01:00
Matej Kenda
7addcfbc81 fix: Resolve compiler warnings across multiple modules 2025-12-17 18:06:59 +01:00
Matej Kenda
b79b07c308 fix: Resolve compiler warnings in Net, Zip, and Foundation modules (#5092) 2025-12-17 07:53:12 +01:00
Matej Kenda
0631ae1b38 fix(Net): Use MessageHeader::quote() for boundary in HTMLForm 2025-12-17 06:55:53 +01:00
Matej Kenda
a6648ee8c3 Foundation simplifications with modern cpp (#5086)
* enh(Logger): simplified logging macros.

* enh(Delegate): Simplify code with constexpr and std::conditional_t.

* enh(NumericString): Simplify code with constexpr and std::is_signed_v.

* enh(MetaProgramming): Simplify code with C++17 equivalents.

* enh(Tuple): Simplify code with C++17 equivalents.

* enh(TypeList): Remove metaprogramming features that are not used.

* enh(Modules): Remove obsolete Foundation functionality

* enh(Foundation): Compile and run deprecated functionality only when POCO_TEST_DEPRECATED is enabled. Update comments for deprecated functionality.

* fix(Modules): Add missing conditional forward declarations for Foundation.
2025-12-16 07:53:45 +01:00
Matej Kenda
227f84fb8b fix(Net): Add POCO_HAS_UNIX_SOCKET guards to fix build without Unix sockets #5064 2025-12-16 06:50:21 +01:00
Copilot
b35f44c552 Fix WebSocket sendFrame delay by enabling TCP_NODELAY (#5077)
* Initial plan

* Fix WebSocket sendFrame delay by enabling TCP_NODELAY

- Enable TCP_NODELAY in WebSocketImpl constructor to prevent Nagle's algorithm
  from buffering small WebSocket frames
- Add check to skip TCP_NODELAY for Unix domain sockets
- Add documentation about TCP_NODELAY behavior to WebSocket class
- Tested with existing WebSocket test suite - all tests pass

Co-authored-by: aleks-f <2429093+aleks-f@users.noreply.github.com>

* Address code review feedback

- Avoid unnecessary SocketAddress object construction by calling family() directly
- Use specific exception type (Poco::Exception) instead of catch-all

Co-authored-by: aleks-f <2429093+aleks-f@users.noreply.github.com>

* Refine exception handling for TCP_NODELAY configuration

- Catch specific exception types (NetException, IOException, InvalidArgumentException)
  instead of broad Poco::Exception
- Improve error handling comments for clarity

Co-authored-by: aleks-f <2429093+aleks-f@users.noreply.github.com>

* Consolidate exception handling for better maintainability

- Combine catch blocks since all exceptions are handled identically
- Improve code clarity with more descriptive comments

Co-authored-by: aleks-f <2429093+aleks-f@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: aleks-f <2429093+aleks-f@users.noreply.github.com>
2025-12-09 02:05:39 +01:00
Aleksandar Fabijanic
03dedff47e 5069 missing dll (#5071)
* fix(SharedLibrary): Missing DLLs not reported #5069

* fix(CMake): not producing proper binary names #5070

* fix(SharedLibrary): disable shared lib tests in static build #5069

* fix(misc): add pdjson links to gitignore, remove unused var in SharedLibrary, harden TaskManagerTest

* fic(ci): separate oracle and sqlserver odbc (out of disk space) (#5075)

* fic(ci): separate oracle and sqlserver odbc (out of disk space)

* use oracle odbc driver

* use oracle free

* ad db user

* postpone adding user after build

* remove default tablespace (does not exist)

* reinstate all ci jobs

* add postgresl odb tests to ci

* remove spurious syminks

* fix gitignore (pdjson)

* Remove VS projects #5076

* chore: revert leftover ODB IP address

* fix(CodeQL): float comparison alerts

* fix: compile errors

* chore: upgrade asan to macos-14 (tryout)

* fix(CI): Github macos-13 runner is deprecated, use macos-15-intel to run tests on Intel macOS

---------

Co-authored-by: Matej Kenda <matejken@gmail.com>
2025-12-09 02:04:50 +01:00
Matej Kenda
8a4a2955d5 Use nullptr in C++ code (solves #4348) (#5043)
* chore(CppParser): 0, NULL --> nullptr

* chore(Crypto): 0, NULL --> nullptr

* chore(DNSSD): 0, NULL --> nullptr

* chore(Encodings): 0, NULL --> nullptr

* chore(CppUnit): Correct indentation.

* chore(Foundation): 0, NULL --> nullptr

* chore(CMake): Always warn about wrong nullptr usage when compiling with GCC or CLang

* chore(Net): 0, NULL --> nullptr

* chore(Foundation): 0, NULL --> nullptr

* chore(Data): 0, NULL --> nullptr

* chore(macOS): 0, NULL --> nullptr

* chore(XML): 0, NULL --> nullptr

* chore(Zip): 0, NULL --> nullptr

* chore(Util): 0, NULL --> nullptr

* chore(Net/NetSSL): 0, NULL --> nullptr

* chore(Bonjour): 0, NULL --> nullptr

* chore(MongoDB, Redis): 0, NULL --> nullptr

* chore(Poco): 0, NULL --> nullptr

* chore(Win32): 0, NULL --> nullptr

* chore(CMake): Only warn about nullptr when verbose warnings are enabled.

* Potential fix for code scanning alert no. 1634: Guarded Free

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* chore(Net): Fix warning reported by gitlab.

* chore(gitlab CI): attempt to clean to gain disk space on the runner.

* chore(gitlab CI): Run build with  --parallel 4, correct docker cleanup.

---------

Co-authored-by: Aleksandar Fabijanic <aleks-f@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2025-10-30 15:20:53 +01:00
Lara Dzivdzanovic
3e10fb2b0f Adapt makefiles for external dependencies (#5049)
* build(makefile): adapt makefiles for external dependencies

* chore(makefile): remove redundant src directory
2025-10-22 14:55:41 +02:00
sky92zwq
68616db653 Add an implementation of reactor http server (#4946)
* reactor http server

* fix

* test logic

* add reactor server session , use buf to cache socket buffer

* add reactor example

* fix: nodelay, otherwise ack will be after 50 ms

* tcp reactor server support multi listener

* fix: tcp reactor connection lifetime about socket

* feat: add tcp reactor params

* format

* check http reqeust complete, dynamic size buffer in reactor

* remove try catch

* remove debug logger

* remove debug logger

* fix: should not pop in destructor

* delete useless

* remove cankeepalive temporarily, optimize check complete req

* coding style

* coding style

* reactor server session unit test

* http reactor time server add delay param

* optimize switch case, and pop completed msg in destructor

* refactor reactor server session

* fix: check completed request when headers are in lower case like oha, add unit tests

* fix auto_ptr compile error, remove logger and coding style

* compile and tests fix, add reactor obj in makefile and vcxproj

* compile and tests fix in win, add reactor sample vcxproj

* compile and tests fix in macos when visibility is hidden
2025-09-30 14:41:30 +02:00
Miko
041e7feeb7 Add support for modules (#4999)
* Add support for modules

* Use "" for inclusion

* Fix missing includes on Poco.Data module

* Add PDF and SevenZip modules, and match modules to build macros

* Add CI test

* Add missing link libraries in CMake

* Add remaining libraries DNSSD, CppParser and CppUnit. Changed some static declarations to inline to export

* We also need to forward the ENABLE_NETSSL_* macros

* Update CMakeLists files

* Add samples as requested, with DateTime and URI test for example

* Fix POCO_MODULES_INSTALL macro

* chore(CMake): Combine install macro for libraries and C++ modules into one macro.

* Apply testsuite changes and address include directories concerns

* Restore accidentally deleted build files

* Mistakenly added a file generated by CMake, removed.

---------

Co-authored-by: Matej Kenda <matejken@gmail.com>
2025-09-19 19:46:36 +02:00
Matej Kenda
dbc800083e fix(Net): Add missing Net_API to Poco::Net::htmlize(const std::string&); 2025-09-12 11:00:16 +02:00
Matej Kenda
7a23a039f9 Reorganise external libs to separate subdirectory (#4996)
* chore(PCRE): properly detect library type on newer macOS

* chore(ZLIB): move source files to own zlib directory and update CMake files.

* chore(PCRE): move source files to own pcre2 directory and update CMake files.

* chore(UTF8PROC): move source files to own utf8proc directory and update CMake files.

* chore(ZLIB): remove header files

* chore(PDJSON): move source files to own pdjson directory and update CMake files.

* chore(SQLite3): move source files to own sqlite3 directory and update CMake files.

* chore(UNBUNDLED): Correct includes.

* chore(expat): move source files to own expat directory and update CMake files.

* chore(wepoll): move source files to own wepoll directory and update CMake files.

* chore(7zip): move source files to own 7zip directory and update CMake files.

* chore(CMake): fix compile and link flags for dependent static libraries

* chore(CMake): set PCRE2_STATIC when building PCRE2.

* chore(SQLite3): Set SQLITE_THREADSAFE for unbundled build, add warnings.

* chore(CMake): Modifications to build and link properly static target libraries (using OBJECT library type and link using BUILD_LOCAL_INTERFACE)

* chore(CMake): fix order of includes in main CMakeLists.txt.

* chore(CI): Build mysql tests with cmake.

* chore(CI): Build mongodb, redis, sqlite no parser tests with cmake.

* chore(CI): Build odbc tests with cmake.

* chore(CI): Build more ations with cmake, other fixes.

* chore(CI): Fixes for macOS

* chore(CMake): extract hpdf and png files to own directories in dependencies

* fix(CMake): include dependencies after all module dependencies are resolved.

* fix(CMake): Improve dependency handling of dependencies to compile them only when necessary.

* fix(CMake): PDF: move t4.h to proper directory, modify include.

* fix(CMake): Fixes to link properly on all platforms.

* fix(CMAKE): Wrong ENABLE for SQLITE

* enh(PDF): Remove dependencies on hpdf headers from Poco::PDF interface and make usage of hpdf only internal.

* enh(CI): Convert more jobs to use cmake.

* enh(CI): Convert macOS sanitizer jobs to use cmake.

* enh(mkrelease): Copy dependencies when creating release package.

* eng(CMake): Add missing POCO_SO option to enable/disable small object optimization.

* enh(CI): Run linux sanitizer with cmake, various fixes and improvements.

* fix(CMake): bundled build: ZLIB::ZLIB is already linked with Foundation, no need to link again to Poco::Zip

* fix(CI): vptr undefined sanitizer causes foundation tests to fail when linking, disable it

* chore(tests): Minor code improvements.

* fix(AsyncNotificationCenter): fix a data race with member _listsEmpty by making it atomic.

* eng(CI): Add a few more time sensitive tests to cppignore.lnx

* chore(Thread): Code updates.

* eng(CI): Add a few more time sensitive tests to cppignore.lnx

* fix(AsyncNotificationCenter): must join threads to avoid data race in dtor.

* chore(CI): Pass TSAN_OPTIONS to jobs where necessary

* chore(CI): run rests without sudo, compile with parallelism

* chore(CI): Use POCO_MINIMAL_BUILD to simplify CMake configure lines.

* chore(CI): Add 32-bit Windows VS build

* chore(CMake): Printout cmake generator platform.

* chore(CMake): linux-gcc-make-armv7l -> linux-gcc-cmake-armv7l

* chore(ci): windows-2025-msvc-cmake-32bit -> windows-2025-msvc-cmake-Win32

* chore(CI): Convert all remaining jobs to CMake.

* chore(make): Prevent building with make.

* chore(CodeQL): exclude all external code from CodeQL checks.

* chore(macOS): Set min support version to 13.3 to properly support C++20 standard.
2025-09-11 17:11:29 +02:00
Matej Kenda
e6f661d313 chore(deprecated): Describe deprecation reasons and alternatives. 2025-09-11 09:25:01 +02:00
Matej Kenda
317ce8aae8 CMake minimal build and dependencies (#5013) 2025-09-06 13:34:59 +02:00
Günter Obiltschnig
a029be8997 Support for RFC 6265 cookies (#4982)
* enh(Net): Support RFC 6265 cookies (#4518)

* fix(HTTPCookie): remove _expires field
2025-08-08 13:42:10 +02:00
Matej Kenda
735e174d90 Async notification center (dispatch notifications asynchronously) (#4957) 2025-06-12 21:12:57 +02:00
Matej Kenda
15d987fbb0 enh(cmake): Add option POCO_ENABLE_CPP20 to enable C++20 when compiling Poco (#4956)
* enh(cmake): Add option POCO_CXX20 to enable standard C++20 and related changes.

* chore(cmake): do not allow C++20 setting for compilers that do not support it properly.

* fix(NetSSL_Win): indentation.
2025-05-28 15:35:28 +02:00
Günter Obiltschnig
4e27f7f0e2 fix(NTLMCredentials): fix potentially uninitialized variable 2025-04-18 13:37:08 +02:00
Günter Obiltschnig
11619a9e95 fix(Net): A SEGV at Net/src/MultipartReader.cpp:164:1 #4915 (move assertion out of ctor) 2025-04-16 09:15:33 +02:00
Günter Obiltschnig
a0822e02ca fix(Net): A SEGV at Net/src/MultipartReader.cpp:164:1 #4915 2025-04-15 22:11:47 +02:00
Günter Obiltschnig
eaf6e28327 fix(Net): Another crash in Poco::Net::NTLMCredentials::parseChallengeMessage #4936 2025-04-15 21:31:26 +02:00
Günter Obiltschnig
4de2afcd1f fix(Net): HTTP client request body RFC compliance #4935 2025-04-15 19:38:13 +02:00
Günter Obiltschnig
3c9b65388c fix(Net): HTTP server request body RFC compliance #4935 2025-04-15 19:17:41 +02:00
alex
c0ea5579e9 Fix wrong/mistaken type comparisons。 (#4931) 2025-04-12 14:28:27 +02:00
Günter Obiltschnig
ecc0e9b674 fix(Net): Crash in Poco::Net::NTLMCredentials::parseChallengeMessage #4926 2025-04-09 21:30:30 +02:00
Jonas Bülow
d020166423 Fix warning deprecated-enum-enum-conversion on clang 2025-04-09 16:12:14 +02:00
Miracle-1996
e758e7e2a6 add_subdirectory(tcpclient) (#4904) 2025-03-20 19:03:40 +01:00
Aleksandar Fabijanic
8fb80fd76e fix(VarHolder): MSVC warning #4886 (#4903)
* fix(VarHolder): MSVC warning #4886

* fix(VarHolder): do not convert unsigned #4886

* chore(SocketImpl): eliminate MSVC warning

* fix(VarHolder): do not convert unsigned (extract unpreserveSign()) #4886

* chore(testsuite): eliminate MSVC warnings

* chore(VarHolder): simplify unpreserveSign using constexpr.

---------

Co-authored-by: Matej Kenda <matejken@gmail.com>
2025-03-20 12:34:55 +01:00
Aleksandar Fabijanic
eb94de03a6 fix(TCPServer): continues to accept connections after stop() #4892 (#4896)
* fix(TCPServer): continues to accept connections after stop() #4892

* fix(TCPServer): first attempt to silence TSAN #4892

* fix(TCPServer): check stopped status after poll; add TCPServerFactory::stop() and allow factory to return nullptr on connection creation request #4892

* fix(TCPServer): initialize factory stopped flag #4892

* revert(SocketImpl): atomic sock fd
2025-03-12 22:15:19 +01:00
Lara Dzivdzanovic
4c70cfca68 Fix testSocketAddress for updated pocoproject.org IP 2025-03-11 09:41:37 +01:00
Günter Obiltschnig
7dd2024c9e fix(Net): WebSocket receiveFrame() keeps returning the same frame when no payload (flags/header only) #4884 2025-02-27 20:52:02 +01:00
Günter Obiltschnig
f32e3d0b90 enh(Net): SocketImpl::sendFile() sends entire contents by repeatedly calling sendfile() if necessary 2025-02-09 16:03:51 +01:00
Günter Obiltschnig
a70fe2b045 enh(Net): SocketImpl::sendFile() - remove signal handling (not thread safe and already done elsewhere); fix wrong signed/unsigned types; cleanup 2025-02-09 14:00:16 +01:00
Günter Obiltschnig
47a77751fb fix(tests): another attempt at fixing the flaky testSendFile*() 2025-02-08 18:04:36 +01:00
Günter Obiltschnig
db88e0ec00 fix(test): fix flaky test 2025-02-08 15:20:14 +01:00
Günter Obiltschnig
24ff931071 fix(Net): Issue concerning Net/CMakeLists.txt detection of HAVE_SENDFILE #4852 2025-02-08 13:48:14 +01:00
Günter Obiltschnig
a1abf9659d enh(Net): additional tests for StreamSocket::sendFile() 2025-02-08 13:02:43 +01:00
Günter Obiltschnig
66c1d30bb4 enh(Net): StreamSocket::sendFile() takes additional count parameter 2025-02-08 12:57:24 +01:00
Günter Obiltschnig
3d8040bb17 fix(tests): remove unused variables 2025-02-07 20:43:28 +01:00
Günter Obiltschnig
6fb0debd71 chore: add test for sendFile() 2025-02-07 18:42:17 +01:00