1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-02 10:24:11 +01:00

AndroidGCS HID: Remove more locks to try and prevent HID deadlocking

This commit is contained in:
James Cotton 2012-08-13 02:00:54 -05:00
parent aa9894c481
commit 2f65952952

View File

@ -343,7 +343,7 @@ public class Telemetry {
/** /**
* Update an object based on its metadata properties * Update an object based on its metadata properties
*/ */
private synchronized void updateObject(UAVObject obj) private void updateObject(UAVObject obj)
{ {
// Get metadata // Get metadata
UAVObject.Metadata metadata = obj.getMetadata(); UAVObject.Metadata metadata = obj.getMetadata();
@ -393,7 +393,7 @@ public class Telemetry {
* Called when a transaction is successfully completed (uavtalk event) * Called when a transaction is successfully completed (uavtalk event)
* @throws IOException * @throws IOException
*/ */
private synchronized void transactionCompleted(UAVObject obj, boolean result) throws IOException private void transactionCompleted(UAVObject obj, boolean result) throws IOException
{ {
if (DEBUG) Log.d(TAG,"UAVTalk transactionCompleted"); if (DEBUG) Log.d(TAG,"UAVTalk transactionCompleted");
// Check if there is a pending transaction and the objects match // Check if there is a pending transaction and the objects match
@ -401,8 +401,11 @@ public class Telemetry {
{ {
if (DEBUG) Log.d(TAG,"Telemetry: transaction completed for " + obj.getName()); if (DEBUG) Log.d(TAG,"Telemetry: transaction completed for " + obj.getName());
// Complete transaction // Complete transaction
synchronized(transTimer) {
transTimer.cancel(); transTimer.cancel();
transPending = false; transPending = false;
}
//Send signal //Send signal
obj.transactionCompleted(result); obj.transactionCompleted(result);
@ -419,9 +422,10 @@ public class Telemetry {
* Called when a transaction is not completed within the timeout period (timer event) * Called when a transaction is not completed within the timeout period (timer event)
* @throws IOException * @throws IOException
*/ */
private synchronized void transactionTimeout() throws IOException private void transactionTimeout() throws IOException
{ {
if (DEBUG) Log.d(TAG,"Telemetry: transaction timeout."); if (DEBUG) Log.d(TAG,"Telemetry: transaction timeout.");
synchronized(transTimer) {
transTimer.cancel(); transTimer.cancel();
// Proceed only if there is a pending transaction // Proceed only if there is a pending transaction
if ( transPending ) if ( transPending )
@ -446,12 +450,13 @@ public class Telemetry {
} }
} }
} }
}
/** /**
* Start an object transaction with UAVTalk, all information is stored in transInfo * Start an object transaction with UAVTalk, all information is stored in transInfo
* @throws IOException * @throws IOException
*/ */
private synchronized void processObjectTransaction() throws IOException private void processObjectTransaction() throws IOException
{ {
if (transPending) if (transPending)
{ {
@ -472,9 +477,11 @@ public class Telemetry {
} }
else else
{ {
synchronized(transTimer) {
transTimer.cancel(); transTimer.cancel();
transPending = false; transPending = false;
} }
}
} else } else
{ {
if (ERROR) Log.e(TAG,"Error: inside of processObjectTransaction with no transPending"); if (ERROR) Log.e(TAG,"Error: inside of processObjectTransaction with no transPending");
@ -628,11 +635,12 @@ public class Telemetry {
* TODO: Clean-up * TODO: Clean-up
* @throws IOException * @throws IOException
*/ */
private synchronized void processPeriodicUpdates() throws IOException private void processPeriodicUpdates() throws IOException
{ {
if (DEBUG) Log.d(TAG, "processPeriodicUpdates()"); if (DEBUG) Log.d(TAG, "processPeriodicUpdates()");
// Stop timer // Stop timer
updateTimer.cancel(); updateTimer.cancel();
// Iterate through each object and update its timer, if zero then transmit object. // Iterate through each object and update its timer, if zero then transmit object.
@ -705,7 +713,7 @@ public class Telemetry {
return stats; return stats;
} }
public synchronized void resetStats() public void resetStats()
{ {
utalk.resetStats(); utalk.resetStats();
txErrors = 0; txErrors = 0;