Skip to content

Commit

Permalink
adding back code to close socket on invalid connection
Browse files Browse the repository at this point in the history
  • Loading branch information
samdmarshall committed Nov 23, 2014
1 parent d20aacc commit ac0314e
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 18 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Expand Up @@ -16,4 +16,6 @@ build/
xcuserdata
SDMMobileDevice.xcworkspace/xcuserdata/
SDMMobileDevice.podspec
podspec
podspec
*/*.xcodeproj/xcshareddata
SDMMobileDevice.xcworkspace/xcshareddata
20 changes: 10 additions & 10 deletions Framework/MobileDevice/Connection/SDMMD_Connection.c
Expand Up @@ -400,12 +400,12 @@ sdmmd_return_t SDMMD_AMDeviceSecureStartService(SDMMD_AMDeviceRef device, CFStri

sdmmd_return_t SDMMD_AMDeviceStartService(SDMMD_AMDeviceRef device, CFStringRef service, CFDictionaryRef options, SDMMD_AMConnectionRef *connection) {
sdmmd_return_t result = kAMDInvalidArgumentError;
//uint32_t socket = -1;
uint32_t tmp_socket = -1, socket = -1;
if (device && connection) {
SSL *ssl_enabled = NULL;
if (service) {
if (device->ivars.device_active) {
CFMutableDictionaryRef optionsCopy;
CFMutableDictionaryRef optionsCopy = NULL;
if (options) {
optionsCopy = CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, options);
}
Expand All @@ -417,10 +417,11 @@ sdmmd_return_t SDMMD_AMDeviceStartService(SDMMD_AMDeviceRef device, CFStringRef
result = SDMMD_AMDeviceSecureStartService(device, service, optionsCopy, connection);
CFSafeRelease(optionsCopy);
if (result == 0) {
//socket = SDMMD_AMDServiceConnectionGetSocket(*connection);
socket = SDMMD_AMDServiceConnectionGetSocket(*connection);
ssl_enabled = SDMMD_AMDServiceConnectionGetSecureIOContext(*connection);
if (ssl_enabled) {
result = kAMDNoWifiSyncSupportError;
tmp_socket = socket;
}
else {
result = kAMDSuccess;
Expand All @@ -436,15 +437,14 @@ sdmmd_return_t SDMMD_AMDeviceStartService(SDMMD_AMDeviceRef device, CFStringRef
ssl_enabled = NULL;
}
}
/*if (ssl_enabled)
if (ssl_enabled) {
SSL_free(ssl_enabled);
if (socket != 0xff) {
if(close(socket) == 0xff) {
printf("SDMMD_AMDeviceStartService: close(2) con socket %d failed: %d\n",socket,errno);
}
}*/
}
if (tmp_socket != -1 && close(tmp_socket) == -1) {
printf("%s: close(2) con socket %d failed: %d\n",__FUNCTION__, tmp_socket,errno);
}
}
//printf("SDMMD_AMDeviceStartService: returning 0x%x, socket is %d.\n",result, socket);
//printf("%s: returning 0x%x, socket is %d.\n",__FUNCTION__, result, socket);
return result;
}

Expand Down
6 changes: 5 additions & 1 deletion Framework/MobileDevice/Services/Debugger/SDMMD_Debugger.c
Expand Up @@ -82,6 +82,7 @@ sdmmd_return_t SDMMD_AMDebugConnectionStart(SDMMD_AMDebugConnectionRef dconn) {

dconn->connection = SDMMD_AMDServiceConnectionCreate(0, NULL, NULL);
result = SDMMD_AMDeviceStartService(dconn->device, CFSTR(AMSVC_DEBUG_SERVER), NULL, &(dconn->connection));
CheckErrorAndReturn(result);

result = SDMMD_AMDeviceStopSession(dconn->device);
CheckErrorAndReturn(result);
Expand Down Expand Up @@ -167,7 +168,10 @@ sdmmd_return_t SDMMD__hangup_with_image_mounter_service(SDMMD_AMConnectionRef co
result = SDMMD_ServiceReceiveMessage(socket, &response);
PrintCFDictionary(response);
}
ExitLabelAndReturn(result);

ExitLabel:
CFSafeRelease(dict);
return result;
}

CFStringRef SDMMD_CopyDeviceSupportPathFromXCRUN() {
Expand Down
Expand Up @@ -597,8 +597,8 @@
22DEF962188350E6008E909F /* CoreFoundation */ = {
isa = PBXGroup;
children = (
22A58E1C191157F600303D31 /* CFStringAddition.c */,
22A58E1D191157F600303D31 /* CFStringAddition.h */,
22A58E1C191157F600303D31 /* CFStringAddition.c */,
22C892AA189D75A1008B1D2D /* CFDataAddition.h */,
22C892A9189D75A1008B1D2D /* CFDataAddition.c */,
22DEF964188350E6008E909F /* CFDictionaryAddition.h */,
Expand Down
Expand Up @@ -10,30 +10,38 @@
<string>SDMMobileDevice</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>5DC493081D5ABCA9EA77A520F32861D07A12B20C</key>
<string>github.com:samdmarshall/SDMMobileDevice.git</string>
<key>69DB9D35-4562-46FC-9ADE-37339C753AA0</key>
<string>ssh://github.com/samdmarshall/Core-Lib.git</string>
<key>E03DDEF6-B97D-41E3-B129-83B8A6249CEB</key>
<string>ssh://github.com/samdmarshall/SDMMobileDevice.git</string>
<key>E3836662-8199-4399-9034-FC52A1A354C7</key>
<string>ssh://github.com/samdmarshall/Macro-Utilities.git</string>
<key>F09F31DD51BF51244351F594DC43B25CE185FB38</key>
<string>github.com:samdmarshall/Core-Lib.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>SDMMobileDevice.xcworkspace</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>5DC493081D5ABCA9EA77A520F32861D07A12B20C</key>
<string>..</string>
<key>69DB9D35-4562-46FC-9ADE-37339C753AA0</key>
<string>../Core</string>
<string>../../SDM_MD_Demo/Core</string>
<key>E03DDEF6-B97D-41E3-B129-83B8A6249CEB</key>
<string>..</string>
<string>../../SDM_MD_Demo</string>
<key>E3836662-8199-4399-9034-FC52A1A354C7</key>
<string>../../Macro Utilities</string>
<key>F09F31DD51BF51244351F594DC43B25CE185FB38</key>
<string>..Core</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>ssh://github.com/samdmarshall/SDMMobileDevice.git</string>
<string>github.com:samdmarshall/SDMMobileDevice.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>110</integer>
<integer>111</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>E03DDEF6-B97D-41E3-B129-83B8A6249CEB</string>
<string>5DC493081D5ABCA9EA77A520F32861D07A12B20C</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
Expand All @@ -60,6 +68,22 @@
<key>IDESourceControlWCCName</key>
<string>SDM_MD_Demo</string>
</dict>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>5DC493081D5ABCA9EA77A520F32861D07A12B20C</string>
<key>IDESourceControlWCCName</key>
<string>SDMMobileDevice</string>
</dict>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>F09F31DD51BF51244351F594DC43B25CE185FB38</string>
<key>IDESourceControlWCCName</key>
<string>SDMMobileDeviceCore</string>
</dict>
</array>
</dict>
</plist>

0 comments on commit ac0314e

Please sign in to comment.