synchronized boolean put ( ByteBuffer event ) throws InterruptedException { boolean isSync = event . getInt ( eventStruct . getTypeIndex ( ) ) == 0 && event . getInt ( eventStruct . getValueIndex ( ) ) == 0 ; while ( bb . limit ( ) - bb . position ( ) < event . limit ( ) ) { // Block if bb is full. This should be the // only time this thread waits for anything // except for more event lines. if ( MonocleSettings . settings . traceEventsVerbose ) { MonocleTrace . traceEvent ( "Event buffer %s is full, waiting for some space to become available" , bb ) ; // wait for half the space to be available, to avoid excessive context switching? } wait ( ) ; } if ( isSync ) { positionOfLastSync = bb . position ( ) ; } bb . put ( event ) ; if ( MonocleSettings . settings . traceEventsVerbose ) { int index = bb . position ( ) - eventStruct . getSize ( ) ; MonocleTrace . traceEvent ( "Read %s [index=%d]" , getEventDescription ( index ) , index ) ; } return isSync ; }
Adds a raw Linux event to the buffer . Blocks if the buffer is full . Checks whether this is a SYN SYN_REPORT event terminator .