Commit Graph
2482 Commits
Author SHA1 Message Date
andrey 27a9f05d65 fix(PIProcess): handle fork() failure (return value -1)
fork() can return -1 on error (too many processes, out of memory).
The old code treated pid_ == -1 as a successful fork, entering the
parent branch and calling waitpid(-1, ...) which waits for ANY
child process. Added explicit check: close pipes, free memory,
and return on fork failure.
2026-08-05 17:39:38 +03:00
andrey 13a9a75f79 fix(PISerial): break infinite loop when readDevice returns <= 0
In the blocking read path (timeout_ms <= 0), the while loop had no
exit condition for readDevice() returning 0 (EOF) or -1 (error).
This caused an infinite busy-loop at 100% CPU. Added 'else break'
to exit the loop on read failure, matching the timeout branch
which already handles this case.
2026-08-05 17:39:37 +03:00
andrey b2e637ee2b fix(PIIOByteArray): advance pos by actual bytes read, not requested size
readDevice() did pos += size instead of pos += ret. The clamping
on the next line (pos = min(pos, data_->size_s())) masked the
issue in practice, but the semantics were wrong. Aligns with
writeDevice() which correctly uses pos += rs.size_s().
2026-08-05 17:39:37 +03:00
andrey 9cd56ab66c fix(PIEthernet): check open() return value with >= 0 instead of != 0
open() returns -1 on error. The check fd != 0 treated -1 as a
valid fd (since -1 != 0 is true), causing devctl(-1, ...) and
close(-1) on QNX. Fixed to fd >= 0.
2026-08-05 17:39:36 +03:00
andrey e05abf16b5 fix(PIWaitEvent): use -1 as pipe_fd sentinel instead of 0
File descriptor 0 is stdin (a valid fd). Using 0 as the 'not-open'
sentinel caused isCreate() to return false and destroy() to skip
close() when pipe() happened to allocate fds {0, 1} (e.g. in daemons
with closed stdio). POSIX convention: -1 = invalid fd.
2026-08-05 17:39:36 +03:00
andrey 6c5c4b73e0 fix(PIClientServer): delete PIEthernet when client_factory returns nullptr
When the custom client_factory() returned nullptr, the incoming
PIEthernet pointer was leaked. Matches existing pattern used in the
max_clients overflow branch.
2026-08-05 17:39:35 +03:00
andrey e89ae88f3a fix(PICAN): align socket handling with PIEthernet patterns
- Sentinel: sock = 0 → sock = -1 (0 is stdin, valid fd)
- openDevice(): close socket on ioctl/bind failure (resource leak)
- openDevice(): set O_NONBLOCK via fcntl after socket()
- openDevice(): check setsockopt() return value
- closeDevice(): call shutdown() before close(), reset sock to -1
- readDevice() / writeDevice(): guard against sock == -1
- Add missing #include <fcntl.h>
2026-08-05 17:39:35 +03:00
andrey 216109b8ed fix(PIString): initialize toChar() return value and fix operator+= OOB
- toChar(): char v was uninitialized, causing UB when
  sscanf fails to match (empty string). Initialize to 0.

- operator+=(PIConstChars): loop iterated l < d.size() instead of
  l < str.size(), reading past the end of str after d.enlarge().
  This is a heap buffer overread with undefined behavior.
