* Fixes FS#434 reported from Maxim, incorrect mysql API usage for mysql_next_result(..)
* According MySQL doc, return values for mysql_next_result(..) can be the following:
0 - Successful and there are more results
-1 - Successful and there are no more results
>0 - An error occured
* Thus, if there will be an error when reading a next result, the code will be infinitely
looped in “while” cycle and current process will eat 100% CPU (The mysql_more_results
will not help here because it just checks a local flag that will be set to TRUE in cases
when there will be more than one result).
* The solution is to replace " > 0” with " == 0”:
... | ... |
@@ -258,7 +258,7 @@ static int db_mysql_store_result(const db1_con_t* _h, db1_res_t** _r) |
258 | 258 |
db_mysql_free_result(_h, *_r); |
259 | 259 |
*_r = 0; |
260 | 260 |
#if (MYSQL_VERSION_ID >= 40100) |
261 |
- while( mysql_more_results(CON_CONNECTION(_h)) && mysql_next_result(CON_CONNECTION(_h)) > 0 ) { |
|
261 |
+ while( mysql_more_results(CON_CONNECTION(_h)) && mysql_next_result(CON_CONNECTION(_h)) == 0 ) { |
|
262 | 262 |
MYSQL_RES *res = mysql_store_result( CON_CONNECTION(_h) ); |
263 | 263 |
mysql_free_result(res); |
264 | 264 |
} |
... | ... |
@@ -268,7 +268,7 @@ static int db_mysql_store_result(const db1_con_t* _h, db1_res_t** _r) |
268 | 268 |
|
269 | 269 |
done: |
270 | 270 |
#if (MYSQL_VERSION_ID >= 40100) |
271 |
- while( mysql_more_results(CON_CONNECTION(_h)) && mysql_next_result(CON_CONNECTION(_h)) > 0 ) { |
|
271 |
+ while( mysql_more_results(CON_CONNECTION(_h)) && mysql_next_result(CON_CONNECTION(_h)) == 0 ) { |
|
272 | 272 |
MYSQL_RES *res = mysql_store_result( CON_CONNECTION(_h) ); |
273 | 273 |
mysql_free_result(res); |
274 | 274 |
} |