Implement test mode to make finding bugs easier
Former-commit-id: 971f69fe1ff9cce50492a47f306b312457e50b9f
This commit is contained in:
parent
b82cf7f034
commit
add714913b
@ -864,6 +864,8 @@ void loadServerConfigFromString(char *config) {
|
|||||||
} else if (!strcasecmp(argv[0], "version-override") && argc == 2) {
|
} else if (!strcasecmp(argv[0], "version-override") && argc == 2) {
|
||||||
KEYDB_SET_VERSION = zstrdup(argv[1]);
|
KEYDB_SET_VERSION = zstrdup(argv[1]);
|
||||||
serverLog(LL_WARNING, "Warning version is overriden to: %s\n", KEYDB_SET_VERSION);
|
serverLog(LL_WARNING, "Warning version is overriden to: %s\n", KEYDB_SET_VERSION);
|
||||||
|
} else if (!strcasecmp(argv[0],"testmode") && argc == 2){
|
||||||
|
g_fTestMode = yesnotoi(argv[1]);
|
||||||
} else {
|
} else {
|
||||||
err = "Bad directive or wrong number of arguments"; goto loaderr;
|
err = "Bad directive or wrong number of arguments"; goto loaderr;
|
||||||
}
|
}
|
||||||
|
@ -1097,11 +1097,31 @@ void acceptTcpHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
|
|||||||
serverLog(LL_VERBOSE,"Accepted %s:%d", cip, cport);
|
serverLog(LL_VERBOSE,"Accepted %s:%d", cip, cport);
|
||||||
int ielCur = ielFromEventLoop(el);
|
int ielCur = ielFromEventLoop(el);
|
||||||
|
|
||||||
|
if (!g_fTestMode)
|
||||||
|
{
|
||||||
// We always accept on the same thread
|
// We always accept on the same thread
|
||||||
|
LLocalThread:
|
||||||
aeAcquireLock();
|
aeAcquireLock();
|
||||||
acceptCommonHandler(cfd,0,cip, ielCur);
|
acceptCommonHandler(cfd,0,cip, ielCur);
|
||||||
aeReleaseLock();
|
aeReleaseLock();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// In test mode we want a good distribution among threads and avoid the main thread
|
||||||
|
// since the main thread is most likely to work
|
||||||
|
int iel = IDX_EVENT_LOOP_MAIN;
|
||||||
|
while (cserver.cthreads > 1 && iel == IDX_EVENT_LOOP_MAIN)
|
||||||
|
iel = rand() % cserver.cthreads;
|
||||||
|
if (iel == ielFromEventLoop(el))
|
||||||
|
goto LLocalThread;
|
||||||
|
char *szT = (char*)zmalloc(NET_IP_STR_LEN, MALLOC_LOCAL);
|
||||||
|
memcpy(szT, cip, NET_IP_STR_LEN);
|
||||||
|
aePostFunction(g_pserver->rgthreadvar[iel].el, [cfd, iel, szT]{
|
||||||
|
acceptCommonHandler(cfd,0,szT, iel);
|
||||||
|
zfree(szT);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void acceptUnixHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
|
void acceptUnixHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
|
||||||
|
@ -61,6 +61,8 @@
|
|||||||
#include <uuid/uuid.h>
|
#include <uuid/uuid.h>
|
||||||
#include "aelocker.h"
|
#include "aelocker.h"
|
||||||
|
|
||||||
|
int g_fTestMode = false;
|
||||||
|
|
||||||
/* Our shared "common" objects */
|
/* Our shared "common" objects */
|
||||||
|
|
||||||
struct sharedObjectsStruct shared;
|
struct sharedObjectsStruct shared;
|
||||||
|
@ -88,6 +88,8 @@ typedef long long mstime_t; /* millisecond time type. */
|
|||||||
#include "endianconv.h"
|
#include "endianconv.h"
|
||||||
#include "crc64.h"
|
#include "crc64.h"
|
||||||
|
|
||||||
|
extern int g_fTestMode;
|
||||||
|
|
||||||
struct redisObject;
|
struct redisObject;
|
||||||
class robj_roptr
|
class robj_roptr
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user