Drain events before terminating log/thread managers.

Using the default scripts, the events from RemoteSerializer::LogStats()
were attempting to use the logging framework after logging/threading
had been terminated which never worked right and sometimes caused
crashes with "fatal error: cannot lock mutex".

Also made communication log baseline test pass more reliably.
This commit is contained in:
Jon Siwek 2012-06-28 12:42:32 -05:00
parent a651185ff9
commit 21a0e74d68
3 changed files with 23 additions and 17 deletions

View file

@ -313,6 +313,8 @@ void terminate_bro()
if ( remote_serializer ) if ( remote_serializer )
remote_serializer->LogStats(); remote_serializer->LogStats();
mgr.Drain();
log_mgr->Terminate(); log_mgr->Terminate();
thread_mgr->Terminate(); thread_mgr->Terminate();

View file

@ -5,17 +5,18 @@
#path communication #path communication
#fields ts peer src_name connected_peer_desc connected_peer_addr connected_peer_port level message #fields ts peer src_name connected_peer_desc connected_peer_addr connected_peer_port level message
#types time string string string addr port string string #types time string string string addr port string string
1326492291.485390 bro parent - - - info [#1/127.0.0.1:47757] added peer 1340904724.781527 bro parent - - - info [#1/127.0.0.1:47757] added peer
1326492291.491731 bro child - - - info [#1/127.0.0.1:47757] connected 1340904724.784954 bro child - - - info [#1/127.0.0.1:47757] connected
1326492291.492024 bro parent - - - info [#1/127.0.0.1:47757] peer connected 1340904724.786168 bro parent - - - info [#1/127.0.0.1:47757] peer connected
1326492291.492024 bro parent - - - info [#1/127.0.0.1:47757] phase: version 1340904724.786168 bro parent - - - info [#1/127.0.0.1:47757] phase: version
1326492291.492740 bro script - - - info connection established 1340904724.786168 bro script - - - info connection established
1326492291.492740 bro script - - - info requesting events matching /^?(NOTHING)$?/ 1340904724.786168 bro script - - - info requesting events matching /^?(NOTHING)$?/
1326492291.492740 bro script - - - info accepting state 1340904724.786168 bro script - - - info accepting state
1326492291.493800 bro parent - - - info [#1/127.0.0.1:47757] phase: handshake 1340904724.787645 bro parent - - - info [#1/127.0.0.1:47757] phase: handshake
1326492291.493800 bro parent - - - info warning: no events to request 1340904724.787645 bro parent - - - info warning: no events to request
1326492291.494161 bro parent - - - info [#1/127.0.0.1:47757] peer_description is bro 1340904724.788857 bro parent - - - info [#1/127.0.0.1:47757] peer_description is bro
1326492291.494404 bro parent - - - info [#1/127.0.0.1:47757] peer supports keep-in-cache; using that 1340904724.829480 bro parent - - - info [#1/127.0.0.1:47757] peer supports keep-in-cache; using that
1326492291.494404 bro parent - - - info [#1/127.0.0.1:47757] phase: running 1340904724.829480 bro parent - - - info [#1/127.0.0.1:47757] phase: running
1326492291.494404 bro parent - - - info terminating... 1340904724.829480 bro parent - - - info terminating...
1326492291.494404 bro parent - - - info [#1/127.0.0.1:47757] closing connection 1340904724.832952 bro child - - - info terminating
1340904724.834082 bro parent - - - info [#1/127.0.0.1:47757] closing connection

View file

@ -5,7 +5,7 @@
# @TEST-EXEC: btest-bg-wait -k 10 # @TEST-EXEC: btest-bg-wait -k 10
# #
# Don't diff the receiver log just because port is always going to change # Don't diff the receiver log just because port is always going to change
# @TEST-EXEC: egrep -v 'pid|socket buffer size' sender/communication.log >send.log # @TEST-EXEC: egrep -v 'CPU|bytes|pid|socket buffer size' sender/communication.log >send.log
# @TEST-EXEC: btest-diff send.log # @TEST-EXEC: btest-diff send.log
@TEST-START-FILE sender.bro @TEST-START-FILE sender.bro
@ -19,6 +19,10 @@ redef Communication::nodes += {
event remote_connection_handshake_done(p: event_peer) event remote_connection_handshake_done(p: event_peer)
{ {
terminate_communication(); terminate_communication();
}
event remote_connection_closed(p: event_peer)
{
terminate(); terminate();
} }
@ -30,9 +34,8 @@ event remote_connection_handshake_done(p: event_peer)
@load frameworks/communication/listen @load frameworks/communication/listen
event remote_connection_handshake_done(p: event_peer) event remote_connection_closed(p: event_peer)
{ {
terminate_communication();
terminate(); terminate();
} }