Skip to content

Conversation

@gmarcosb
Copy link
Contributor

@gmarcosb gmarcosb commented Sep 9, 2025

Summary

This is a followup to #40817 with additional clean-up, formalizing ref-counting & removing visiblity into internals, so that users are pushed to use auto ref counting

Testing

CI

@github-actions
Copy link

github-actions bot commented Sep 9, 2025

PR #40904: Size comparison from b034faa to 71e7825

Full report (35 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, nxp, psoc6, qpg, realtek, stm32, telink)
platform target config section b034faa 71e7825 change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1104518 1104518 0 0.0
RAM 178970 178970 0 0.0
bl702 lighting-app bl702+eth FLASH 659090 659090 0 0.0
RAM 135025 135025 0 0.0
bl702+wifi FLASH 835158 835158 0 0.0
RAM 124509 124509 0 0.0
bl706+mfd+rpc+littlefs FLASH 1068166 1068166 0 0.0
RAM 117333 117333 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 898406 898406 0 0.0
RAM 105676 105676 0 0.0
lighting-app bl702l+mfd+littlefs FLASH 981318 981318 0 0.0
RAM 109828 109828 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 768172 768172 0 0.0
RAM 103392 103392 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 779800 779800 0 0.0
RAM 108560 108560 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 725396 725396 0 0.0
RAM 96932 96932 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 709888 709888 0 0.0
RAM 97140 97140 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 553162 553162 0 0.0
RAM 205168 205168 0 0.0
lock CC3235SF_LAUNCHXL FLASH 585854 585854 0 0.0
RAM 205400 205400 0 0.0
efr32 lock-app BRD4187C FLASH 959752 959752 0 0.0
RAM 126408 126408 0 0.0
BRD4338a FLASH 755176 755168 -8 -0.0
RAM 255732 255732 0 0.0
window-app BRD4187C FLASH 1053988 1053988 0 0.0
RAM 122604 122604 0 0.0
esp32 all-clusters-app c3devkit DRAM 102552 102552 0 0.0
FLASH 1774904 1774904 0 0.0
IRAM 83862 83862 0 0.0
nxp contact mcxw71+release FLASH 633096 633096 0 0.0
RAM 64148 64148 0 0.0
lock mcxw71+release FLASH 742168 742168 0 0.0
RAM 65200 65200 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1664660 1664660 0 0.0
RAM 211288 211288 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1584644 1584644 0 0.0
RAM 208560 208560 0 0.0
light cy8ckit_062s2_43012 FLASH 1455108 1455108 0 0.0
RAM 197248 197248 0 0.0
lock cy8ckit_062s2_43012 FLASH 1487436 1487436 0 0.0
RAM 224968 224968 0 0.0
qpg lighting-app qpg6200+debug FLASH 831400 831400 0 0.0
RAM 127788 127788 0 0.0
lock-app qpg6200+debug FLASH 768452 768452 0 0.0
RAM 118748 118748 0 0.0
realtek light-switch-app rtl8777g FLASH 703608 703608 0 0.0
RAM 106660 106660 0 0.0
lighting-app rtl8777g FLASH 755368 755368 0 0.0
RAM 127040 127040 0 0.0
stm32 light STM32WB5MM-DK FLASH 467876 467876 0 0.0
RAM 141400 141400 0 0.0
telink bridge-app tl7218x FLASH 709726 709726 0 0.0
RAM 93468 93468 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 798740 798740 0 0.0
RAM 44028 44028 0 0.0
light-app-ota-shell-factory-data tl7218x FLASH 789954 789954 0 0.0
RAM 100772 100772 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 716136 716136 0 0.0
RAM 54256 54256 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 749490 749490 0 0.0
RAM 77404 77404 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 726282 726282 0 0.0
RAM 37004 37004 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 606350 606350 0 0.0
RAM 112580 112580 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 822674 822678 4 0.0
RAM 99168 99168 0 0.0

@github-actions
Copy link

github-actions bot commented Oct 3, 2025

PR #40904: Size comparison from c8232e1 to 6af5c44

