Skip to content

Commit

Permalink
Fix memory leak
Browse files Browse the repository at this point in the history
Any time a new client connects, it is added to the _clients array and never removed until the server stops. This fix removes disconnected clients from the list after processing each frame.
  • Loading branch information
bschug authored and dploeger committed Oct 21, 2024
1 parent 12ca995 commit 6825e55
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions addons/godottpd/http_server.gd
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ func _process(_delta: float) -> void:
if bytes > 0:
var request_string = client.get_utf8_string(bytes)
self._handle_request(client, request_string)
_remove_disconnected_clients()


func _remove_disconnected_clients():
self._clients = self._clients.filter(func(c: StreamPeerTCP): c.get_status() == StreamPeerTCP.STATUS_CONNECTED)


# Start the server
Expand Down

0 comments on commit 6825e55

Please sign in to comment.