Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow shutting down of TcpServers #1284

Merged
merged 6 commits into from
Nov 11, 2017

Conversation

slaff
Copy link
Contributor

@slaff slaff commented Nov 8, 2017

Rebase of #1280.

Have to be improved to free all RAM (heap) taken when HTTP server is created.
@slaff slaff force-pushed the feature/httpserver-stop branch from 2b78200 to 603d268 Compare November 8, 2017 17:46
@slaff
Copy link
Contributor Author

slaff commented Nov 8, 2017

@bbourdel Can you check if this PR is working for you? The way to shutdown the server is to call HttpServer::shutdown().

@bbourdel
Copy link

bbourdel commented Nov 8, 2017

@slaff Tested and OK !! :-)
Thanks for your completion.

Fixes segfault with HttpServer::shutdown();
@slaff slaff force-pushed the feature/httpserver-stop branch from a6338c5 to 09ee2b4 Compare November 9, 2017 10:16
totalConnections = connections.count();
if(totalConnections == 0 && !active){
debugf("Shutting down the Http Server");
delete this;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note to myself: That will cause a race condition - HttpServer will start freeing the resources and meanwhile the HttpServerConnections will try to use those resource in their destructors... A timer with 3 - 4 seconds delay should fix this...

@slaff slaff added this to the 3.5.0 milestone Nov 9, 2017
@slaff slaff changed the title Feature/httpserver stop Allow shutting down of TcpServers Nov 9, 2017
The shutdown uses timeouts to "gracefully" close the client connections.
It should be possible to shut down cleanly all servers that inherit from TcpServer.
@slaff slaff force-pushed the feature/httpserver-stop branch from decbf7c to 26ed098 Compare November 11, 2017 08:19
@slaff slaff removed the 3 - Review label Nov 11, 2017
@slaff slaff merged commit 30e7d6b into SmingHub:develop Nov 11, 2017
johndoe8967 added a commit to johndoe8967/Sming that referenced this pull request Dec 18, 2017
* commit 'f8f675415c36dd4d8da45cfc3669f50469c65d8d':
  Preparation for release 3.5.0. (SmingHub#1295)
  Added Stream::indexOf(char c) that finds a character in a stream (SmingHub#1290)
  Made spiffs_mount() compatible with rBoot. (SmingHub#1292)
  Added experimental support for SDK 2.1 (SmingHub#1264)
  Initial test code for improved sendPing and sendPong. (SmingHub#1270)
  Added experimental support for LWIP v2 (SmingHub#1289)
  Fixed ssl memory leaks related to SSL context not being freed (SmingHub#1288)
  Fixed an error breaking SSL session resumption, Http Connection reuse and Http pipelining. (SmingHub#1287)
  Added Adafruit_BME280 Library (SmingHub#1286)
  Allow immediate server deletion if there are no active connections. (SmingHub#1285)
  Deleting an HttpClient should result in freeing the total memory it uses.
  Allow shutting down of TcpServers (SmingHub#1284)
  TcpConnection fixes related to ssl extensions. Styling fixes for HttpClient.
  fix/MemoryLeak(Heap) during TCP Client connection and delete
  Reverted: m_printf: stacksize reduced SmingHub#1097. (SmingHub#1279)
  Preparation for release 3.4.0. (SmingHub#1277)
  Mqtt memory fix: Fix copy and paste error (SmingHub#1276)
  Fix Memory Leak in Mqtt (SmingHub#1273)
  Changed a TcpClient message to be less confusing. (SmingHub#1271)
johndoe8967 added a commit to johndoe8967/Sming that referenced this pull request Jan 16, 2019
* commit '4a0fec18235521e4369d111f111c2624fbd3203b': (50 commits)
  Added the Arduino Libraries.
  Added the latest changes to the third-party projects.
  Preparation for release 3.5.0. (SmingHub#1295)
  Added Stream::indexOf(char c) that finds a character in a stream (SmingHub#1290)
  Made spiffs_mount() compatible with rBoot. (SmingHub#1292)
  Added experimental support for SDK 2.1 (SmingHub#1264)
  Initial test code for improved sendPing and sendPong. (SmingHub#1270)
  Added experimental support for LWIP v2 (SmingHub#1289)
  Fixed ssl memory leaks related to SSL context not being freed (SmingHub#1288)
  Fixed an error breaking SSL session resumption, Http Connection reuse and Http pipelining. (SmingHub#1287)
  Added Adafruit_BME280 Library (SmingHub#1286)
  Allow immediate server deletion if there are no active connections. (SmingHub#1285)
  Deleting an HttpClient should result in freeing the total memory it uses.
  Allow shutting down of TcpServers (SmingHub#1284)
  TcpConnection fixes related to ssl extensions. Styling fixes for HttpClient.
  fix/MemoryLeak(Heap) during TCP Client connection and delete
  Reverted: m_printf: stacksize reduced SmingHub#1097. (SmingHub#1279)
  Preparation for release 3.4.0. (SmingHub#1277)
  Mqtt memory fix: Fix copy and paste error (SmingHub#1276)
  Fix Memory Leak in Mqtt (SmingHub#1273)
  ...
@slaff slaff deleted the feature/httpserver-stop branch July 22, 2019 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants