Permalink
Browse files

fixed #36 (searchd crashes on startup when invalid agents are specified)

  • Loading branch information...
glookka authored and klirichek committed Jun 6, 2017
1 parent 4ca6350 commit 11e62547ad31c4bd0acf08385edb2bd6924b89a6
Showing with 25 additions and 0 deletions.
  1. +17 −0 src/searchdha.cpp
  2. +1 −0 src/searchdha.h
  3. +7 −0 test/test_173/test.xml
@@ -266,6 +266,13 @@ AgentDesc_c * MultiAgentDesc_t::NewAgent()
return & tAgent;
}
void MultiAgentDesc_t::RemoveLastAgent()
{
int iLast = m_dHosts.GetLength()-1;
assert ( !m_dHosts[iLast].m_pDash && !m_dHosts[iLast].m_pStats );
m_dHosts.Remove ( iLast );
}
AgentDesc_c * MultiAgentDesc_t::RRAgent ()
{
if ( !IsHA() )
@@ -1053,7 +1060,11 @@ bool ConfigureAgent ( MultiAgentDesc_t & tAgent, const char * szAgent, const cha
{
eState = ( *p=='|' ? AP_WANT_ADDRESS : AP_OPTIONS );
if ( !ValidateAndAddDashboard ( pNewAgent, &dWI ) )
{
tAgent.RemoveLastAgent();
return false;
}
pNewAgent = tAgent.NewAgent();
++p;
break;
@@ -1090,7 +1101,11 @@ bool ConfigureAgent ( MultiAgentDesc_t & tAgent, const char * szAgent, const cha
++p;
eState = AP_WANT_ADDRESS;
if ( !ValidateAndAddDashboard ( pNewAgent, &dWI ) )
{
tAgent.RemoveLastAgent();
return false;
}
pNewAgent = tAgent.NewAgent();
} else
eState = AP_OPTIONS;
@@ -1178,6 +1193,8 @@ bool ConfigureAgent ( MultiAgentDesc_t & tAgent, const char * szAgent, const cha
}
bool bRes = ValidateAndAddDashboard ( pNewAgent, &dWI );
if ( !bRes )
tAgent.RemoveLastAgent();
FixupOrphanedAgents ( tAgent );
tAgent.SetOptions ( tDesc );
@@ -352,6 +352,7 @@ struct MultiAgentDesc_t
MultiAgentDesc_t & operator= ( MultiAgentDesc_t && rhs ) EXCLUDES ( m_dWeightLock );
AgentDesc_c * NewAgent ();
void RemoveLastAgent();
AgentDesc_c * GetAgent ( int iAgent=0 );
const AgentDesc_c & ChooseAgent ();
@@ -83,6 +83,13 @@ index warn3
min_infix_len = 5
}
<!-- regression for a crash when adding several invalid agents -->
index dist_crash
{
type = distributed
agent = unknown:test0
agent = unknown:8312:test0
}
</config>
<sphqueries>

0 comments on commit 11e6254

Please sign in to comment.