Full report (3 builds for realtek, stm32)
platform target config section c8232e1 6af5c44 change % change
realtek light-switch-app rtl8777g FLASH 704160 704336 176 0.0
RAM 106720 106720 0 0.0
lighting-app rtl8777g FLASH 755320 755496 176 0.0
RAM 127076 127076 0 0.0
stm32 light STM32WB5MM-DK FLASH 467764 467948 184 0.0
RAM 141152 141152 0 0.0

@github-actions github-actions bot added the system label Oct 3, 2025
@github-actions
Copy link

github-actions bot commented Oct 3, 2025

PR #40904: Size comparison from c8232e1 to f86d48b

Full report (30 builds for bl602, bl702, bl702l, cc13x4_26x4, efr32, esp32, nxp, qpg, realtek, stm32, telink)
platform target config section c8232e1 f86d48b change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1104336 1105184 848 0.1
RAM 178698 178706 8 0.0
bl702 lighting-app bl702+eth FLASH 658780 659840 1060 0.2
RAM 134761 134777 16 0.0
bl702+wifi FLASH 834848 835908 1060 0.1
RAM 124245 124261 16 0.0
bl706+mfd+rpc+littlefs FLASH 1068114 1068756 642 0.1
RAM 117077 117093 16 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 898334 898976 642 0.1
RAM 105412 105428 16 0.0
lighting-app bl702l+mfd+littlefs FLASH 980754 981652 898 0.1
RAM 109572 109588 16 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 768156 768808 652 0.1
RAM 103152 103160 8 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 779792 780404 612 0.1
RAM 108312 108328 16 0.0
pump-app LP_EM_CC1354P10_6 FLASH 725772 726464 692 0.1
RAM 97220 97236 16 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 710240 710948 708 0.1
RAM 97436 97444 8 0.0
efr32 lock-app BRD4187C FLASH 959864 960512 648 0.1
RAM 126184 126184 0 0.0
BRD4338a FLASH 755528 756152 624 0.1
RAM 255484 255492 8 0.0
window-app BRD4187C FLASH 1053924 1054468 544 0.1
RAM 122380 122380 0 0.0
esp32 all-clusters-app c3devkit DRAM 102984 103000 16 0.0
FLASH 1787494 1788492 998 0.1
IRAM 83862 83862 0 0.0
nxp contact mcxw71+release FLASH 690368 690944 576 0.1
RAM 61392 61408 16 0.0
lighting mcxw71+release FLASH 721928 722512 584 0.1
RAM 68036 68052 16 0.0
lock mcxw71+release FLASH 769024 769608 584 0.1
RAM 61764 61772 8 0.0
qpg lighting-app qpg6200+debug FLASH 833872 834576 704 0.1
RAM 127548 127556 8 0.0
lock-app qpg6200+debug FLASH 770868 771540 672 0.1
RAM 118516 118524 8 0.0
realtek light-switch-app rtl8777g FLASH 704160 704784 624 0.1
RAM 106720 106736 16 0.0
lighting-app rtl8777g FLASH 755320 755944 624 0.1
RAM 127076 127092 16 0.0
stm32 light STM32WB5MM-DK FLASH 467764 468404 640 0.1
RAM 141152 141168 16 0.0
telink bridge-app tl7218x FLASH 707538 708278 740 0.1
RAM 90308 90320 12 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 795368 796046 678 0.1
RAM 40860 40872 12 0.0
light-app-ota-shell-factory-data tl7218x FLASH 786570 787252 682 0.1
RAM 93504 93516 12 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 713362 714068 706 0.1
RAM 51680 51692 12 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 746666 747372 706 0.1
RAM 70728 70740 12 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 723518 724220 702 0.1
RAM 34428 34440 12 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 600792 601616 824 0.1
RAM 108552 108564 12 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 819190 819876 686 0.1
RAM 91900 91912 12 0.0

@gmarcosb gmarcosb force-pushed the tcp-followup branch 2 times, most recently from 2f68a81 to eae6bf3 Compare October 6, 2025 18:19
@codecov
Copy link

codecov bot commented Oct 6, 2025

Codecov Report

❌ Patch coverage is 74.38017% with 62 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.99%. Comparing base (5ca0aad) to head (8eaff21).
⚠️ Report is 20 commits behind head on master.

