Fixing some old threading stuff

This commit is contained in:
BlackLight 2010-11-23 18:51:46 +01:00
parent 1cf36baadf
commit dbba991c47
5 changed files with 9 additions and 55 deletions

View file

@ -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 );

View file

@ -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 */

View file

@ -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__ ); */
/* } */
}
}
}

2
db.c
View file

@ -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();

View file

@ -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 ();