Skip to content

Commit

Permalink
Fixed #558: Fix leak of RCConnection that prevents RCDevice to get freed
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonis committed Mar 31, 2017
1 parent 39c2734 commit 2999f6c
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
/* End PBXAggregateTarget section */

/* Begin PBXBuildFile section */
8D077AE924D682A3864EB1B6 /* libPods-restcomm-olympus.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BC4348E4400029D41BAF43FE /* libPods-restcomm-olympus.a */; };
AE0A08351DD2101100641151 /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AE0A08341DD2101100641151 /* CoreMotion.framework */; };
AE155F541CCF8658002F404E /* ToastController.m in Sources */ = {isa = PBXBuildFile; fileRef = AE155F531CCF8658002F404E /* ToastController.m */; };
AE20DA841CE31EC200695925 /* speaker-on-50x50.png in Resources */ = {isa = PBXBuildFile; fileRef = AE20DA811CE31EC200695925 /* speaker-on-50x50.png */; };
Expand Down Expand Up @@ -219,6 +220,7 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
7E04E0726E9DAAD39F403925 /* Pods-restcomm-olympus.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-restcomm-olympus.debug.xcconfig"; path = "Pods/Target Support Files/Pods-restcomm-olympus/Pods-restcomm-olympus.debug.xcconfig"; sourceTree = "<group>"; };
AE0A08341DD2101100641151 /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = System/Library/Frameworks/CoreMotion.framework; sourceTree = SDKROOT; };
AE155F521CCF8658002F404E /* ToastController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ToastController.h; sourceTree = "<group>"; };
AE155F531CCF8658002F404E /* ToastController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ToastController.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -416,6 +418,8 @@
AEED2F0B1C7F252000006E76 /* SIPSettingsNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SIPSettingsNavigationController.m; sourceTree = "<group>"; };
AEFA3BCB1C7F32E600ECD02F /* ICESettingsNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ICESettingsNavigationController.h; sourceTree = "<group>"; };
AEFA3BCC1C7F32E600ECD02F /* ICESettingsNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ICESettingsNavigationController.m; sourceTree = "<group>"; };
BC4348E4400029D41BAF43FE /* libPods-restcomm-olympus.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-restcomm-olympus.a"; sourceTree = BUILT_PRODUCTS_DIR; };
DEB244673BF1A52D93E92613 /* Pods-restcomm-olympus.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-restcomm-olympus.release.xcconfig"; path = "Pods/Target Support Files/Pods-restcomm-olympus/Pods-restcomm-olympus.release.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -425,6 +429,7 @@
files = (
AE0A08351DD2101100641151 /* CoreMotion.framework in Frameworks */,
AEA4967F1C2997F6000D9762 /* libTestFairy.a in Frameworks */,
8D077AE924D682A3864EB1B6 /* libPods-restcomm-olympus.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -438,6 +443,15 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
A3CF81123D358C8601AD0862 /* Pods */ = {
isa = PBXGroup;
children = (
7E04E0726E9DAAD39F403925 /* Pods-restcomm-olympus.debug.xcconfig */,
DEB244673BF1A52D93E92613 /* Pods-restcomm-olympus.release.xcconfig */,
);
name = Pods;
sourceTree = "<group>";
};
AE3E52C31C57BB7B0057F5D0 /* cert */ = {
isa = PBXGroup;
children = (
Expand All @@ -454,6 +468,7 @@
AE79D31719BC8DAD0023306C /* Products */,
AEA495651C2997F6000D9762 /* restcomm-olympus */,
AED0B05F1A0976F8008A6057 /* restcomm-olympusTests */,
A3CF81123D358C8601AD0862 /* Pods */,
);
sourceTree = "<group>";
};
Expand All @@ -470,6 +485,7 @@
isa = PBXGroup;
children = (
AE0A08341DD2101100641151 /* CoreMotion.framework */,
BC4348E4400029D41BAF43FE /* libPods-restcomm-olympus.a */,
);
name = Frameworks;
sourceTree = "<group>";
Expand Down Expand Up @@ -728,10 +744,13 @@
isa = PBXNativeTarget;
buildConfigurationList = AE79D34B19BC8DAE0023306C /* Build configuration list for PBXNativeTarget "restcomm-olympus" */;
buildPhases = (
54FAC50C676569AB62D7A177 /* [CP] Check Pods Manifest.lock */,
AE79D31219BC8DAD0023306C /* Sources */,
AE79D31319BC8DAD0023306C /* Frameworks */,
AE79D31419BC8DAD0023306C /* Resources */,
AE7D36491D9E707F00610033 /* Embed Frameworks */,
4D093DA00E5D5809F67951E4 /* [CP] Embed Pods Frameworks */,
C3CFD8736FDBD50DD78AA037 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -967,6 +986,36 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
4D093DA00E5D5809F67951E4 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-restcomm-olympus/Pods-restcomm-olympus-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
54FAC50C676569AB62D7A177 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
AED9718819E98B77000F7A8E /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand All @@ -993,6 +1042,21 @@
shellPath = /bin/sh;
shellScript = "cd \"${PROJECT_DIR}/doc\"\ndoxygen Doxyfile";
};
C3CFD8736FDBD50DD78AA037 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-restcomm-olympus/Pods-restcomm-olympus-resources.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down Expand Up @@ -1165,6 +1229,7 @@
};
AE79D34C19BC8DAE0023306C /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 7E04E0726E9DAAD39F403925 /* Pods-restcomm-olympus.debug.xcconfig */;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD)";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
Expand Down Expand Up @@ -1204,6 +1269,7 @@
};
AE79D34D19BC8DAE0023306C /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = DEB244673BF1A52D93E92613 /* Pods-restcomm-olympus.release.xcconfig */;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD)";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@