Files with missing lines Patch % Lines
src/transport/raw/TCP.cpp 78.57% 15 Missing ⚠️
src/protocols/secure_channel/CASESession.cpp 0.00% 10 Missing ⚠️
src/inet/TCPEndPointImplSockets.cpp 81.25% 9 Missing ⚠️
src/inet/TCPEndPoint.cpp 60.00% 4 Missing ⚠️
src/transport/SessionManager.cpp 0.00% 4 Missing ⚠️
src/transport/raw/ActiveTCPConnectionState.h 42.85% 4 Missing ⚠️
src/inet/InetLayer.h 70.00% 3 Missing ⚠️
src/transport/Session.h 0.00% 2 Missing ⚠️
...ment-server/camera-av-stream-management-server.cpp 0.00% 1 Missing ⚠️
...ement-server/tls-certificate-management-server.cpp 0.00% 1 Missing ⚠️
... and 9 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #40904      +/-   ##
==========================================
+ Coverage   50.94%   50.99%   +0.04%     
==========================================
  Files        1378     1380       +2     
  Lines      100728   100772      +44     
  Branches    13065    13057       -8     
==========================================
+ Hits        51318    51390      +72     
+ Misses      49410    49382      -28     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gmarcosb gmarcosb force-pushed the tcp-followup branch 4 times, most recently from 05f66d4 to b060c44 Compare October 6, 2025 20:22
@github-actions
Copy link

github-actions bot commented Oct 6, 2025

PR #40904: Size comparison from cf7d828 to b060c44

Full report (28 builds for bl602, bl702, bl702l, cc13x4_26x4, efr32, esp32, nrfconnect, qpg, realtek, stm32, telink)
platform target config section cf7d828 b060c44 change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1105078 1105416 338 0.0
RAM 178738 178738 0 0.0
bl702 lighting-app bl702+eth FLASH 659582 659920 338 0.1
RAM 134801 134801 0 0.0
bl702+wifi FLASH 835650 835988 338 0.0
RAM 124285 124285 0 0.0
bl706+mfd+rpc+littlefs FLASH 1068794 1068996 202 0.0
RAM 117117 117117 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 899020 899222 202 0.0
RAM 105460 105460 0 0.0
lighting-app bl702l+mfd+littlefs FLASH 981812 982014 202 0.0
RAM 109612 109612 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 769208 769396 188 0.0
RAM 103184 103184 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 780868 781040 172 0.0
RAM 108352 108352 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 726840 727020 180 0.0
RAM 97252 97252 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 711316 711496 180 0.0
RAM 97468 97468 0 0.0
efr32 lock-app BRD4187C FLASH 961000 961160 160 0.0
RAM 126220 126220 0 0.0
BRD4338a FLASH 756832 757080 248 0.0
RAM 255520 255520 0 0.0
window-app BRD4187C FLASH 1055236 1055388 152 0.0
RAM 122416 122416 0 0.0
esp32 all-clusters-app c3devkit DRAM 103024 103024 0 0.0
FLASH 1788902 1789264 362 0.0
IRAM 83862 83862 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 928944 929104 160 0.0
RAM 160991 160991 0 0.0
qpg lighting-app qpg6200+debug FLASH 835216 835392 176 0.0
RAM 127592 127592 0 0.0
lock-app qpg6200+debug FLASH 771972 772148 176 0.0
RAM 118552 118552 0 0.0
realtek light-switch-app rtl8777g FLASH 705184 705384 200 0.0
RAM 106756 106756 0 0.0
lighting-app rtl8777g FLASH 756376 756568 192 0.0
RAM 127120 127120 0 0.0
stm32 light STM32WB5MM-DK FLASH 468884 469048 164 0.0
RAM 141192 141192 0 0.0
telink bridge-app tl7218x FLASH 708284 708500 216 0.0
RAM 90340 90340 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 795816 796028 212 0.0
RAM 40896 40896 0 0.0
light-app-ota-shell-factory-data tl7218x FLASH 787012 787228 216 0.0
RAM 93540 93540 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 713818 714034 216 0.0
RAM 51712 51712 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 747122 747338 216 0.0
RAM 70760 70760 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 723974 724186 212 0.0
RAM 34460 34460 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 601240 601586 346 0.1
RAM 108588 108588 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 819632 819852 220 0.0
RAM 91936 91936 0 0.0

…yway, and set mAppState

Remove unnecessary initialization as it's now done @ top of method
Fixes CI failure:

