Closing a SSLSockets input or output stream does not close the socket (https://issuetracker.google.com/issues/37018094)
ClosedPublic

Authored by eduisters on Dec 2 2018, 6:30 PM.

Details

Summary

When you close a SSLSockets input or output stream the socket does not get closed leading to may
sockets in the CLOSE_WAIT state. This will eventually deplete the available file descriptors

Test Plan

Before appying this patch share a file from desktop to android
After the share is finished issue the command:

netstat -pW | grep kde

There should be a line showing that the socket used is in the state CLOSE_WAIT like below

tcp6 0 0 ::ffff:192.168.0.32:33604 ::ffff:192.168.0.2:1739 CLOSE_WAIT 6200/org.kde.kdeconnect_tp

Apply this patch and repeat the test. Now there should no longer be any sockets in the CLOSE_WAIT state

Diff Detail

Repository
R225 KDE Connect - Android application
Branch
sslsocket_close_stream_does_not_close_socket
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 5683
Build 5701: arc lint + arc unit
eduisters created this revision.Dec 2 2018, 6:30 PM
Restricted Application added a project: KDE Connect. · View Herald TranscriptDec 2 2018, 6:30 PM
Restricted Application added a subscriber: kdeconnect. · View Herald Transcript
eduisters requested review of this revision.Dec 2 2018, 6:30 PM

Thanks for looking into this!

So now every time we are done with the payload we need to close both the InputStream and the socket? That seems like something that is easily forgotten. Maybe it would make sense to add a closePayload() method to NetworkPacket that closes both so you only need to call one method?

eduisters updated this revision to Diff 46811.Dec 3 2018, 7:21 PM
  • Encapsulate mPayload, mPayloadSocket and mPayloadSize in a NetworkPacket.Payload object for easier handling
nicolasfella accepted this revision.Dec 7 2018, 6:28 PM

Looks good from looking at it, didn't try it out.

This revision is now accepted and ready to land.Dec 7 2018, 6:28 PM
eduisters updated this revision to Diff 47107.Dec 8 2018, 1:27 PM
  • Rebased onto master
This revision was automatically updated to reflect the committed changes.