Skip to content

Commit 776d820

Browse files
committed
Merge branch 'gh-98-segfault' into php7-v2
Closes gh-98. Removes debug output.
2 parents 5b7029c + 80a7011 commit 776d820

File tree

4 files changed

+37
-9
lines changed

4 files changed

+37
-9
lines changed

src/tarantool.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ void pack_key(zval *args, char select, zval *arr) {
584584
array_init(arr);
585585
return;
586586
}
587+
Z_TRY_ADDREF_P(args);
587588
array_init(arr);
588589
add_next_index_zval(arr, args);
589590
}
@@ -659,7 +660,7 @@ int get_spaceno_by_name(tarantool_connection *obj, zval *name) {
659660
}
660661

661662
if (tarantool_schema_add_spaces(obj->schema, resp.data, resp.data_len)) {
662-
fprintf(stderr, "%s", php_base64_encode(resp.data, resp.data_len)->val);
663+
// fprintf(stderr, "%s", php_base64_encode(resp.data, resp.data_len)->val);
663664
tarantool_throw_parsingexception("schema (space)");
664665
return FAILURE;
665666
}
@@ -719,7 +720,7 @@ int get_indexno_by_name(tarantool_connection *obj, int space_no,
719720
}
720721

721722
if (tarantool_schema_add_indexes(obj->schema, resp.data, resp.data_len)) {
722-
fprintf(stderr, "%s", php_base64_encode(resp.data, resp.data_len)->val);
723+
// fprintf(stderr, "%s", php_base64_encode(resp.data, resp.data_len)->val);
723724
tarantool_throw_parsingexception("schema (index)");
724725
return FAILURE;
725726
}
@@ -774,7 +775,7 @@ int get_fieldno_by_name(tarantool_connection *obj, uint32_t space_no,
774775
}
775776

776777
if (tarantool_schema_add_spaces(obj->schema, resp.data, resp.data_len)) {
777-
fprintf(stderr, "%s", php_base64_encode(resp.data, resp.data_len)->val);
778+
// fprintf(stderr, "%s", php_base64_encode(resp.data, resp.data_len)->val);
778779
tarantool_throw_parsingexception("schema (space)");
779780
return FAILURE;
780781
}
@@ -1220,15 +1221,15 @@ int __tarantool_authenticate(tarantool_connection *obj) {
12201221
if (tarantool_schema_add_spaces(obj->schema, resp.data,
12211222
resp.data_len) &&
12221223
status != FAILURE) {
1223-
fprintf(stderr, "%s", php_base64_encode(resp.data, resp.data_len)->val);
1224+
// fprintf(stderr, "%s", php_base64_encode(resp.data, resp.data_len)->val);
12241225
tarantool_throw_parsingexception("schema (space)");
12251226
status = FAILURE;
12261227
}
12271228
} else if (resp.sync == index_sync) {
12281229
if (tarantool_schema_add_indexes(obj->schema, resp.data,
12291230
resp.data_len) &&
12301231
status != FAILURE) {
1231-
fprintf(stderr, "%s", php_base64_encode(resp.data, resp.data_len)->val);
1232+
// fprintf(stderr, "%s", php_base64_encode(resp.data, resp.data_len)->val);
12321233
tarantool_throw_parsingexception("schema (index)");
12331234
status = FAILURE;
12341235
}
@@ -1499,13 +1500,13 @@ PHP_METHOD(Tarantool, update) {
14991500
size_t before_len = SSTR_LEN(obj->value);
15001501
char *sz = php_tp_encode_update(obj->value, sync, space_no,
15011502
index_no, &key_new);
1503+
zval_ptr_dtor(&key_new);
15021504
if (tarantool_uwrite_ops(obj, args, space_no) == -1) {
15031505
/* rollback all written changes */
15041506
SSTR_LEN(obj->value) = before_len;
15051507
RETURN_FALSE;
15061508
}
15071509
php_tp_reencode_length(obj->value, sz);
1508-
zval_ptr_dtor(&key_new);
15091510
if (tarantool_stream_send(obj) == FAILURE)
15101511
RETURN_FALSE;
15111512

src/tarantool_internal.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33

44
#define TNT_INIT_CLASS_ENTRY(ce, name, name_ns, methods) \
55
if (TARANTOOL_G(use_namespace)) { \
6-
printf("%s", name_ns); \
76
INIT_CLASS_ENTRY(ce, name_ns, methods); \
87
} else { \
9-
printf("%s", name); \
108
INIT_CLASS_ENTRY(ce, name, methods); \
119
}
1210

test/DMLTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,4 +438,28 @@ public static function provideIteratorGood() {
438438
['test_hash', 'gt' ],
439439
];
440440
}
441+
442+
public function test_18_01_delete_loop() {
443+
for ($i = 0; $i <= 1000; $i++) {
444+
self::$tarantool->replace("pstring", array("test2" . $i, $i));
445+
self::$tarantool->select ("pstring", array("test2" . $i));
446+
self::$tarantool->delete ("pstring", array("test2" . $i));
447+
}
448+
gc_collect_cycles();
449+
gc_collect_cycles();
450+
gc_collect_cycles();
451+
gc_collect_cycles();
452+
}
453+
454+
public function test_18_02_delete_loop() {
455+
for ($i = 0; $i <= 1000; $i++) {
456+
self::$tarantool->replace("pstring", array("test2" . $i, $i));
457+
self::$tarantool->select ("pstring", "test2" . $i);
458+
self::$tarantool->delete ("pstring", "test2" . $i);
459+
}
460+
gc_collect_cycles();
461+
gc_collect_cycles();
462+
gc_collect_cycles();
463+
gc_collect_cycles();
464+
}
441465
}

test/shared/box.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@ box.once('initialization', function()
6666
})
6767
test_hash:insert{1, 'hash-loc'}
6868
test_hash:insert{2, 'hash-col'}
69-
test_hash:insert{3, 'hash-olc'}
69+
test_hash:insert{3, 'hash-olc'}
70+
71+
local space = box.schema.space.create('pstring')
72+
space:create_index('primary', {
73+
parts = {1, 'STR'}
74+
})
7075
end)
7176

7277
function test_1()

0 commit comments

Comments
 (0)