Skip to content

Commit

Permalink
fixed missing request cleanup in sphinx_query() (eg after network err…
Browse files Browse the repository at this point in the history
…ors)

git-svn-id: http://sphinxsearch.googlecode.com/svn/trunk@2480 8b96e2b9-35c5-2c16-bc47-5122d61876d4
  • Loading branch information
shodan committed Sep 13, 2010
1 parent 23a7785 commit 2740d88
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions api/libsphinxclient/sphinxclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,16 @@ void sphinx_reset_groupby ( sphinx_client * client )

//////////////////////////////////////////////////////////////////////////

static int sphinx_dismiss_requests ( sphinx_client * client )
{
int nreqs = client->num_reqs, i;
for ( i=0; i<client->num_reqs; i++ )
free ( client->reqs[i] );
client->num_reqs = 0;
return nreqs;
}


sphinx_result * sphinx_query ( sphinx_client * client, const char * query, const char * index_list, const char * comment )
{
sphinx_result * res;
Expand All @@ -916,6 +926,7 @@ sphinx_result * sphinx_query ( sphinx_client * client, const char * query, const
return NULL;

res = sphinx_run_queries ( client ); // just a shortcut for client->results[0]
sphinx_dismiss_requests ( client ); // sphinx_query() is fire and forget; dismiss request in all cases
if ( !res )
return NULL;

Expand Down Expand Up @@ -1681,12 +1692,8 @@ sphinx_result * sphinx_run_queries ( sphinx_client * client )
if ( !client->response_buf )
return NULL;

// dismiss requests
nreqs = client->num_reqs;

for ( i=0; i<client->num_reqs; i++ )
free ( client->reqs[i] );
client->num_reqs = 0;
// dismiss request data, memorize count
nreqs = sphinx_dismiss_requests ( client );

// parse response
p = client->response_start;
Expand Down

0 comments on commit 2740d88

Please sign in to comment.