esp8266 / esp8266/Arduino

Empty destructor in WifiServer::~WiFiServer()

Open
#9,212 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
16.7k
Forks
13.1k
PR merge metrics
No merged PRs in 30d

Description

### Basic Infos

- [x] This issue complies with the [issue POLICY doc](https://github.com/esp8266/Arduino/blob/master/POLICY.md).
- [X] I have read the documentation at [readthedocs](https://arduino-esp8266.readthedocs.io/en/latest) and the issue is not addressed there.
- [X] I have tested that the issue is present in current master branch (aka latest git).
- [X] I have searched the issue tracker for a similar issue.
- [X] If there is a stack dump, I have decoded it.
- [X] I have filled out all fields below.

#### Platform

- Hardware: ESP8285 generic (TYWE2S)
- Core Version: bb79e9076e (2024-12-08)
- Development Env: Arduino IDE
- Operating System: Linux (Arch)

### Settings in IDE

- Module: Generic ESP8266 Module
- Flash Mode: other
- Flash Size: 1MB
- lwip Variant: ?
- Reset Method: manual (a bit of wire)
- Flash Frequency: ?
- CPU Frequency: 24Mhz
- Upload Using: Generic FTDI adapter
- Upload Speed: 115200

### Problem Description

WiFiServer appears to have an empty destructor, and does not automatically call `stop()` or `end()` when deleted like esp32 does.

Depending on the project, this may cause the port listen to fail on the 2nd and subsequent attempts if for example, WiFi is connected, a port is listened, the WiFi connection is lost, and then a connection is re-established and `begin()` is called again on a new WiFiServer object with the same port.

If the project didn't check for success after calling `begin()` (this isn't exposed very well, so I'm using `status() != CLOSED` to infer the result of the internal test `!listen_pcb`), then the device can even appear to re-connect but then reboot via `abort()` on the subsequent first incoming connection.

### Expected Behavior

I would expect that WiFiServer's destructor should clean up all owned resources as is C++ convention, so that projects that don't use it as a singleton can `delete` and `new` it again to reset the state without any memory or resource leaks.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.