uring落盘的无锁队列修改
This commit is contained in:
@@ -10,48 +10,49 @@
|
||||
|
||||
static void die(redisContext *c, const char *msg) {
|
||||
fprintf(stderr, "%s: %s\n", msg, c && c->err ? c->errstr : "unknown");
|
||||
redisFree(c);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void must_ok(redisReply *r, const char *what) {
|
||||
if (!r) { fprintf(stderr, "%s: reply null\n", what); exit(1); }
|
||||
static int must_ok(redisReply *r, const char *what) {
|
||||
if (!r) { fprintf(stderr, "%s: reply null\n", what); return -1; }
|
||||
if (!(r->type == REDIS_REPLY_STATUS && r->str && strcasecmp(r->str, "OK") == 0)) {
|
||||
fprintf(stderr, "%s: expect +OK, got type=%d str=%s\n",
|
||||
what, r->type, r->str ? r->str : "(null)");
|
||||
freeReplyObject(r);
|
||||
exit(1);
|
||||
return -1;
|
||||
}
|
||||
freeReplyObject(r);
|
||||
}
|
||||
|
||||
static void must_int(redisReply *r, long long expect, const char *what) {
|
||||
if (!r) { fprintf(stderr, "%s: reply null\n", what); exit(1); }
|
||||
static int must_int(redisReply *r, long long expect, const char *what) {
|
||||
if (!r) { fprintf(stderr, "%s: reply null\n", what); return -1; }
|
||||
if (r->type != REDIS_REPLY_INTEGER || r->integer != expect) {
|
||||
fprintf(stderr, "%s: expect :%lld, got type=%d int=%lld\n",
|
||||
what, expect, r->type, (long long)r->integer);
|
||||
freeReplyObject(r);
|
||||
exit(1);
|
||||
return -1;
|
||||
}
|
||||
freeReplyObject(r);
|
||||
}
|
||||
|
||||
static void must_bulk_eq(redisReply *r, const void *buf, size_t n, const char *what) {
|
||||
if (!r) { fprintf(stderr, "%s: reply null\n", what); exit(1); }
|
||||
static int must_bulk_eq(redisReply *r, const void *buf, size_t n, const char *what) {
|
||||
if (!r) { fprintf(stderr, "%s: reply null\n", what); return -1; }
|
||||
if (r->type != REDIS_REPLY_STRING || r->len != n || memcmp(r->str, buf, n) != 0) {
|
||||
fprintf(stderr, "%s: bulk mismatch. type=%d len=%zu\n", what, r->type, r->len);
|
||||
fprintf(stderr, "expect:%s, truely:%s\n", (const char*)buf, r->str);
|
||||
freeReplyObject(r);
|
||||
exit(1);
|
||||
return -1;
|
||||
}
|
||||
freeReplyObject(r);
|
||||
}
|
||||
|
||||
static void must_nil(redisReply *r, const char *what) {
|
||||
if (!r) { fprintf(stderr, "%s: reply null\n", what); exit(1); }
|
||||
static int must_nil(redisReply *r, const char *what) {
|
||||
if (!r) { fprintf(stderr, "%s: reply null\n", what); return -1; }
|
||||
if (r->type != REDIS_REPLY_NIL) {
|
||||
fprintf(stderr, "%s: expect nil, got type=%d\n", what, r->type);
|
||||
freeReplyObject(r);
|
||||
exit(1);
|
||||
return -1;
|
||||
}
|
||||
freeReplyObject(r);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user