==68889==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000030 (pc 0x000104884514 bp 0x00016b642490 sp 0x00016b642410 T0)
==68889==The signal is caused by a READ memory access.
==68889==Hint: address points to the zero page.
    #0 0x104884514 in chip::Transport::TCPBase::FindActiveConnection(chip::Inet::EndPointHandle<chip::Inet::TCPEndPoint> const&) TCP.cpp:205
    #1 0x1048826a8 in chip::Transport::TCPBase::HandleAcceptError(chip::Inet::EndPointHandle<chip::Inet::TCPEndPoint> const&, chip::ChipError) TCP.cpp:664
    #2 0x10488181c in chip::Transport::TCPBase::HandleIncomingConnection(chip::Inet::EndPointHandle<chip::Inet::TCPEndPoint> const&, chip::Inet::EndPointHandle<chip::Inet::TCPEndPoint> const&, chip::Inet::IPAddress const&, unsigned short) TCP.cpp:623
    #3 0x1048b3328 in chip::Inet::TCPEndPointImplSockets::HandleIncomingConnection() TCPEndPointImplSockets.cpp:1066
    #4 0x1048b13ac in chip::Inet::TCPEndPointImplSockets::HandlePendingIO(chip::BitFlags<chip::System::SocketEventFlags, unsigned char>) TCPEndPointImplSockets.cpp:797
    #5 0x1048a96a8 in chip::Inet::TCPEndPointImplSockets::HandlePendingIO(chip::BitFlags<chip::System::SocketEventFlags, unsigned char>, long) TCPEndPointImplSockets.cpp:783
    #6 0x10493f870 in chip::System::LayerImplDispatch::SocketWatch::HandleEvents(chip::System::LayerImplDispatch::SelectSets const&) const SystemLayerImplDispatchSockets.mm:245
    #7 0x10493e800 in chip::System::LayerImplDispatch::SocketWatchPool::HandleEvents(chip::System::LayerImplDispatch::SelectSets const&) const SystemLayerImplDispatchSockets.mm:204
    #8 0x10493df84 in chip::System::LayerImplDispatch::HandleSocketsAndTimerEvents(std::__1::chrono::duration<unsigned int, std::__1::ratio<1l, 1000l>>) SystemLayerImplDispatchSockets.mm:172
    #9 0x104930e28 in chip::System::LayerImplDispatch::HandleDispatchQueueEvents(std::__1::chrono::duration<unsigned int, std::__1::ratio<1l, 1000l>>) SystemLayerImplDispatch.mm:298
@gmarcosb gmarcosb force-pushed the tcp-followup branch 2 times, most recently from 119a18f to 9c370fc Compare October 13, 2025 17:39
@github-actions
Copy link

github-actions bot commented Oct 13, 2025

PR #40904: Size comparison from 5ca0aad to 77cfc8f

