From aefd65d7173b517c9f583601a41c98626bfb5218 Mon Sep 17 00:00:00 2001 From: stefanocasazza Date: Tue, 17 Jul 2018 17:01:13 +0200 Subject: [PATCH] redis fix --- include/ulib/net/client/redis.h | 15 +++++++++++++++ src/ulib/net/client/redis.cpp | 4 +++- src/ulib/utility/socket_ext.cpp | 2 ++ tests/examples/TSA/tsaserial | 2 +- tests/ulib/README | 4 ++-- 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/include/ulib/net/client/redis.h b/include/ulib/net/client/redis.h index 6f893532..8ae52c73 100644 --- a/include/ulib/net/client/redis.h +++ b/include/ulib/net/client/redis.h @@ -686,6 +686,21 @@ public: bool processMultiRequest(const char* format, uint32_t fmt_size, ...); + // REDI-SEARCH (@see https://oss.redislabs.com/redisearch/) + + bool suggest(const char* key, uint32_t keyLength, const char* prefix, uint32_t prefixLength, bool fuzzy, bool withPayloads) + { + U_TRACE(0, "UREDISClient_Base::suggest(%.*S,%u,%.*S,%u,%b,%b)", keyLength, key, keyLength, prefixLength, prefix, prefixLength, fuzzy, withPayloads) + + U_INTERNAL_ASSERT_EQUALS(u_buffer_len, 0) + + return processRequest(U_RC_MULTIBULK, U_CONSTANT_TO_PARAM("FT.SUGGET"), u_buffer, + u__snprintf(u_buffer, U_BUFFER_SIZE, U_CONSTANT_TO_PARAM("%.*s %.*s %.*s %.*s"), + keyLength, key, prefixLength, prefix, + (fuzzy ? U_CONSTANT_SIZE("FUZZY") : 0), "FUZZY", + (withPayloads ? U_CONSTANT_SIZE("WITHPAYLOADS") : 0), "WITHPAYLOADS")); + } + #if defined(U_STDCPP_ENABLE) && defined(DEBUG) const char* dump(bool reset) const; #endif diff --git a/src/ulib/net/client/redis.cpp b/src/ulib/net/client/redis.cpp index a00a19fb..939d61ce 100644 --- a/src/ulib/net/client/redis.cpp +++ b/src/ulib/net/client/redis.cpp @@ -111,7 +111,7 @@ void UREDISClient_Base::manageResponseBufferResize(uint32_t n) U_INTERNAL_DUMP("rep = %p rep->parent = %p rep->references = %u rep->_length = %u rep->_capacity = %u", rep, rep->parent, rep->references, rep->_length, rep->_capacity) - UStringRep* nrep = UStringRep::create(rep->_length, n, rep->data()); + UStringRep* nrep = UStringRep::create(rep->_length, rep->_length+n, rep->data()); if ((n = pthis->vitem.size())) { @@ -232,6 +232,8 @@ U_NO_EXPORT bool UREDISClient_Base::getResponseItem() { uint32_t d = UClient_Base::response.distance(ptr2); + manageResponseBufferResize(len); + if (UClient_Base::readResponse() == false) { U_RETURN(false); diff --git a/src/ulib/utility/socket_ext.cpp b/src/ulib/utility/socket_ext.cpp index 1076c5ca..24b85c97 100644 --- a/src/ulib/utility/socket_ext.cpp +++ b/src/ulib/utility/socket_ext.cpp @@ -78,6 +78,8 @@ bool USocketExt::read(USocket* sk, UString& buffer, uint32_t count, int timeoutM else UString::_reserve(buffer, buffer.getReserveNeed(chunk)); ncount = buffer.space(); + + U_INTERNAL_ASSERT_MAJOR(ncount, 0) } ptr = buffer.c_pointer(start); diff --git a/tests/examples/TSA/tsaserial b/tests/examples/TSA/tsaserial index 648933ea..32b5453c 100644 --- a/tests/examples/TSA/tsaserial +++ b/tests/examples/TSA/tsaserial @@ -1 +1 @@ -01E1 +01E8 diff --git a/tests/ulib/README b/tests/ulib/README index 0d4f110a..065027be 100644 --- a/tests/ulib/README +++ b/tests/ulib/README @@ -7,8 +7,8 @@ Debian 7.11 was released Saturday, 4th June 2016. Debian 8.11, or jessie. Access this release through dists/oldstable Debian 8.11 was released Saturday, 23rd June 2018. -Debian 9.4, or stretch. Access this release through dists/stable -Debian 9.4 was released Saturday, 10th March 2018. +Debian 9.5, or stretch. Access this release through dists/stable +Debian 9.5 was released Saturday, 14th July 2018. Testing, or buster. Access this release through dists/testing. The current tested development snapshot is named buster. Packages which