Permalink
Browse files

Merge branch 'pre-stable' of git://github.com/binf/barnyard2 into pre…

…-stable
  • Loading branch information...
2 parents 0a2ff88 + eb3b1b9 commit 64956e02023862b7cc0e93fd3564ee638a1141ef @binf binf committed May 31, 2012
Showing with 63 additions and 71 deletions.
  1. +46 −60 src/output-plugins/spo_database.c
  2. +7 −2 src/output-plugins/spo_sguil.c
  3. +10 −9 src/plugbase.c
@@ -4639,44 +4639,42 @@ u_int32_t dbConnectionStatusMYSQL(dbReliabilityHandle *pdbRH)
we need to check if we are in a transaction
and if we are we bail, since the resulting issued commands would obviously fail
*/
+ if( dbReconnectSetCounters(pdbRH))
+ {
+ /* XXX */
+ FatalError("database [%s()]: Call failed, the process will need to be restarted \n",__FUNCTION__);
+ }
+
if(checkTransactionState(pdbRH))
{
- /* Calling rollback if we reconnected will bring us in a dead loop */
- //if( RollbackTransaction(pdbRH->dbdata))
- //{
- //FatalError("[%s()]: Failed in a transaction, the process need to be restarted \n",
- // __FUNCTION__);
- //}
-
/* ResetState for the caller */
setReconnectState(pdbRH,1);
setTransactionCallFail(pdbRH);
setTransactionState(pdbRH);
}
- else
+
+ pdbRH->pThreadID = aThreadID;
+
+ /* make sure are are off auto_commit */
+ if(mysql_autocommit(pdbRH->dbdata->m_sock,0))
{
- pdbRH->pThreadID = aThreadID;
-
- /* make sure are are off auto_commit */
- if(mysql_autocommit(pdbRH->dbdata->m_sock,0))
- {
- /* XXX */
- LogMessage("database Can't set autocommit off \n");
- return 1;
- }
-
- /* make shure we keep the option on ..*/
- if (mysql_options(dbdata->m_sock,
- MYSQL_OPT_RECONNECT,
- &pdbRH->mysql_reconnect) != 0)
- {
- LogMessage("database: Failed to set reconnect option: %s\n", mysql_error(dbdata->m_sock));
- return 1;
- }
-
- LogMessage("Warning: {MYSQL} The database connection has reconnected it self to the database server, via a call to mysql_ping() new thread id is [%u] \n",
- pdbRH->pThreadID);
+ /* XXX */
+ LogMessage("database Can't set autocommit off \n");
+ return 1;
+ }
+
+ /* make shure we keep the option on ..*/
+ if (mysql_options(dbdata->m_sock,
+ MYSQL_OPT_RECONNECT,
+ &pdbRH->mysql_reconnect) != 0)
+ {
+ LogMessage("database: Failed to set reconnect option: %s\n", mysql_error(dbdata->m_sock));
+ return 1;
}
+
+ LogMessage("Warning: {MYSQL} The database connection has reconnected it self to the database server, via a call to mysql_ping() new thread id is [%u] \n",
+ pdbRH->pThreadID);
+ return 0;
}
else
{
@@ -4704,16 +4702,23 @@ u_int32_t dbConnectionStatusMYSQL(dbReliabilityHandle *pdbRH)
LogMessage("database: Failed to set reconnect option: %s\n", mysql_error(dbdata->m_sock));
return 1;
}
+ return 0;
}
- return 0;
-
break;
case CR_COMMANDS_OUT_OF_SYNC:
case CR_SERVER_GONE_ERROR:
case CR_UNKNOWN_ERROR:
default:
+ if(checkTransactionState(pdbRH))
+ {
+ /* ResetState for the caller */
+ setReconnectState(pdbRH,1);
+ setTransactionCallFail(pdbRH);
+ setTransactionState(pdbRH);
+ }
+
if( dbReconnectSetCounters(pdbRH))
{
/* XXX */
@@ -4727,7 +4732,6 @@ u_int32_t dbConnectionStatusMYSQL(dbReliabilityHandle *pdbRH)
}
else /* Manual Reconnect mode */
{
-
switch(ping_ret)
{
@@ -4736,53 +4740,35 @@ u_int32_t dbConnectionStatusMYSQL(dbReliabilityHandle *pdbRH)
{
FatalError("database We are in {MYSQL} \"manual reconnect\" mode and a call to mysql_ping() changed the mysql_thread_id, this shouldn't happen the process will terminate \n");
}
-
return 0;
break;
-
+
case CR_COMMANDS_OUT_OF_SYNC:
case CR_SERVER_GONE_ERROR:
case CR_UNKNOWN_ERROR:
default:
if(checkTransactionState(pdbRH))
{
- if(dbReconnectSetCounters(pdbRH))
- {
- /* XXX */
- FatalError("database [%s()]: Call failed, the process will need to be restarted \n",__FUNCTION__);
- }
-
- if((MYSQL_ManualConnect(pdbRH->dbdata)))
- {
- goto MYSQL_RetryConnection;
- }
-
/* ResetState for the caller */
setReconnectState(pdbRH,1);
setTransactionCallFail(pdbRH);
setTransactionState(pdbRH);
}
- else
+
+ if(dbReconnectSetCounters(pdbRH))
{
- if(dbReconnectSetCounters(pdbRH))
- {
- /* XXX */
- FatalError("database [%s()]: Call failed, the process will need to be restarted \n",__FUNCTION__);
- }
+ /* XXX */
+ FatalError("database [%s()]: Call failed, the process will need to be restarted \n",__FUNCTION__);
+ }
- if((MYSQL_ManualConnect(pdbRH->dbdata)))
- {
- goto MYSQL_RetryConnection;
- }
- else
- {
- return 0;
- }
- break;
+ if((MYSQL_ManualConnect(pdbRH->dbdata)))
+ {
+ goto MYSQL_RetryConnection;
}
}
+ return 0;
}
/* XXX */
@@ -237,9 +237,14 @@ void Sguil(Packet *p, void *event, uint32_t event_type, void *arg)
return;
}
- if ( (p != NULL) && (p->ip6h != NULL) )
+ if(p != NULL)
{
- return;
+ if((p->ip6h != NULL)
+ {
+ LogMessage("[%s] Received a IPv6 Packets, ignoring \n",
+ __FUNCTION__);
+ return;
+ }
}
data = (SpoSguilData *)arg;
View
@@ -569,23 +569,24 @@ void CallOutputPlugins(OutputType out_type, Packet *packet, void *event, uint32_
}
else
{
- switch(out_type)
+ //All those sub "Log" type will go away in the future..
+ //Iterate Log and Alert.
+ idx = LogList;
+
+ while (idx != NULL)
{
- case OUTPUT_TYPE__ALERT:
- idx = AlertList;
- break;
- case OUTPUT_TYPE__LOG:
- idx = LogList;
- break;
- default:
- break;
+ idx->func(packet, event, event_type, idx->arg);
+ idx = idx->next;
}
+
+ idx = AlertList;
while (idx != NULL)
{
idx->func(packet, event, event_type, idx->arg);
idx = idx->next;
}
+
}
}

0 comments on commit 64956e0

Please sign in to comment.