@@ -111,16 +111,16 @@ PHP_INI_BEGIN()
111111 STD_PHP_INI_BOOLEAN ("tarantool.connection_alias" , "0" , PHP_INI_SYSTEM ,
112112 OnUpdateBool , connection_alias ,
113113 zend_tarantool_globals , tarantool_globals )
114- STD_PHP_INI_ENTRY ("tarantool.timeout" , "10 .0" , PHP_INI_ALL ,
114+ STD_PHP_INI_ENTRY ("tarantool.timeout" , "3600 .0" , PHP_INI_ALL ,
115115 OnUpdateReal , timeout , zend_tarantool_globals ,
116116 tarantool_globals )
117- STD_PHP_INI_ENTRY ("tarantool.request_timeout" , "10 .0" , PHP_INI_ALL ,
117+ STD_PHP_INI_ENTRY ("tarantool.request_timeout" , "3600 .0" , PHP_INI_ALL ,
118118 OnUpdateReal , request_timeout , zend_tarantool_globals ,
119119 tarantool_globals )
120120 STD_PHP_INI_ENTRY ("tarantool.retry_count" , "1" , PHP_INI_ALL ,
121121 OnUpdateLong , retry_count , zend_tarantool_globals ,
122122 tarantool_globals )
123- STD_PHP_INI_ENTRY ("tarantool.retry_sleep" , "0.1 " , PHP_INI_ALL ,
123+ STD_PHP_INI_ENTRY ("tarantool.retry_sleep" , "10 " , PHP_INI_ALL ,
124124 OnUpdateReal , retry_sleep , zend_tarantool_globals ,
125125 tarantool_globals )
126126PHP_INI_END ()
@@ -223,19 +223,23 @@ static zend_string *pid_pzsgen(const char *host, int port, const char *login,
223223inline static int
224224tarantool_stream_read (tarantool_connection * obj , char * buf , size_t size ) {
225225 size_t got = tntll_stream_read2 (obj -> stream , buf , size );
226+ const char * suffix = "" ;
227+ if (got == 0 && tntll_stream_is_timedout ())
228+ suffix = " (request timeout reached)" ;
229+ char errno_suffix [256 ] = {0 };
226230 if (got != size ) {
231+ tarantool_throw_ioexception ("Failed to read %ld bytes %s" ,
232+ size , suffix );
227233 tarantool_stream_close (obj );
228- tarantool_throw_ioexception ("Failed to read %ld bytes" , size );
229234 return FAILURE ;
230235 }
231236 return SUCCESS ;
232237}
233238
234239static void
235240tarantool_stream_close (tarantool_connection * obj ) {
236- if (obj -> stream || obj -> persistent_id ) {
241+ if (obj -> stream || obj -> persistent_id )
237242 tntll_stream_close (obj -> stream , obj -> persistent_id );
238- }
239243 obj -> stream = NULL ;
240244 if (obj -> persistent_id != NULL ) {
241245 zend_string_release (obj -> persistent_id );
@@ -281,11 +285,9 @@ static int __tarantool_connect(tarantool_object *t_obj) {
281285 obj -> suffix_len );
282286
283287 }
284- if (tntll_stream_open (obj -> host , obj -> port ,
285- obj -> persistent_id ,
286- & obj -> stream , & err ) == -1 ) {
288+ if (tntll_stream_open (obj -> host , obj -> port , obj -> persistent_id ,
289+ & obj -> stream , & err ) == -1 )
287290 continue ;
288- }
289291 if (tntll_stream_read2 (obj -> stream , obj -> greeting ,
290292 GREETING_SIZE ) != GREETING_SIZE ) {
291293 continue ;
@@ -299,6 +301,7 @@ static int __tarantool_connect(tarantool_object *t_obj) {
299301 }
300302 if (count == 0 ) {
301303ioexception :
304+ // raise (SIGABRT);
302305 tarantool_throw_ioexception ("%s" , err );
303306 efree (err );
304307 return FAILURE ;
@@ -401,34 +404,48 @@ static int tarantool_step_recv(
401404 zval * body ) {
402405 char pack_len [5 ] = {0 , 0 , 0 , 0 , 0 };
403406 if (tarantool_stream_read (obj , pack_len , 5 ) == FAILURE ) {
404- goto error ;
407+ header = NULL ;
408+ body = NULL ;
409+ goto error_con ;
405410 }
406411 if (php_mp_check (pack_len , 5 )) {
412+ header = NULL ;
413+ body = NULL ;
407414 tarantool_throw_parsingexception ("package length" );
408415 goto error_con ;
409416 }
410417 size_t body_size = php_mp_unpack_package_size (pack_len );
411418 smart_string_ensure (obj -> value , body_size );
412419 if (tarantool_stream_read (obj , SSTR_POS (obj -> value ),
413420 body_size ) == FAILURE ) {
414- goto error ;
421+ header = NULL ;
422+ body = NULL ;
423+ goto error_con ;
415424 }
416425 SSTR_LEN (obj -> value ) += body_size ;
417426
418427 char * pos = SSTR_BEG (obj -> value );
419428 if (php_mp_check (pos , body_size )) {
429+ header = NULL ;
430+ body = NULL ;
420431 tarantool_throw_parsingexception ("package header" );
421432 goto error_con ;
422433 }
423434 if (php_mp_unpack (header , & pos ) == FAILURE ||
424435 Z_TYPE_P (header ) != IS_ARRAY ) {
436+ header = NULL ;
437+ body = NULL ;
425438 goto error_con ;
426439 }
427440 if (php_mp_check (pos , body_size )) {
441+ header = NULL ;
442+ body = NULL ;
428443 tarantool_throw_parsingexception ("package body" );
429444 goto error_con ;
430445 }
431446 if (php_mp_unpack (body , & pos ) == FAILURE ) {
447+ header = NULL ;
448+ body = NULL ;
432449 goto error_con ;
433450 }
434451
@@ -466,7 +483,7 @@ static int tarantool_step_recv(
466483 "Bad error field type. Expected"
467484 " STRING, got %s" ,
468485 tutils_op_to_string (z_error_str ));
469- goto error ;
486+ goto error_con ;
470487 }
471488 } else {
472489 error_str = "empty" ;
@@ -941,9 +958,9 @@ PHP_RINIT_FUNCTION(tarantool) {
941958static void php_tarantool_init_globals (zend_tarantool_globals * tarantool_globals ) {
942959 tarantool_globals -> sync_counter = 0 ;
943960 tarantool_globals -> retry_count = 1 ;
944- tarantool_globals -> retry_sleep = 0.1 ;
945- tarantool_globals -> timeout = 1 .0 ;
946- tarantool_globals -> request_timeout = 10 .0 ;
961+ tarantool_globals -> retry_sleep = 10 ;
962+ tarantool_globals -> timeout = 3600 .0 ;
963+ tarantool_globals -> request_timeout = 3600 .0 ;
947964}
948965
949966static void tarantool_destructor_connection (zend_resource * rsrc TSRMLS_DC ) {
0 commit comments