Skip to content

Commit

Permalink
Fix for broken upsert/update
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey Gadzhiev committed Apr 18, 2018
1 parent 2c8ed54 commit 7b7e01f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/tarantool.c
Original file line number Diff line number Diff line change
Expand Up @@ -1513,7 +1513,7 @@ PHP_METHOD(Tarantool, update) {
SSTR_LEN(obj->value) = before_len;
RETURN_FALSE;
}
php_tp_reencode_length(obj->value, sz);
php_tp_reencode_length(obj->value, before_len);
if (tarantool_stream_send(obj) == FAILURE)
RETURN_FALSE;

Expand Down Expand Up @@ -1543,7 +1543,7 @@ PHP_METHOD(Tarantool, upsert) {
SSTR_LEN(obj->value) = before_len;
RETURN_FALSE;
}
php_tp_reencode_length(obj->value, sz);
php_tp_reencode_length(obj->value, before_len);
if (tarantool_stream_send(obj) == FAILURE)
RETURN_FALSE;

Expand Down
5 changes: 3 additions & 2 deletions src/tarantool_proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,10 @@ void php_tp_encode_usplice(smart_string *str, uint32_t fieldno,
php_mp_pack_string(str, buffer, buffer_len);
}

void php_tp_reencode_length(smart_string *str, char *sz) {
ssize_t package_size = (SSTR_POS(str) - sz) - 5;
void php_tp_reencode_length(smart_string *str, size_t orig_len) {
ssize_t package_size = (SSTR_LEN(str) - orig_len) - 5;
assert(package_size > 0);
char *sz = SSTR_BEG(str) + orig_len;
php_mp_pack_package_size_basic(sz, package_size);
}

Expand Down
2 changes: 1 addition & 1 deletion src/tarantool_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void php_tp_encode_uother(smart_string *str, char type, uint32_t fieldno,
void php_tp_encode_usplice(smart_string *str, uint32_t fieldno,
uint32_t position, uint32_t offset,
const char *buffer, size_t buffer_len);
void php_tp_reencode_length(smart_string *str, char *sz);
void php_tp_reencode_length(smart_string *str, size_t orig_len);

int convert_iter_str(const char *i, size_t i_len);

Expand Down

0 comments on commit 7b7e01f

Please sign in to comment.