$OpenBSD: patch-src_searchd_cpp,v 1.1 2018/04/10 22:04:52 sthen Exp $

Index: src/searchd.cpp
--- src/searchd.cpp.orig
+++ src/searchd.cpp
@@ -3927,7 +3927,7 @@ struct MetaAgentDesc_t (public)
 		// only one node with lowest error rating. Return it.
 		if ( !dCandidates.GetLength() )
 		{
-			sphLogDebug ( "HA selected %d node with best num of errors a row ("INT64_FMT")", iBestAgent, iErrARow );
+			sphLogDebug ( "HA selected %d node with best num of errors a row (" INT64_FMT ")", iBestAgent, iErrARow );
 			return &m_dAgents[iBestAgent];
 		}
 
@@ -3940,7 +3940,7 @@ struct MetaAgentDesc_t (public)
 		{
 			const HostDashboard_t & dDash = GetCommonStat ( iBestAgent );
 			fAge = ( dDash.m_iLastAnswerTime-dDash.m_iLastQueryTime ) / 1000.0f;
-			sLogStr = "HA selected %d node by weighted random, with best EaR ("INT64_FMT"), last answered in %f milliseconds";
+			sLogStr = "HA selected %d node by weighted random, with best EaR (" INT64_FMT "), last answered in %f milliseconds";
 		}
 
 		sphLogDebug ( sLogStr, iBestAgent, iErrARow, fAge );