Full report (37 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, nrfconnect, nxp, psoc6, qpg, realtek, stm32, telink)
platform target config section 5ca0aad 77cfc8f change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1105406 1105674 268 0.0
RAM 178754 178754 0 0.0
bl702 lighting-app bl702+eth FLASH 659894 660162 268 0.0
RAM 134825 134825 0 0.0
bl702+wifi FLASH 835978 836246 268 0.0
RAM 124301 124301 0 0.0
bl706+mfd+rpc+littlefs FLASH 1069114 1069294 180 0.0
RAM 117141 117141 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 899328 899508 180 0.0
RAM 105476 105476 0 0.0
lighting-app bl702l+mfd+littlefs FLASH 981876 982056 180 0.0
RAM 109628 109628 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 769432 769584 152 0.0
RAM 103208 103208 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 781076 781212 136 0.0
RAM 108360 108360 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 727072 727216 144 0.0
RAM 97276 97276 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 711540 711684 144 0.0
RAM 97484 97484 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 554310 554930 620 0.1
RAM 205544 205544 0 0.0
lock CC3235SF_LAUNCHXL FLASH 587034 587646 612 0.1
RAM 205768 205768 0 0.0
efr32 lock-app BRD4187C FLASH 961168 961328 160 0.0
RAM 126228 126228 0 0.0
BRD4338a FLASH 755896 756080 184 0.0
RAM 255516 255516 0 0.0
window-app BRD4187C FLASH 1055508 1055628 120 0.0
RAM 122424 122424 0 0.0
esp32 all-clusters-app c3devkit DRAM 103016 103016 0 0.0
FLASH 1793820 1794136 316 0.0
IRAM 83862 83862 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 931132 931272 140 0.0
RAM 160987 160987 0 0.0
nxp contact mcxw71+release FLASH 691800 691928 128 0.0
RAM 61440 61440 0 0.0
lighting mcxw71+release FLASH 723368 723496 128 0.0
RAM 68100 68100 0 0.0
lock mcxw71+release FLASH 770592 770712 120 0.0
RAM 61804 61804 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1673804 1674588 784 0.0
RAM 213620 213620 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1589940 1590708 768 0.0
RAM 210900 210900 0 0.0
light cy8ckit_062s2_43012 FLASH 1456772 1457540 768 0.1
RAM 197616 197616 0 0.0
lock cy8ckit_062s2_43012 FLASH 1489084 1489868 784 0.1
RAM 225328 225328 0 0.0
qpg lighting-app qpg6200+debug FLASH 835432 835576 144 0.0
RAM 127604 127604 0 0.0
lock-app qpg6200+debug FLASH 772180 772324 144 0.0
RAM 118580 118580 0 0.0
realtek light-switch-app rtl8777g FLASH 705368 705544 176 0.0
RAM 106784 106784 0 0.0
lighting-app rtl8777g FLASH 756568 756744 176 0.0
RAM 127132 127132 0 0.0
stm32 light STM32WB5MM-DK FLASH 469068 469216 148 0.0
RAM 141208 141208 0 0.0
telink bridge-app tl7218x FLASH 708408 708600 192 0.0
RAM 90356 90356 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 795940 796128 188 0.0
RAM 40908 40908 0 0.0
light-app-ota-shell-factory-data tl7218x FLASH 787136 787328 192 0.0
RAM 93552 93552 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 713942 714134 192 0.0
RAM 51724 51724 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 747246 747440 194 0.0
RAM 70772 70772 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 724098 724286 188 0.0
RAM 34472 34472 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 601366 601646 280 0.0
RAM 108600 108600 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 819756 819952 196 0.0
RAM 91948 91948 0 0.0

@andy31415 andy31415 requested a review from Copilot October 14, 2025 15:47
@andy31415
Copy link
Contributor

/gemini review

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR is a followup to #40817 that refactors TCP endpoint handling to use automatic reference counting with handles. The changes formalize ref-counting by replacing raw pointer usage with handle types and removing direct visibility into endpoint internals, pushing users toward automatic reference counting patterns.

Key changes:

  • Replaced ActiveTCPConnectionHolder with ActiveTCPConnectionHandle throughout the codebase
  • Introduced ReferenceCountedPtr as a general-purpose smart pointer for reference counted objects
  • Changed endpoint types to use handle-based access patterns (TCPEndPointHandle, UDPEndPointHandle)
  • Updated endpoint lifecycle management to use automatic cleanup via handles instead of manual Release() calls

Reviewed Changes

Copilot reviewed 59 out of 59 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/transport/raw/ActiveTCPConnectionState.h Renamed holder class to handle and switched from AutoRelease to ReferenceCountedPtr base
src/transport/raw/TCP.h Updated method signatures to use handles instead of raw pointers
src/transport/raw/TCP.cpp Implemented handle-based endpoint management and cleanup patterns
src/lib/support/ReferenceCountedPtr.h Added new smart pointer class for reference counted objects
src/lib/core/ReferenceCounted.h Split into ReferenceCountedProtected (private ref-counting) and ReferenceCounted (public)
src/inet/TCPEndPoint.h Changed callback signatures to use handles and made Free() protected
src/inet/UDPEndPoint.h Introduced UDPEndPointHandle and made Free() protected
src/inet/InetLayer.h Updated EndPointManager to work with handles instead of raw pointers
src/inet/EndPointBasis.h Changed base class to ReferenceCountedProtected for controlled access
src/system/SystemLayerImplSelect.cpp Added null pointer check for StopWatchingSocket

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a significant and valuable refactoring that introduces ReferenceCountedPtr for managing the lifetime of EndPoint and ActiveTCPConnectionState objects. This moves the codebase towards safer, RAII-based resource management, away from manual Retain/Release calls. The introduction of ReferenceCountedProtected and the ScopeExit utility are also excellent improvements for code safety and clarity. The changes are extensive and mostly look correct and consistent with the goal of the refactoring. I've found one issue that will cause a compilation error.

