changeset 214:9cc5a10cf711

8131165: [UART] Race condition at device status flags Summary: Fixed device status flag access order. Reviewed-by: alkonsta
author snazarki
date Tue, 14 Jul 2015 18:20:07 +0300
parents a2c106aa4c74
children 1a709d70a4cf
files src/share/linux/native/com/oracle/dio/uart/uart.c
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/linux/native/com/oracle/dio/uart/uart.c	Tue Jul 14 15:46:19 2015 +0300
+++ b/src/share/linux/native/com/oracle/dio/uart/uart.c	Tue Jul 14 18:20:07 2015 +0300
@@ -48,8 +48,8 @@
     uart_handle port = (uart_handle)handle;
     if (port->subscribedEvents & SERIAL_OUT_EMPTY) {
         if(!(port->notifiedEvents & SERIAL_OUT_EMPTY)){
+            port->notifiedEvents |= SERIAL_OUT_EMPTY;
             javanotify_uart_event(OUTPUT_BUFFER_EMPTY, handle, param, res);
-            port->notifiedEvents |= SERIAL_OUT_EMPTY;
         }
     }
     if (port->async_write_ongoing == JAVACALL_FALSE){
@@ -60,8 +60,8 @@
 static void _buffer_overrun_cb(javacall_handle handle, int param, javacall_result error) {
     uart_handle port = (uart_handle)handle;
     if ( (port->subscribedEvents & SERIAL_IN_OVERRUN) && !(port->notifiedEvents & SERIAL_IN_OVERRUN)) {
+        port->notifiedEvents |= SERIAL_IN_OVERRUN;
         javanotify_uart_event(INPUT_BUFFER_OVERRUN, (javacall_handle) port, 0, error);
-        port->notifiedEvents |= SERIAL_IN_OVERRUN;
     }
 }
 
@@ -69,8 +69,8 @@
     uart_handle port = (uart_handle)handle;
     if ( port->subscribedEvents & SERIAL_IN_AVAILABLE){
         if(!(port->notifiedEvents & SERIAL_IN_AVAILABLE)) {
+            port->notifiedEvents |= SERIAL_IN_AVAILABLE;
             javanotify_uart_event(INPUT_DATA_AVAILABLE, (javacall_handle) port, param, res);
-            port->notifiedEvents |= SERIAL_IN_AVAILABLE;
         }
     }else{
     //unblock midp thread