Skip to content

Commit

Permalink
Merge pull request #213 from mavlink/fix-stream-leak
Browse files Browse the repository at this point in the history
Fix stream leak
  • Loading branch information
JonasVautherin authored Jul 7, 2022
2 parents 66da999 + 2fae49d commit 6f202ce
Show file tree
Hide file tree
Showing 16 changed files with 350 additions and 210 deletions.
56 changes: 35 additions & 21 deletions Sources/Mavsdk/Generated/ActionServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -439,12 +439,12 @@ public class ActionServer {


private func createArmDisarmObservable() -> Observable<ArmDisarm> {
return Observable.create { observer in
return Observable.create { [unowned self] observer in
let request = Mavsdk_Rpc_ActionServer_SubscribeArmDisarmRequest()



_ = self.service.subscribeArmDisarm(request, handler: { (response) in
let serverStreamingCall = self.service.subscribeArmDisarm(request, handler: { (response) in



Expand All @@ -465,7 +465,9 @@ public class ActionServer {

})

return Disposables.create()
return Disposables.create {
serverStreamingCall.cancel(promise: nil)
}
}
.retry { error in
error.map {
Expand All @@ -484,12 +486,12 @@ public class ActionServer {


private func createFlightModeChangeObservable() -> Observable<FlightMode> {
return Observable.create { observer in
return Observable.create { [unowned self] observer in
let request = Mavsdk_Rpc_ActionServer_SubscribeFlightModeChangeRequest()



_ = self.service.subscribeFlightModeChange(request, handler: { (response) in
let serverStreamingCall = self.service.subscribeFlightModeChange(request, handler: { (response) in



Expand All @@ -510,7 +512,9 @@ public class ActionServer {

})

return Disposables.create()
return Disposables.create {
serverStreamingCall.cancel(promise: nil)
}
}
.retry { error in
error.map {
Expand All @@ -529,12 +533,12 @@ public class ActionServer {


private func createTakeoffObservable() -> Observable<Bool> {
return Observable.create { observer in
return Observable.create { [unowned self] observer in
let request = Mavsdk_Rpc_ActionServer_SubscribeTakeoffRequest()



_ = self.service.subscribeTakeoff(request, handler: { (response) in
let serverStreamingCall = self.service.subscribeTakeoff(request, handler: { (response) in



Expand All @@ -556,7 +560,9 @@ public class ActionServer {

})

return Disposables.create()
return Disposables.create {
serverStreamingCall.cancel(promise: nil)
}
}
.retry { error in
error.map {
Expand All @@ -575,12 +581,12 @@ public class ActionServer {


private func createLandObservable() -> Observable<Bool> {
return Observable.create { observer in
return Observable.create { [unowned self] observer in
let request = Mavsdk_Rpc_ActionServer_SubscribeLandRequest()



_ = self.service.subscribeLand(request, handler: { (response) in
let serverStreamingCall = self.service.subscribeLand(request, handler: { (response) in



Expand All @@ -602,7 +608,9 @@ public class ActionServer {

})

return Disposables.create()
return Disposables.create {
serverStreamingCall.cancel(promise: nil)
}
}
.retry { error in
error.map {
Expand All @@ -621,12 +629,12 @@ public class ActionServer {


private func createRebootObservable() -> Observable<Bool> {
return Observable.create { observer in
return Observable.create { [unowned self] observer in
let request = Mavsdk_Rpc_ActionServer_SubscribeRebootRequest()



_ = self.service.subscribeReboot(request, handler: { (response) in
let serverStreamingCall = self.service.subscribeReboot(request, handler: { (response) in



Expand All @@ -648,7 +656,9 @@ public class ActionServer {

})

return Disposables.create()
return Disposables.create {
serverStreamingCall.cancel(promise: nil)
}
}
.retry { error in
error.map {
Expand All @@ -667,12 +677,12 @@ public class ActionServer {


private func createShutdownObservable() -> Observable<Bool> {
return Observable.create { observer in
return Observable.create { [unowned self] observer in
let request = Mavsdk_Rpc_ActionServer_SubscribeShutdownRequest()



_ = self.service.subscribeShutdown(request, handler: { (response) in
let serverStreamingCall = self.service.subscribeShutdown(request, handler: { (response) in



Expand All @@ -694,7 +704,9 @@ public class ActionServer {

})

return Disposables.create()
return Disposables.create {
serverStreamingCall.cancel(promise: nil)
}
}
.retry { error in
error.map {
Expand All @@ -713,12 +725,12 @@ public class ActionServer {


private func createTerminateObservable() -> Observable<Bool> {
return Observable.create { observer in
return Observable.create { [unowned self] observer in
let request = Mavsdk_Rpc_ActionServer_SubscribeTerminateRequest()



_ = self.service.subscribeTerminate(request, handler: { (response) in
let serverStreamingCall = self.service.subscribeTerminate(request, handler: { (response) in



Expand All @@ -740,7 +752,9 @@ public class ActionServer {

})

return Disposables.create()
return Disposables.create {
serverStreamingCall.cancel(promise: nil)
}
}
.retry { error in
error.map {
Expand Down
40 changes: 25 additions & 15 deletions Sources/Mavsdk/Generated/Calibration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,12 @@ public class Calibration {
*/

public func calibrateGyro() -> Observable<ProgressData> {
return Observable.create { observer in
return Observable.create { [unowned self] observer in
let request = Mavsdk_Rpc_Calibration_SubscribeCalibrateGyroRequest()



_ = self.service.subscribeCalibrateGyro(request, handler: { (response) in
let serverStreamingCall = self.service.subscribeCalibrateGyro(request, handler: { (response) in



Expand All @@ -309,7 +309,9 @@ public class Calibration {

})

return Disposables.create()
return Disposables.create {
serverStreamingCall.cancel(promise: nil)
}
}
.retry { error in
error.map {
Expand All @@ -327,12 +329,12 @@ public class Calibration {
*/

public func calibrateAccelerometer() -> Observable<ProgressData> {
return Observable.create { observer in
return Observable.create { [unowned self] observer in
let request = Mavsdk_Rpc_Calibration_SubscribeCalibrateAccelerometerRequest()



_ = self.service.subscribeCalibrateAccelerometer(request, handler: { (response) in
let serverStreamingCall = self.service.subscribeCalibrateAccelerometer(request, handler: { (response) in



Expand All @@ -353,7 +355,9 @@ public class Calibration {

})

return Disposables.create()
return Disposables.create {
serverStreamingCall.cancel(promise: nil)
}
}
.retry { error in
error.map {
Expand All @@ -371,12 +375,12 @@ public class Calibration {
*/

public func calibrateMagnetometer() -> Observable<ProgressData> {
return Observable.create { observer in
return Observable.create { [unowned self] observer in
let request = Mavsdk_Rpc_Calibration_SubscribeCalibrateMagnetometerRequest()



_ = self.service.subscribeCalibrateMagnetometer(request, handler: { (response) in
let serverStreamingCall = self.service.subscribeCalibrateMagnetometer(request, handler: { (response) in



Expand All @@ -397,7 +401,9 @@ public class Calibration {

})

return Disposables.create()
return Disposables.create {
serverStreamingCall.cancel(promise: nil)
}
}
.retry { error in
error.map {
Expand All @@ -415,12 +421,12 @@ public class Calibration {
*/

public func calibrateLevelHorizon() -> Observable<ProgressData> {
return Observable.create { observer in
return Observable.create { [unowned self] observer in
let request = Mavsdk_Rpc_Calibration_SubscribeCalibrateLevelHorizonRequest()



_ = self.service.subscribeCalibrateLevelHorizon(request, handler: { (response) in
let serverStreamingCall = self.service.subscribeCalibrateLevelHorizon(request, handler: { (response) in



Expand All @@ -441,7 +447,9 @@ public class Calibration {

})

return Disposables.create()
return Disposables.create {
serverStreamingCall.cancel(promise: nil)
}
}
.retry { error in
error.map {
Expand All @@ -459,12 +467,12 @@ public class Calibration {
*/

public func calibrateGimbalAccelerometer() -> Observable<ProgressData> {
return Observable.create { observer in
return Observable.create { [unowned self] observer in
let request = Mavsdk_Rpc_Calibration_SubscribeCalibrateGimbalAccelerometerRequest()



_ = self.service.subscribeCalibrateGimbalAccelerometer(request, handler: { (response) in
let serverStreamingCall = self.service.subscribeCalibrateGimbalAccelerometer(request, handler: { (response) in



Expand All @@ -485,7 +493,9 @@ public class Calibration {

})

return Disposables.create()
return Disposables.create {
serverStreamingCall.cancel(promise: nil)
}
}
.retry { error in
error.map {
Expand Down
Loading

0 comments on commit 6f202ce

Please sign in to comment.