samdmarshall/SDMMobileDevice — pull request #64 by JeremyAgost (2014-12-11 11:26:01+00:00)
Title: SSL connection stability

Don't allow creation of AMConnectionRef with SSL context unless the socket is valid. Clear the SSL error queue before calling SSL functions and checking for errors.

I've got reproducible cases with large numbers of devices where an SSL context is created but the socket is invalid because the application hit e.g. a file descriptor limit. In that case, using any of the ServiceSend/Receive functions on the associated connection will cause issues because the SSL context doesn't have a socket. The change to AMDServiceConnectionCreate will make the service start routines return kAMDNoResourcesError instead of providing an inherently invalid AMConnectionRef.