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

Authored by eduisters on Sun, Dec 2, 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
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
eduisters created this revision.Sun, Dec 2, 6:30 PM
Restricted Application added a project: KDE Connect. · View Herald TranscriptSun, Dec 2, 6:30 PM
Restricted Application added a subscriber: kdeconnect. · View Herald Transcript
eduisters requested review of this revision.Sun, Dec 2, 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.Mon, Dec 3, 7:21 PM
  • Encapsulate mPayload, mPayloadSocket and mPayloadSize in a NetworkPacket.Payload object for easier handling
nicolasfella accepted this revision.Fri, Dec 7, 6:28 PM

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

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