@@ -6935,7 +6935,7 @@ void LogQueryPlain ( const CSphQuery & tQuery, const C
 	// [matchmode/numfilters/sortmode matches (offset,limit)
 	static const char * sModes [ SPH_MATCH_TOTAL ] = { "all", "any", "phr", "bool", "ext", "scan", "ext2" };
 	static const char * sSort [ SPH_SORT_TOTAL ] = { "rel", "attr-", "attr+", "tsegs", "ext", "expr" };
-	tBuf.Appendf ( " [%s/%d/%s "INT64_FMT" (%d,%d)",
+	tBuf.Appendf ( " [%s/%d/%s " INT64_FMT " (%d,%d)",
 		sModes [ tQuery.m_eMode ], tQuery.m_dFilters.GetLength(), sSort [ tQuery.m_eSort ],
 		tRes.m_iTotalMatches, tQuery.m_iOffset, tQuery.m_iLimit );
 
@@ -7045,10 +7045,10 @@ static void LogQuerySphinxql ( const CSphQuery & q, co
 	tBuf += sTimeBuf;
 
 	if ( tRes.m_iMultiplier>1 )
-		tBuf.Appendf ( " conn %d real %d.%03d wall %d.%03d x%d found "INT64_FMT" *""/ ",
+		tBuf.Appendf ( " conn %d real %d.%03d wall %d.%03d x%d found " INT64_FMT " *""/ ",
 			iCid, iRealTime/1000, iRealTime%1000, iQueryTime/1000, iQueryTime%1000, tRes.m_iMultiplier, tRes.m_iTotalMatches );
 	else
-		tBuf.Appendf ( " conn %d real %d.%03d wall %d.%03d found "INT64_FMT" *""/ ",
+		tBuf.Appendf ( " conn %d real %d.%03d wall %d.%03d found " INT64_FMT " *""/ ",
 			iCid, iRealTime/1000, iRealTime%1000, iQueryTime/1000, iQueryTime%1000, tRes.m_iTotalMatches );
 
 	///////////////////////////////////
@@ -7089,9 +7089,9 @@ static void LogQuerySphinxql ( const CSphQuery & q, co
 					if ( f.m_dValues.GetLength()==1 )
 					{
 						if ( f.m_bExclude )
-							tBuf.Appendf ( " %s!="INT64_FMT, f.m_sAttrName.cstr(), (int64_t)f.m_dValues[0] );
+							tBuf.Appendf ( " %s!=" INT64_FMT, f.m_sAttrName.cstr(), (int64_t)f.m_dValues[0] );
 						else
-							tBuf.Appendf ( " %s="INT64_FMT, f.m_sAttrName.cstr(), (int64_t)f.m_dValues[0] );
+							tBuf.Appendf ( " %s=" INT64_FMT, f.m_sAttrName.cstr(), (int64_t)f.m_dValues[0] );
 					} else
 					{
 						if ( f.m_bExclude )
@@ -7106,7 +7106,7 @@ static void LogQuerySphinxql ( const CSphQuery & q, co
 							for ( int j=0; j<iLimit; ++j )
 							{
 								if ( j )
-									tBuf.Appendf ( ","INT64_FMT, (int64_t)f.m_dValues[j] );
+									tBuf.Appendf ( "," INT64_FMT, (int64_t)f.m_dValues[j] );
 								else
 									tBuf.Appendf ( INT64_FMT, (int64_t)f.m_dValues[j] );
 							}
@@ -7115,7 +7115,7 @@ static void LogQuerySphinxql ( const CSphQuery & q, co
 							for ( int j=iLimit-3; j<iLimit; ++j )
 							{
 								if ( j )
-									tBuf.Appendf ( ","INT64_FMT, (int64_t)f.m_dValues[j] );
+									tBuf.Appendf ( "," INT64_FMT, (int64_t)f.m_dValues[j] );
 								else
 									tBuf.Appendf ( INT64_FMT, (int64_t)f.m_dValues[j] );
 							}
@@ -7124,7 +7124,7 @@ static void LogQuerySphinxql ( const CSphQuery & q, co
 							ARRAY_FOREACH ( j, f.m_dValues )
 							{
 								if ( j )
-									tBuf.Appendf ( ","INT64_FMT, (int64_t)f.m_dValues[j] );
+									tBuf.Appendf ( "," INT64_FMT, (int64_t)f.m_dValues[j] );
 								else
 									tBuf.Appendf ( INT64_FMT, (int64_t)f.m_dValues[j] );
 							}
@@ -7137,17 +7137,17 @@ static void LogQuerySphinxql ( const CSphQuery & q, co
 					{
 						// no min, thus (attr<maxval)
 						const char * sOps[2][2] = { { "<", "<=" }, { ">=", ">" } };
-						tBuf.Appendf ( " %s%s"INT64_FMT, f.m_sAttrName.cstr(),
+						tBuf.Appendf ( " %s%s" INT64_FMT, f.m_sAttrName.cstr(),
 							sOps [ f.m_bExclude ][ f.m_bHasEqual ], f.m_iMaxValue );
 					} else if ( f.m_iMaxValue==INT64_MAX || ( f.m_iMaxValue==-1 && f.m_sAttrName=="@id" ) )
 					{
 						// mo max, thus (attr>minval)
 						const char * sOps[2][2] = { { ">", ">=" }, { "<", "<=" } };
-						tBuf.Appendf ( " %s%s"INT64_FMT, f.m_sAttrName.cstr(),
+						tBuf.Appendf ( " %s%s" INT64_FMT, f.m_sAttrName.cstr(),
 							sOps [ f.m_bExclude ][ f.m_bHasEqual ], f.m_iMinValue );
 					} else
 					{
-						tBuf.Appendf ( " %s%s BETWEEN "INT64_FMT" AND "INT64_FMT,
+						tBuf.Appendf ( " %s%s BETWEEN " INT64_FMT " AND " INT64_FMT,
 							f.m_sAttrName.cstr(), f.m_bExclude ? " NOT" : "",
 							f.m_iMinValue + !f.m_bHasEqual, f.m_iMaxValue - !f.m_bHasEqual );
 					}
@@ -14320,7 +14320,7 @@ void HandleClientSphinx ( int iSock, const char * sCli
 	DWORD uServer = htonl ( SPHINX_SEARCHD_PROTO );
 	if ( sphSockSend ( iSock, (char*)&uServer, sizeof(DWORD) )!=sizeof(DWORD) )
 	{
-		sphWarning ( "failed to send server version (client=%s("INT64_FMT"))", sClientIP, iCID );
+		sphWarning ( "failed to send server version (client=%s(" INT64_FMT "))", sClientIP, iCID );
 		return;
 	}
 
@@ -14328,10 +14328,10 @@ void HandleClientSphinx ( int iSock, const char * sCli
 	tBuf.ReadFrom ( 4 ); // FIXME! magic
 	int iMagic = tBuf.GetInt (); // client version is for now unused
 
-	sphLogDebugv ( "conn %s("INT64_FMT"): got handshake, major v.%d, err %d", sClientIP, iCID, iMagic, (int)tBuf.GetError() );
+	sphLogDebugv ( "conn %s(" INT64_FMT "): got handshake, major v.%d, err %d", sClientIP, iCID, iMagic, (int)tBuf.GetError() );
 	if ( tBuf.GetError() )
 	{
-		sphLogDebugv ( "conn %s("INT64_FMT"): exiting on handshake error", sClientIP, iCID );
+		sphLogDebugv ( "conn %s(" INT64_FMT "): exiting on handshake error", sClientIP, iCID );
 		return;
 	}
 
@@ -14350,14 +14350,14 @@ void HandleClientSphinx ( int iSock, const char * sCli
 		// on SIGTERM, bail unconditionally and immediately, at all times
 		if ( !bCommand && g_bGotSigterm )
 		{
-			sphLogDebugv ( "conn %s("INT64_FMT"): bailing on SIGTERM", sClientIP, iCID );
+			sphLogDebugv ( "conn %s(" INT64_FMT "): bailing on SIGTERM", sClientIP, iCID );
 			break;
 		}
 
 		// on SIGHUP vs pconn, bail if a pconn was idle for 1 sec
 		if ( bPersist && !bCommand && g_bGotSighup && sphSockPeekErrno()==ETIMEDOUT )
 		{
-			sphLogDebugv ( "conn %s("INT64_FMT"): bailing idle pconn on SIGHUP", sClientIP, iCID );
+			sphLogDebugv ( "conn %s(" INT64_FMT "): bailing idle pconn on SIGHUP", sClientIP, iCID );
 			break;
 		}
 
@@ -14367,7 +14367,7 @@ void HandleClientSphinx ( int iSock, const char * sCli
 			iPconnIdle += iTimeout;
 			if ( iPconnIdle>=g_iClientTimeout )
 			{
-				sphLogDebugv ( "conn %s("INT64_FMT"): bailing idle pconn on client_timeout", sClientIP, iCID );
+				sphLogDebugv ( "conn %s(" INT64_FMT "): bailing idle pconn on client_timeout", sClientIP, iCID );
 				break;
 			}
 			continue;
@@ -14391,7 +14391,7 @@ void HandleClientSphinx ( int iSock, const char * sCli
 			// lets avoid agent log flood
 			//
 			// sphWarning ( "failed to receive client version and request (client=%s, error=%s)", sClientIP, sphSockError() );
-			sphLogDebugv ( "conn %s("INT64_FMT"): bailing on failed request header (sockerr=%s)", sClientIP, iCID, sphSockError() );
+			sphLogDebugv ( "conn %s(" INT64_FMT "): bailing on failed request header (sockerr=%s)", sClientIP, iCID, sphSockError() );
 			if ( bPersist )
 				DecPersCount();
 			return;
@@ -14425,7 +14425,7 @@ void HandleClientSphinx ( int iSock, const char * sCli
 		assert ( iLength>=0 && iLength<=g_iMaxPacketSize );
 		if ( iLength && !tBuf.ReadFrom ( iLength ) )
 		{
-			sphWarning ( "failed to receive client request body (client=%s("INT64_FMT"), exp=%d, error='%s')",
+			sphWarning ( "failed to receive client request body (client=%s(" INT64_FMT "), exp=%d, error='%s')",
 				sClientIP, iCID, iLength, sphSockError() );
 
 			if ( bPersist )
@@ -14450,7 +14450,7 @@ void HandleClientSphinx ( int iSock, const char * sCli
 			pThd->m_sCommand = g_dApiCommands[iCommand];
 		THD_STATE ( THD_QUERY );
 
-		sphLogDebugv ( "conn %s("INT64_FMT"): got command %d, handling", sClientIP, iCID, iCommand );
+		sphLogDebugv ( "conn %s(" INT64_FMT "): got command %d, handling", sClientIP, iCID, iCommand );
 		switch ( iCommand )
 		{
 			case SEARCHD_COMMAND_SEARCH:	HandleCommandSearch ( iSock, iCommandVer, tBuf, pThd ); break;
@@ -14461,7 +14461,7 @@ void HandleClientSphinx ( int iSock, const char * sCli
 				{
 					bPersist = ( tBuf.GetInt()!=0 );
 					iTimeout = 1;
-					sphLogDebugv ( "conn %s("INT64_FMT"): pconn is now %s", sClientIP, iCID, bPersist ? "on" : "off" );
+					sphLogDebugv ( "conn %s(" INT64_FMT "): pconn is now %s", sClientIP, iCID, bPersist ? "on" : "off" );
 					CSphScopedLockedShare<InterWorkerStorage> dPersNum ( *g_pPersistentInUse );
 					DWORD uMaxChildren = (g_eWorkers==MPM_PREFORK)?g_iPreforkChildren:g_iMaxChildren;
 					DWORD& uPers = dPersNum.SharedValue<DWORD>();
@@ -14493,7 +14493,7 @@ void HandleClientSphinx ( int iSock, const char * sCli
 	if ( bPersist )
 		DecPersCount();
 
-	sphLogDebugv ( "conn %s("INT64_FMT"): exiting", sClientIP, iCID );
+	sphLogDebugv ( "conn %s(" INT64_FMT "): exiting", sClientIP, iCID );
 }
 
 //////////////////////////////////////////////////////////////////////////
@@ -18437,7 +18437,7 @@ static void HandleClientMySQL ( int iSock, const char 
 	if ( sphSockSend ( iSock, g_sMysqlHandshake, g_iMysqlHandshake )!=g_iMysqlHandshake )
 	{
 		int iErrno = sphSockGetErrno ();
-		sphWarning ( "failed to send server version (client=%s("INT64_FMT"), error: %d '%s')", sClientIP, iCID, iErrno, sphSockError ( iErrno ) );
+		sphWarning ( "failed to send server version (client=%s(" INT64_FMT "), error: %d '%s')", sClientIP, iCID, iErrno, sphSockError ( iErrno ) );
 		return;
 	}
 
@@ -18460,7 +18460,7 @@ static void HandleClientMySQL ( int iSock, const char 
 		THD_STATE ( THD_NET_IDLE );
 		if ( !tIn.ReadFrom ( 4, INTERACTIVE_TIMEOUT, true ) )
 		{
-			sphLogDebugv ( "conn %s("INT64_FMT"): bailing on failed MySQL header (sockerr=%s)", sClientIP, iCID, sphSockError() );
+			sphLogDebugv ( "conn %s(" INT64_FMT "): bailing on failed MySQL header (sockerr=%s)", sClientIP, iCID, sphSockError() );
 			break;
 		}
 
@@ -18480,7 +18480,7 @@ static void HandleClientMySQL ( int iSock, const char 
 		int iPacketLen = ( uPacketHeader & MAX_PACKET_LEN );
 		if ( !tIn.ReadFrom ( iPacketLen, INTERACTIVE_TIMEOUT, true ) )
 		{
-			sphWarning ( "failed to receive MySQL request body (client=%s("INT64_FMT"), exp=%d, error='%s')",
+			sphWarning ( "failed to receive MySQL request body (client=%s(" INT64_FMT "), exp=%d, error='%s')",
 				sClientIP, iCID, iPacketLen, sphSockError() );
 			break;
 		}
@@ -18500,7 +18500,7 @@ static void HandleClientMySQL ( int iSock, const char 
 			{
 				if ( !tIn2.ReadFrom ( 4, INTERACTIVE_TIMEOUT, true ) )
 				{
-					sphLogDebugv ( "conn %s("INT64_FMT"): bailing on failed MySQL header2 (sockerr=%s)",
+					sphLogDebugv ( "conn %s(" INT64_FMT "): bailing on failed MySQL header2 (sockerr=%s)",
 						sClientIP, iCID, sphSockError() );
 					break;
 				}
@@ -18510,7 +18510,7 @@ static void HandleClientMySQL ( int iSock, const char 
 				iAddonLen = ( uAddon & MAX_PACKET_LEN );
 				if ( !tIn.ReadFrom ( iAddonLen, INTERACTIVE_TIMEOUT, true, true ) )
 				{
-					sphWarning ( "failed to receive MySQL request body2 (client=%s("INT64_FMT"), exp=%d, error='%s')",
+					sphWarning ( "failed to receive MySQL request body2 (client=%s(" INT64_FMT "), exp=%d, error='%s')",
 						sClientIP, iCID, iAddonLen, sphSockError() );
 					iAddonLen = -1;
 					break;
@@ -19446,10 +19446,10 @@ static void SphinxqlStateThreadFunc ( void * )
 		ARRAY_FOREACH_COND ( i, dUservars, tmLast==g_tmSphinxqlState )
 		{
 			const CSphVector<SphAttr_t> & dVals = *dUservars[i].m_pVal;
-			int iLen = snprintf ( dBuf, sizeof ( dBuf ), "SET GLOBAL %s = ( "INT64_FMT, dUservars[i].m_sName.cstr(), dVals[0] );
+			int iLen = snprintf ( dBuf, sizeof ( dBuf ), "SET GLOBAL %s = ( " INT64_FMT, dUservars[i].m_sName.cstr(), dVals[0] );
 			for ( int j=1; j<dVals.GetLength(); j++ )
 			{
-				iLen += snprintf ( dBuf+iLen, sizeof ( dBuf ), ", "INT64_FMT, dVals[j] );
+				iLen += snprintf ( dBuf+iLen, sizeof ( dBuf ), ", " INT64_FMT, dVals[j] );
 
 				if ( iLen>=iMaxString && j<dVals.GetLength()-1 )
 				{
@@ -19966,7 +19966,7 @@ bool ValidateAgentDesc ( MetaAgentDesc_t & tAgent, con
 		g_tStatsMutex.Lock();
 		pAgent->m_iStatsIndex = g_pStats->m_dAgentStats.AllocItem();
 		if ( pAgent->m_iStatsIndex<0 )
-			sphWarning ( "index '%s': agent '%s': failed to allocate slot for stats",
+			sphWarning ( "index '%s': agent '%s': failed to allocate slot for stats%s",
 				szIndexName, pLine->cstr(), ( tAgent.IsHA() ? ", HA might be wrong" : "" ) );
 
 		if ( g_pStats->m_hDashBoard.Exists ( sHashKey ) )
@@ -19978,7 +19978,7 @@ bool ValidateAgentDesc ( MetaAgentDesc_t & tAgent, con
 			pAgent->m_iDashIndex = g_pStats->m_dDashboard.AllocItem();
 			if ( pAgent->m_iDashIndex<0 )
 			{
-				sphWarning ( "index '%s': agent '%s': failed to allocate slot for stat-dashboard",
+				sphWarning ( "index '%s': agent '%s': failed to allocate slot for stat-dashboard%s",
 				szIndexName, pLine->cstr(), ( tAgent.IsHA() ? ", HA might be wrong" : "" ) );
 			} else
 			{
