From dbba991c4723d1c2d690f0cdd725b968ffcd2e1e Mon Sep 17 00:00:00 2001 From: BlackLight Date: Tue, 23 Nov 2010 18:51:46 +0100 Subject: [PATCH] Fixing some old threading stuff --- alert_parser.c | 40 +++++++--------------------------------- cluster.c | 10 ---------- correlation.c | 10 ---------- db.c | 2 +- spp_ai.h | 2 +- 5 files changed, 9 insertions(+), 55 deletions(-) diff --git a/alert_parser.c b/alert_parser.c index 70cc1bf..e770ff6 100644 --- a/alert_parser.c +++ b/alert_parser.c @@ -45,22 +45,19 @@ unsigned int alerts_pool_count = 0; * \param arg void* pointer to the alert to be added to the pool, if any */ -void* -AI_serializer_thread ( void *arg ) +void +AI_serializer ( AI_snort_alert *alert ) { unsigned int i = 0; - AI_snort_alert *alert = NULL; - if ( arg ) + if ( alert ) { - alert = ( AI_snort_alert* ) arg; - pthread_mutex_lock ( &alerts_pool_mutex ); alerts_pool [ alerts_pool_count++ ] = alert; pthread_mutex_unlock ( &alerts_pool_mutex ); } - if ( !arg || ( arg && alerts_pool_count >= config->alert_bufsize )) + if ( !alert || ( alert && alerts_pool_count >= config->alert_bufsize )) { pthread_mutex_lock ( &alerts_pool_mutex ); AI_serialize_alerts ( alerts_pool, alerts_pool_count ); @@ -73,10 +70,7 @@ AI_serializer_thread ( void *arg ) alerts_pool_count = 0; pthread_mutex_unlock ( &alerts_pool_mutex ); } - - /* pthread_exit ((void*) 0); */ - return (void*) 0; -} /* ----- end of function AI_serializer_thread ----- */ +} /* ----- end of function AI_serializer ----- */ /** @@ -95,17 +89,7 @@ AI_alerts_pool_thread ( void *arg ) if ( !alerts_pool || alerts_pool_count == 0 ) continue; - AI_serializer_thread((void*) 0); - - /* if ( pthread_create ( &serializer_thread, NULL, AI_serializer_thread, NULL ) != 0 ) */ - /* { */ - /* AI_fatal_err ( "Failed to create the alerts' serializer thread", __FILE__, __LINE__ ); */ - /* } */ - - /* if ( pthread_join ( serializer_thread, NULL ) != 0 ) */ - /* { */ - /* AI_fatal_err ( "Could not join the alerts' serializer thread", __FILE__, __LINE__ ); */ - /* } */ + AI_serializer ( NULL ); } pthread_exit ((void*) 0); @@ -295,18 +279,8 @@ AI_file_alertparser_thread ( void* arg ) tmp->next = alert; } - AI_serializer_thread ((void*) alert); + AI_serializer ( alert ); - /* if ( pthread_create ( &serializer_thread, NULL, AI_serializer_thread, alert ) != 0 ) */ - /* { */ - /* AI_fatal_err ( "Failed to create the alerts' serializer thread", __FILE__, __LINE__ ); */ - /* } */ - - /* if ( pthread_join ( serializer_thread, NULL ) != 0 ) */ - /* { */ - /* AI_fatal_err ( "Failed to join the alerts' serializer thread", __FILE__, __LINE__ ); */ - /* } */ - if ( config->outdbtype != outdb_none ) { AI_store_alert_to_db ( alert ); diff --git a/cluster.c b/cluster.c index 796262e..f9626a3 100644 --- a/cluster.c +++ b/cluster.c @@ -290,16 +290,6 @@ __AI_merge_alerts ( AI_snort_alert **log ) alerts_couple->alert2 = tmp2->next; AI_store_cluster_to_db ( alerts_couple ); - - /* if ( pthread_create ( &db_thread, NULL, AI_store_cluster_to_db_thread, alerts_couple ) != 0 ) */ - /* { */ - /* AI_fatal_err ( "Failed to create the cluster-to-database thread", __FILE__, __LINE__ ); */ - /* } */ - - /* if ( pthread_join ( db_thread, NULL ) != 0 ) */ - /* { */ - /* AI_fatal_err ( "Could not join the cluster-to-database thread", __FILE__, __LINE__ ); */ - /* } */ } /* Merge the two alerts */ diff --git a/correlation.c b/correlation.c index 7b72097..5f4dc6a 100644 --- a/correlation.c +++ b/correlation.c @@ -1469,16 +1469,6 @@ AI_alert_correlation_thread ( void *arg ) if ( config->outdbtype != outdb_none ) { AI_store_correlation_to_db ( corr ); - - /* if ( pthread_create ( &db_thread, NULL, AI_store_correlation_to_db_thread, corr ) != 0 ) */ - /* { */ - /* AI_fatal_err ( "Failed to create the correlation-to-database storing thread", __FILE__, __LINE__ ); */ - /* } */ - - /* if ( pthread_join ( db_thread, NULL ) != 0 ) */ - /* { */ - /* AI_fatal_err ( "Failed to join the correlation-to-database storing thread", __FILE__, __LINE__ ); */ - /* } */ } } } diff --git a/db.c b/db.c index b1b809f..4782641 100644 --- a/db.c +++ b/db.c @@ -239,7 +239,7 @@ AI_db_alertparser_thread ( void *arg ) DB_free_result ( res ); latest_time = time ( NULL ); - AI_serializer_thread ((void*) alert); + AI_serializer ( alert ); } DB_close(); diff --git a/spp_ai.h b/spp_ai.h index 6c8ee86..8384115 100644 --- a/spp_ai.h +++ b/spp_ai.h @@ -540,9 +540,9 @@ AI_snort_alert* AI_get_alerts ( void ); AI_snort_alert* AI_get_clustered_alerts ( void ); void AI_serialize_alerts ( AI_snort_alert**, unsigned int ); +void AI_serializer ( AI_snort_alert* ); void* AI_deserialize_alerts (); void* AI_alerts_pool_thread ( void* ); -void* AI_serializer_thread ( void* ); void* AI_neural_thread ( void* ); const AI_alert_event* AI_get_alert_events_by_key ( AI_alert_event_key ); unsigned int AI_get_history_alert_number ();