altosuilib: Make sure only one thread is closing serial device
authorKeith Packard <keithp@keithp.com>
Sat, 14 Jun 2014 21:38:00 +0000 (14:38 -0700)
committerKeith Packard <keithp@keithp.com>
Sat, 14 Jun 2014 21:38:00 +0000 (14:38 -0700)
Multiple closers can cause a crash by freeing the libaltos device twice

Signed-off-by: Keith Packard <keithp@keithp.com>
altosuilib/AltosSerial.java

index 0632ca7072c3dfae9c887f629a1aa78e06bc5bde..60e15bdb094c9b0d664ef8940f587090e34062e1 100644 (file)
@@ -117,7 +117,7 @@ public class AltosSerial extends AltosLink  {
                SwingUtilities.invokeLater(r);
        }
 
-       private void close_serial() {
+       private synchronized void close_serial() {
                synchronized (devices_opened) {
                        devices_opened.remove(device.getPath());
                }