@@ -51,13 +51,22 @@ static const char *str_state( int state ) {
5151 }
5252}
5353
54- // External access to all current results
55- struct search_t * * searches_get ( void ) {
56- return & g_searches [0 ];
54+ struct search_t * searches_find_by_id ( const uint8_t id [] ) {
55+ struct search_t * * searches ;
56+
57+ searches = & g_searches [0 ];
58+ while ( * searches ) {
59+ if ( memcmp ( (* searches )-> id , id , SHA1_BIN_LENGTH ) == 0 ) {
60+ return * searches ;
61+ }
62+ searches ++ ;
63+ }
64+
65+ return NULL ;
5766}
5867
59- // Find a value search result
60- static struct search_t * searches_find ( const char query [] ) {
68+
69+ static struct search_t * searches_find_by_query ( const char query [] ) {
6170 struct search_t * * search ;
6271 struct search_t * searches ;
6372
@@ -108,7 +117,7 @@ static struct result_t *find_next_result( struct search_t *search ) {
108117static struct search_t * find_next_search ( auth_callback * callback ) {
109118 struct search_t * * searches ;
110119
111- searches = searches_get () ;
120+ searches = & g_searches [ 0 ] ;
112121 while ( * searches ) {
113122 if ( !(* searches )-> done && (* searches )-> callback == callback ) {
114123 return * searches ;
@@ -147,7 +156,7 @@ void searches_set_auth_state( const char query[], const IP *addr, const int stat
147156
148157 log_debug ( "SRC: Set authentication state for %s: %s" , query , str_state ( state ) );
149158
150- search = searches_find ( query );
159+ search = searches_find_by_query ( query );
151160
152161 if ( search ) {
153162 // Search and set authentication state of result
@@ -253,7 +262,7 @@ struct search_t* searches_start( const char query[] ) {
253262 struct search_t * new ;
254263
255264 // Find existing search
256- if ( (search = searches_find ( query )) != NULL ) {
265+ if ( (search = searches_find_by_query ( query )) != NULL ) {
257266 // Restart search after half of search lifetime
258267 if ( (time_now_sec () - search -> start_time ) > (MAX_SEARCH_LIFETIME / 2 ) ) {
259268 search_restart ( search );
0 commit comments