@protocol CallDelegate <NSObject>
//- (void)callViewController:(CallViewController *)callViewController didSendStatus:(NSString *)status;
@end
@end
11 changes: 11 additions & 0 deletions RestCommClient/Classes/RCConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ - (void)disconnect
[self.ringingPlayer stop];
self.ringingPlayer.currentTime = 0.0;
}

[self handleDisconnected];
}

- (void)sendDigits:(NSString*)digits
Expand Down Expand Up @@ -243,6 +245,11 @@ - (void)sipManagerDidReceiveOutgoingRinging:(SipManager*)sipManager
[self.delegate connectionDidStartConnecting:self];
}

- (void) handleDisconnected
{
[self.device clearCurrentConnection];
}

- (void)sipManagerDidReceiveOutgoingEstablished:(SipManager*)sipManager
{
RCLogNotice("[RCConnection sipManagerDidReceiveOutgoingEstablished]");
Expand Down Expand Up @@ -281,6 +288,7 @@ - (void)sipManagerDidReceiveOutgoingCancelled:(SipManager*)sipManager;
self.state = RCConnectionStateDisconnected;
[self.delegate connectionDidDisconnect:self];
self.device.state = RCDeviceStateReady;
[self handleDisconnected];
}

- (void)sipManagerDidReceiveOutgoingDeclined:(SipManager*)sipManager;
Expand All @@ -294,6 +302,7 @@ - (void)sipManagerDidReceiveOutgoingDeclined:(SipManager*)sipManager;
self.state = RCConnectionStateDisconnected;
[self.delegate connectionDidGetDeclined:self];
self.device.state = RCDeviceStateReady;
[self handleDisconnected];
}

- (void)sipManagerDidReceiveBye:(SipManager*)sipManager;
Expand All @@ -312,6 +321,7 @@ - (void)sipManagerDidReceiveBye:(SipManager*)sipManager;
if (self.device.state != RCDeviceStateOffline) {
self.device.state = RCDeviceStateReady;
}
[self handleDisconnected];
}

- (void)sipManagerDidReceiveIncomingCancelled:(SipManager*)sipManager;
Expand All @@ -326,6 +336,7 @@ - (void)sipManagerDidReceiveIncomingCancelled:(SipManager*)sipManager;
self.state = RCConnectionStateDisconnected;
[self.delegate connectionDidCancel:self];
self.device.state = RCDeviceStateReady;
[self handleDisconnected];
}

- (void)sipManager:(SipManager*)sipManager didReceiveLocalVideo:(RTCVideoTrack *)localView;
Expand Down
3 changes: 3 additions & 0 deletions RestCommClient/Classes/RCDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ extern NSString* const RCDeviceCapabilityClientNameKey;
*/
- (BOOL) updateParams:(NSDictionary*)params;

// To be used internally by the library -not for application usage
- (void)clearCurrentConnection;

/* DEBUG:
-(void)startSofia;
-(void)stopSofia;
Expand Down
5 changes: 5 additions & 0 deletions RestCommClient/Classes/RCDevice.m
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ - (void)unlisten
[self.sipManager shutdown:NO];
}

- (void)clearCurrentConnection
{
self.currentConnection = nil;
}

+ (RCDeviceConnectivityType)networkStatus2ConnectivityType:(NetworkStatus)status
{
// right now those 2 enums are one to one, but let's keep the conversion in case the values change at some point
Expand Down

0 comments on commit 2999f6c

Please sign in to comment.