@github-actions
Copy link

github-actions bot commented Oct 14, 2025

PR #40904: Size comparison from 5ca0aad to 8eaff21

Full report (37 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, nrfconnect, nxp, psoc6, qpg, realtek, stm32, telink)
platform target config section 5ca0aad 8eaff21 change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1105406 1105674 268 0.0
RAM 178754 178754 0 0.0
bl702 lighting-app bl702+eth FLASH 659894 660162 268 0.0
RAM 134825 134825 0 0.0
bl702+wifi FLASH 835978 836246 268 0.0
RAM 124301 124301 0 0.0
bl706+mfd+rpc+littlefs FLASH 1069114 1069294 180 0.0
RAM 117141 117141 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 899328 899508 180 0.0
RAM 105476 105476 0 0.0
lighting-app bl702l+mfd+littlefs FLASH 981876 982056 180 0.0
RAM 109628 109628 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 769432 769584 152 0.0
RAM 103208 103208 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 781076 781212 136 0.0
RAM 108360 108360 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 727072 727216 144 0.0
RAM 97276 97276 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 711540 711684 144 0.0
RAM 97484 97484 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 554310 554930 620 0.1
RAM 205544 205544 0 0.0
lock CC3235SF_LAUNCHXL FLASH 587034 587646 612 0.1
RAM 205768 205768 0 0.0
efr32 lock-app BRD4187C FLASH 961168 961328 160 0.0
RAM 126228 126228 0 0.0
BRD4338a FLASH 755896 756080 184 0.0
RAM 255516 255516 0 0.0
window-app BRD4187C FLASH 1055508 1055628 120 0.0
RAM 122424 122424 0 0.0
esp32 all-clusters-app c3devkit DRAM 103016 103064 48 0.0
FLASH 1793820 1795576 1756 0.1
IRAM 83862 83862 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 931132 932492 1360 0.1
RAM 160987 161041 54 0.0
nxp contact mcxw71+release FLASH 691800 691928 128 0.0
RAM 61440 61440 0 0.0
lighting mcxw71+release FLASH 723368 723496 128 0.0
RAM 68100 68100 0 0.0
lock mcxw71+release FLASH 770592 772024 1432 0.2
RAM 61804 61860 56 0.1
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1673804 1676148 2344 0.1
RAM 213620 213668 48 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1589940 1592252 2312 0.1
RAM 210900 210956 56 0.0
light cy8ckit_062s2_43012 FLASH 1456772 1457540 768 0.1
RAM 197616 197616 0 0.0
lock cy8ckit_062s2_43012 FLASH 1489084 1489868 784 0.1
RAM 225328 225328 0 0.0
qpg lighting-app qpg6200+debug FLASH 835432 835576 144 0.0
RAM 127604 127604 0 0.0
lock-app qpg6200+debug FLASH 772180 772324 144 0.0
RAM 118580 118580 0 0.0
realtek light-switch-app rtl8777g FLASH 705368 705544 176 0.0
RAM 106784 106784 0 0.0
lighting-app rtl8777g FLASH 756568 756744 176 0.0
RAM 127132 127132 0 0.0
stm32 light STM32WB5MM-DK FLASH 469068 469216 148 0.0
RAM 141208 141208 0 0.0
telink bridge-app tl7218x FLASH 708408 709878 1470 0.2
RAM 90356 90408 52 0.1
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 795940 796128 188 0.0
RAM 40908 40908 0 0.0
light-app-ota-shell-factory-data tl7218x FLASH 787136 787328 192 0.0
RAM 93552 93552 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 713942 714134 192 0.0
RAM 51724 51724 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 747246 747440 194 0.0
RAM 70772 70772 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 724098 724286 188 0.0
RAM 34472 34472 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 601366 601646 280 0.0
RAM 108600 108600 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 819756 819952 196 0.0
RAM 91948 91948 0 0.0

@mergify mergify bot merged commit c0cdd2e into project-chip:master Oct 14, 2025
75 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

General ref counting issues in TCP impl

4 participants