Skip to content

Commit

Permalink
Fixes #1564
Browse files Browse the repository at this point in the history
* Ensure that all RPC requests are sent on the processing queue to ensure protected resources are accessed synchronously from the same queue
  • Loading branch information
joeljfischer committed Feb 24, 2020
1 parent b4a95b4 commit f9cddf2
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions SmartDeviceLink/SDLLifecycleManager.m
Expand Up @@ -342,7 +342,7 @@ - (void)didEnterStateConnected {

// Send the request and depending on the response, post the notification
__weak typeof(self) weakSelf = self;
[self sdl_sendRequest:regRequest
[self sendConnectionManagerRequest:regRequest
withResponseHandler:^(__kindof SDLRPCRequest *_Nullable request, __kindof SDLRPCResponse *_Nullable response, NSError *_Nullable error) {
// If the success BOOL is NO or we received an error at this point, we failed. Call the ready handler and transition to the DISCONNECTED state.
if (error != nil || ![response.success boolValue]) {
Expand Down Expand Up @@ -587,7 +587,7 @@ - (void)sdl_sendAppIcon:(nullable SDLFile *)appIcon withCompletion:(void (^)(voi
SDLSetAppIcon *setAppIcon = [[SDLSetAppIcon alloc] init];
setAppIcon.syncFileName = appIcon.name;

[self sdl_sendRequest:setAppIcon
[self sendConnectionManagerRequest:setAppIcon
withResponseHandler:^(__kindof SDLRPCRequest *_Nullable request, __kindof SDLRPCResponse *_Nullable response, NSError *_Nullable error) {
if (error != nil) {
SDLLogW(@"Error setting up app icon: %@", error);
Expand Down Expand Up @@ -651,7 +651,9 @@ - (void)sendConnectionRPC:(__kindof SDLRPCMessage *)rpc {
return;
}

[self sdl_sendRequest:rpc withResponseHandler:nil];
[self sdl_runOnProcessingQueue:^{
[self sdl_sendRequest:rpc withResponseHandler:nil];
}];
}

- (void)sendConnectionRequest:(__kindof SDLRPCRequest *)request withResponseHandler:(nullable SDLResponseHandler)handler {
Expand All @@ -676,13 +678,17 @@ - (void)sendConnectionRequest:(__kindof SDLRPCRequest *)request withResponseHand

return;
}

[self sdl_sendRequest:request withResponseHandler:handler];

[self sdl_runOnProcessingQueue:^{
[self sdl_sendRequest:request withResponseHandler:handler];
}];
}

// Managers need to avoid state checking. Part of <SDLConnectionManagerType>.
- (void)sendConnectionManagerRequest:(__kindof SDLRPCMessage *)request withResponseHandler:(nullable SDLResponseHandler)handler {
[self sdl_sendRequest:request withResponseHandler:handler];
[self sdl_runOnProcessingQueue:^{
[self sdl_sendRequest:request withResponseHandler:handler];
}];
}

- (void)sdl_sendRequest:(__kindof SDLRPCMessage *)request withResponseHandler:(nullable SDLResponseHandler)handler {
Expand Down

0 comments on commit f9cddf2

Please sign in to comment.