2026-08-05 17:39:34 +03:00
peri4 ef560ccc96 Merge pull request 'PIP Bugfixes' (#207) from bugfixes into master
Reviewed-on: #207
2026-08-05 13:32:11 +03:00
andrey df93563931 version 2026-08-05 13:11:27 +03:00
andrey 3603f6df13 fix piwaitevent 2026-08-05 12:59:36 +03:00
andrey 427130e2ca fix 2 2026-08-05 12:48:40 +03:00
andrey 42dd5945dd review fixes 2026-08-05 12:46:43 +03:00
andrey ec98963347 Revert "fix select usage"
This reverts commit 9da2d4fdb3.
2026-08-05 12:45:46 +03:00
andrey dc69ebe5ae fix memleak in PIEthernet::interfaces for android 2026-08-05 12:06:03 +03:00
andrey 11d6f7b0db piethernet replace inet_ntoa by threadsafe inet_ntop 2026-08-05 12:05:09 +03:00
andrey c53f1d39aa fix piethernet blocking write return value 2026-08-05 12:03:56 +03:00
andrey 9da2d4fdb3 fix select usage 2026-08-05 12:03:22 +03:00
andrey 6f11eeb895 check PIBinaryStream negative size to fix memory overflow 2026-08-05 12:02:35 +03:00
andrey b0307e8323 fix piprocess set workdir 2026-08-05 12:01:36 +03:00
andrey a2f625292a piterminal nonzero exit code on fail 2026-08-05 12:00:59 +03:00
peri4 15277f8f32 PIPoint operators *=, /=, * and / now also with PIPoint 2026-06-04 11:18:28 +03:00
peri4 1689f560d5 version 5.8.0
very important performance fix for normalizeAngleDeg...() methods, now fixed-speed (no "while")
MQTT client release
2026-05-29 17:40:09 +03:00
peri4 afb4ae8126 MQTT ready to use
change subscription logic - now keep subscriptions independently from connecting state. No unregisters on disconnect, but resubscriptions on connect. So one-time subscription on app start and just connect() on lost connection - all subscriptions keeps
2026-05-29 09:56:29 +03:00
peri4 38d09e272c MQTT seems to work
1. subscribe now similar to HTTP server, with lambda
 2. subscribe topic syntax support all HTTP features as path arguments and wildcards
 3. event received() changed to receivedUnhandled() for unhandled messages (should never be called in proper work)
 4. internal logic got more complicated, several endpoints may be serviced by single MQTT topic, so nested Map used
2026-05-28 20:26:49 +03:00
andrey 236896fb0f Merge pull request 'Add parents (de)serialization in pip_cmg' (#206) from cmg_serialize_parents into master
Reviewed-on: #206
Reviewed-by: Пелипенко Иван <peri4ko@yandex.ru>
2026-05-27 16:38:47 +03:00
andrey 533f9cc640 parse only public inherited classes 2026-05-27 16:37:04 +03:00
andrey 7b5c5d939b Add parents (de)serialization in pip_cmg 2026-05-27 15:44:08 +03:00
peri4 cf67072bed add files 2026-05-26 21:38:00 +03:00
peri4 34b55de561 revert RequestFunction 2026-05-26 21:37:21 +03:00
peri4 a2093e24a6 detach PIHTTPServer::Endpoint to base struct PIHTTP::ServerEndpoint (private header), no functionality changes in HTTP server
Ready to implement this private base struct to MQTT client
2026-05-26 21:31:58 +03:00
peri4 a2e54c3694 android fix unknown -W 2026-05-08 16:17:56 +03:00
peri4 a90c486094 PIJSON::print (and toJSON()) now use "null" for unknown type, resulting valid JSON 2026-04-09 14:23:41 +03:00
peri4 715d70d930 add PIJSON de/serialization overloads for PIStringList 2026-04-09 13:56:08 +03:00
peri4 a680b7eceb fix PIValueTree 2026-04-02 17:35:25 +03:00
peri4 22b47799dc PIPoint: const fixes, add some methods 2026-03-28 22:23:41 +03:00
peri4 9076cc749a Merge pull request 'Add forEach method to PIVector2D' (#205) from pivector2d into master
Reviewed-on: #205
2026-03-28 20:25:11 +03:00
andrey d27e796595 Add forEach method to PIVector2D 2026-03-28 20:17:58 +03:00
peri4 aadf3375a6 PIMQTT::Message now Const & Mutable (as in PIHTTP) 2026-03-26 16:50:55 +03:00
peri4 089e241a67 migrate to PIThreadPoolWorker 2026-03-26 13:28:34 +03:00
peri4 c05fe46d04 pimqttclient before migrate to threadpoolworker 2026-03-26 13:06:57 +03:00
peri4 1ef4103cf9 Merge pull request 'add file' (#204) from mqtt_client into master
Reviewed-on: #204
2026-03-26 13:04:37 +03:00
peri4 a2f73d053c add file 2026-03-26 13:04:26 +03:00
peri4 7e48df7e01 Merge pull request 'mqtt_client' (#203) from mqtt_client into master
Reviewed-on: #203
2026-03-26 13:03:06 +03:00
peri4 6a6cfe1efe Merge branch 'master' into mqtt_client 2026-03-26 12:57:03 +03:00
peri4 f52fd45936 version 2026-03-26 09:33:23 +03:00
peri4 88d4a8e74d PIByteArray gcc one annoying warning off 2026-03-26 09:32:30 +03:00
peri4 6ddc7263e8 Merge pull request 'add new PIThreadPoolWorker - rework of PIThreadPoolExecutor' (#202) from PIThreadPoolWorker into master
Reviewed-on: #202
Reviewed-by: Бычков Андрей <andrey@signalmodelling.ru>
2026-03-26 09:12:23 +03:00
peri4 a16f629dc5 PIThreadPoolWorker ready to use 2026-03-25 10:59:32 +03:00
peri4 5868e0ec9d work with PIThreadPoolWorker 2026-03-24 19:56:43 +03:00