Skip to content

Commit

Permalink
[fix] fix bug & add flag -Wno-pedantic
Browse files Browse the repository at this point in the history
  • Loading branch information
VCgege committed Oct 31, 2024
1 parent 6b4ea68 commit f412c32
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ifneq (,$(findstring FreeBSD,$(uname_S)))
STD+=-Wno-c11-extensions
endif
endif
WARN=-Wall -W -Wno-missing-field-initializers
WARN=-Wall -W -Wno-missing-field-initializers -Wno-pedantic
OPT=$(OPTIMIZATION)

# Detect if the compiler supports C11 _Atomic
Expand Down
1 change: 1 addition & 0 deletions src/ctrip_swap.h
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ void freeObjectMeta(objectMeta *object_meta);
sds objectMetaEncode(struct objectMeta *object_meta, int meta_enc_mode);
int objectMetaDecode(struct objectMeta *object_meta, const char *extend, size_t extlen);
int keyIsHot(objectMeta *object_meta, robj *value);
int keyIsPureHot(redisDb *db, robj *key);
sds dumpObjectMeta(objectMeta *object_meta);
int objectMetaEqual(struct objectMeta *oma, struct objectMeta *omb);
int objectMetaRebuildFeed(struct objectMeta *rebuild_meta, uint64_t version, const char *subkey, size_t sublen, robj *subval);
Expand Down
1 change: 1 addition & 0 deletions src/ctrip_swap_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ NULL
if (submitUtilTask(ROCKSDB_COMPACT_RANGE_TASK, task, rocksdbCompactRangeTaskDone, task, &error)) {
addReply(c,shared.ok);
} else {
compactTaskFree(task);
addReplyErrorSds(c,error);
}
} else if (!strcasecmp(c->argv[1]->ptr,"flush") && c->argc >= 2) {
Expand Down
6 changes: 2 additions & 4 deletions src/ctrip_swap_load.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ int tryLoadKey(redisDb *db, robj *key, int oom_sensitive) {
client *load_client = server.load_clients[db->id];

/* skip pure hot key */
if (lookupKey(db, key, LOOKUP_NOTOUCH) != NULL && lookupMeta(db, key) == NULL) {
if (keyIsPureHot(db, key)) {
return 0;
}

Expand Down Expand Up @@ -166,9 +166,7 @@ int readSwapChildErr(swapRdbSaveErrType *err_type, int *db_id, sds *key) {
if (server.swap_child_err_nread == buf_len) {
/* read swapRdbSaveErr done, make room for key reading */
server.swap_child_err_nread = 0;
key_buffer = sdsempty();
key_buffer = sdsMakeRoomForExact(key_buffer, buffer.klen);
sdssetlen(key_buffer, buffer.klen);
key_buffer = sdsnewlen(SDS_NOINIT, buffer.klen);
}
}

Expand Down
15 changes: 15 additions & 0 deletions src/ctrip_swap_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,21 @@ int keyIsHot(objectMeta *object_meta, robj *value) {
return swapObjectMetaIsHot(&som);
}

int keyIsPureHot(redisDb *db, robj *key) {
if (lookupKey(db, key, LOOKUP_NOTOUCH) == NULL) {
return 0;
} else {
objectMeta *om = lookupMeta(db, key);
if (om == NULL) {
return 1;
} else if (om->swap_type == SWAP_TYPE_BITMAP && bitmapObjectMetaIsMarker(om)) {
return 1;
} else {
return 0;
}
}
}

struct listMeta;
sds listMetaDump(sds result, struct listMeta *lm);

Expand Down
2 changes: 1 addition & 1 deletion tests/swap/integration/rordb.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ start_server {tags {"rordb replication"} overrides {}} {
assert_equal [$slave bitcount mybitmap2] {5}

assert_equal [object_meta_pure_cold_subkeys_num $slave mybitmap3] 6
# $master flushdb
$master flushdb

}

Expand Down
2 changes: 1 addition & 1 deletion tests/swap/integration/type_error.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -555,5 +555,5 @@ start_server {tags {"repl"}} {

}
}

r flushdb
}

0 comments on commit f412c32

Please sign in to comment.