Fix a race that could crash a few threads in the input thread pool

This commit is contained in:
Cameron Gutman 2013-12-20 15:06:56 -05:00
parent 48f8a05bae
commit a1440621f9

View File

@ -194,8 +194,13 @@ public class NvConnection {
private boolean startInputConnection() throws IOException
{
inputStream = new NvController(hostAddr);
inputStream.initialize();
// Because input events can be delivered at any time, we must only assign
// it to the instance variable once the object is properly initialized.
// This avoids the race where inputStream != null but inputStream.initialize()
// has not returned yet.
NvController tempController = new NvController(hostAddr);
tempController.initialize();
inputStream = tempController;
return true;
}