Skip to content

Commit 1a627c3

Browse files
committed
No more assertion on 0 retries options
closes tarantoolgh-83
1 parent 21f638b commit 1a627c3

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Place it into project library path in your IDE.
6767

6868
* `tarantool.persistent` - Enable persistent connections (don't close connections between sessions) (defaults: True, **can't be changed in runtime**)
6969
* `tarantool.timeout` - Connection timeout (defaults: 10 seconds, can be changed in runtime)
70-
* `tarantool.retry_count` - Count of retries for connecting (defaults: 1, can be changed in runtime)
70+
* `tarantool.retry_count` - Count of retries for connecting (defaults: 1, can be changed in runtime). 0 means do not retry in case the connection was failed the first time.
7171
* `tarantool.retry_sleep` - Sleep between connecting retries (defaults: 0.1 second, can be changed in runtime)
7272
* `tarantool.request_timeout` - Read/write timeout for requests (defaults: 10 second, can be changed in runtime)
7373

src/tarantool.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ PHP_INI_BEGIN()
117117
STD_PHP_INI_ENTRY("tarantool.request_timeout", "3600.0", PHP_INI_ALL,
118118
OnUpdateReal, request_timeout, zend_tarantool_globals,
119119
tarantool_globals)
120-
STD_PHP_INI_ENTRY("tarantool.retry_count", "1", PHP_INI_ALL,
120+
STD_PHP_INI_ENTRY("tarantool.retry_count", "0", PHP_INI_ALL,
121121
OnUpdateLong, retry_count, zend_tarantool_globals,
122122
tarantool_globals)
123123
STD_PHP_INI_ENTRY("tarantool.retry_sleep", "10", PHP_INI_ALL,
@@ -252,7 +252,9 @@ static int __tarantool_connect(tarantool_object *t_obj) {
252252
TSRMLS_FETCH();
253253
tarantool_connection *obj = t_obj->obj;
254254
int status = SUCCESS;
255-
long count = TARANTOOL_G(retry_count);
255+
/* retry_count always 1 more than count of tries, since retry count
256+
* is number of retries*/
257+
long count = TARANTOOL_G(retry_count) + 1;
256258
struct timespec sleep_time = {0};
257259
double_to_ts(INI_FLT("retry_sleep"), &sleep_time);
258260
char *err = NULL;

test/CreateTest.php

+9
Original file line numberDiff line numberDiff line change
@@ -163,5 +163,14 @@ public static function provideGoodCredentials()
163163
['guest', null],
164164
];
165165
}
166+
167+
public function test_10_zero_retry_exception() {
168+
$t = new Tarantool('localhost', self::$port);
169+
$rc = ini_get('tarantool.retry_count');
170+
171+
ini_set('tarantool.retry_count', 0);
172+
$this->assertEquals($t->ping(), true);
173+
ini_set('tarantool.retry_count', $rc);
174+
}
166175
}
167176

0 commit comments

Comments
 (0)