github liulilittle/openppp2 1.0.0.26016

5 days ago

Fixing LWIP Stack Shutdown Issues and Optimizations

Version Information

1.0.0.26016 (Build 20260103)

Commit Summary

This commit fixes a critical protocol stack error that caused VPN's TCP functionality to fail and includes two modernization improvements aimed at enhancing code quality and performance.

Detailed Changes

1. Fixed VPN TCP Connection Failure Caused by Erroneous LWIP Stack Shutdown

  • Issue: On Windows platforms (which use the LWIP protocol stack by default), the VPN client could not access the internet via the TCP protocol. The TCP_PCB state was abnormal.
  • Root Cause: In the VNetstack::TapTcpClient::Finalize() function, cleanup for a single session erroneously invoked the global lwip::netstack::close(), causing the entire protocol stack to shut down.
  • Change: Removed the erroneous lwip::netstack::close() call. Now only sets the disposed_ = TRUE flag to correctly track the session lifecycle.
  • Impact: After the fix, LWIP works stably on all supported platforms, and the VPN can correctly manage user TCP connections.

2. Optimization: Replaced NULL with NULLPTR Macro

  • Change: Globally replaced NULL with the NULLPTR macro (i.e., C++11's nullptr).
  • Reason: Leverages the std::nullptr_t type to improve type safety, eliminate overload ambiguity, and optimize container-related code, aligning with modern C++ standards.

3. Optimization: Introduced FUNCTION Compiler Macro, Defaulting to std::function

  • Change: In CMakeList.txt (or the corresponding VS project properties), the FUNCTION compiler macro is now predefined by default. This macro directs the code to use std::function instead of the project's custom ppp::function in non-LLVM libc++ environments (e.g., gcc's libstdc++, msvcrt).
  • Basis: Referencing the implementation and testing of medium-frequency event queues (https://blog.csdn.net/liulilittle/article/details/156061074), in most small-call scenarios, std::function often performs better due to its Small Buffer Optimization (SBO) strategy. SBO stores small callable objects inline, avoiding heap allocation overhead.
  • Summary: In general standard library environments, using the thread-safe and highly optimized std::function typically yields better and more stable performance compared to non-thread-safe custom implementations.

Don't miss a new openppp2 release

NewReleases is sending notifications on new releases.