Skip to content

Commit

Permalink
fix redis tests crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Ponomarenko authored and furmur committed Oct 9, 2024
1 parent c7475dd commit 1479efb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ ADD_SUBDIRECTORY (debian)

IF(SEMS_USE_GTEST)
add_subdirectory(unit_tests)
add_custom_target(test USES_TERMINAL COMMAND /bin/bash ${CMAKE_SOURCE_DIR}/run_unit_test.sh all --gtest_filter=-FaxTest.*:PostgresqlTest.*:RedisTest.*:RTPStream.SingleStreams:ZRTPTest.SingleTest:TransportTest.WebSocket)
add_custom_target(test USES_TERMINAL COMMAND /bin/bash ${CMAKE_SOURCE_DIR}/run_unit_test.sh all --gtest_filter=-FaxTest.*:RTPStream.SingleStreams:ZRTPTest.SingleTest:TransportTest.WebSocket)
ENDIF(SEMS_USE_GTEST)

#SET_DIRECTORY_PROPERTIES(ADDITIONAL_MAKE_CLEAN_FILES *~)
Expand Down
22 changes: 14 additions & 8 deletions apps/redis/unit_tests/RedisTestInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ class RedisTestConnection : public RedisInstance
if(!async_connected && ac->onConnect) {
async_connected = true;
ac->onConnect(ac, REDIS_OK);
} else if (q.empty()) {
ERROR("q is empty");
} else {
redisReply* reply;
Command cmd = q.front();
Expand Down Expand Up @@ -168,21 +170,20 @@ class RedisTestConnection : public RedisInstance

int redisAsyncFormattedCommand(redisAsyncContext *ac, redisCallbackFn *fn, void *privdata_, const char *cmd, size_t len) override
{
if(ac->ev.addWrite)
ac->ev.addWrite(ac->ev.data);
Command current;
current.replyfn = fn;
current.privdata = privdata_;
current.command = string(cmd, len);
q.push(current);

if(ac->ev.addWrite)
ac->ev.addWrite(ac->ev.data);

return REDIS_OK;
}

int redisAsyncCommandArgv(redisAsyncContext *ac, redisCallbackFn *fn, void *privdata, int argc, const char **argv, const size_t *argvlen) override
{
if(ac->ev.addWrite)
ac->ev.addWrite(ac->ev.data);

Command current;
sds cmd;
long long len;
Expand All @@ -194,15 +195,16 @@ class RedisTestConnection : public RedisInstance

current.command = string(cmd, len);
q.push(current);

if(ac->ev.addWrite)
ac->ev.addWrite(ac->ev.data);

redisFreeSdsCommand(cmd);
return REDIS_OK;
}

int redisvAsyncCommand(redisAsyncContext *ac, redisCallbackFn *fn, void *privdata, const char* format, va_list argptr) override
{
if(ac->ev.addWrite)
ac->ev.addWrite(ac->ev.data);

Command current;
current.replyfn = fn;
current.privdata = privdata;
Expand All @@ -214,6 +216,10 @@ class RedisTestConnection : public RedisInstance

current.command = string(cmd, len);
q.push(current);

if(ac->ev.addWrite)
ac->ev.addWrite(ac->ev.data);

redisFreeCommand(cmd);
return REDIS_OK;
}
Expand Down

0 comments on commit 1479efb

Please sign in to comment.