fredlala8 / marketbilling

Automatically exported from code.google.com/p/marketbilling
0 stars 0 forks source link

Race condition in runRequest() due to unsynchornized mService #68

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
BillingRequest.runRequest performs a check on mService to see if 
onServiceConnected has set its value. If the value is set, the service has 
connected and we execute the request immediately, otherwise we queue the 
request until the service is connected.

Since the service connects asynchronously it's possible that a BillingRequest 
made immediately after starting the service will never be executed. In this 
case the request is added to the queue but bad timing can mean it happens after 
onServiceConnected has processed its pending queue. This can be resolved by 
putting the code that sets mService and the code that checks mService != null 
in synchronized blocks. With that in place the first request to the 
BillingService is always processed.

Original issue reported on code.google.com by trevorjohns@google.com on 8 May 2012 at 8:18