Skip to content

Commit

Permalink
No more assertion on 0 retries options
Browse files Browse the repository at this point in the history
closes gh-83
  • Loading branch information
MariaHajdic committed Jun 16, 2020
1 parent 21f638b commit 2c69e2e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/tarantool.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("tarantool.request_timeout", "3600.0", PHP_INI_ALL,
OnUpdateReal, request_timeout, zend_tarantool_globals,
tarantool_globals)
STD_PHP_INI_ENTRY("tarantool.retry_count", "1", PHP_INI_ALL,
STD_PHP_INI_ENTRY("tarantool.retry_count", "0", PHP_INI_ALL,
OnUpdateLong, retry_count, zend_tarantool_globals,
tarantool_globals)
STD_PHP_INI_ENTRY("tarantool.retry_sleep", "10", PHP_INI_ALL,
Expand Down Expand Up @@ -252,7 +252,9 @@ static int __tarantool_connect(tarantool_object *t_obj) {
TSRMLS_FETCH();
tarantool_connection *obj = t_obj->obj;
int status = SUCCESS;
long count = TARANTOOL_G(retry_count);
/* retry_count always 1 more than count of tries, since retry count
* is number of retries*/
long count = TARANTOOL_G(retry_count) + 1;
struct timespec sleep_time = {0};
double_to_ts(INI_FLT("retry_sleep"), &sleep_time);
char *err = NULL;
Expand Down
9 changes: 9 additions & 0 deletions test/CreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,14 @@ public static function provideGoodCredentials()
['guest', null],
];
}

public function test_10_zero_retry_exception() {
$t = new Tarantool('localhost', self::$port);
$rc = ini_get('tarantool.retry_count');

ini_set('tarantool.retry_count', 0);
$this->assertEquals($t->ping(), true);
ini_set('tarantool.retry_count', $rc);
}
}

0 comments on commit 2c69e2e

Please sign in to comment.