- 博客(2835)
- 资源 (19)
- 收藏
- 关注
原创 漫话Redis源码之三十六
#include "server.h"int clientSubscriptionsCount(client *c);/*----------------------------------------------------------------------------- * Pubsub client replies API *----------------------------------------------------------------------------*...
2021-12-12 23:27:49 1259
原创 漫话Redis源码之三十五
#ifndef REDIS_STATIC#define REDIS_STATIC static#endif/* Optimization levels for size-based filling. * Note that the largest possible limit is 16k, so even if each record takes * just one byte, it still won't overflow the 16 bit count field. */sta...
2021-12-12 23:26:25 688
原创 漫话Redis源码之三十四
#include <stdint.h>#define N 16#define MASK ((1 << (N - 1)) + (1 << (N - 1)) - 1)#define LOW(x) ((unsigned)(x) & MASK)#define HIGH(x) LOW((x) >> N)#define MUL(x, y, z) { int32_t l = (long)(x) * (long)(y); \ (z)[0] =...
2021-12-12 23:25:02 504
原创 漫话Redis源码之三十三
/* Allocate a new rax and return its pointer. On out of memory the function * returns NULL. */rax *raxNew(void) { rax *rax = rax_malloc(sizeof(*rax)); if (rax == NULL) return NULL; rax->numele = 0; rax->numnodes = 1; rax-&g...
2021-12-12 23:22:17 402
原创 漫话Redis源码之三十二
static ssize_t rdbWriteRaw(rio *rdb, void *p, size_t len) { if (rdb && rioWrite(rdb,p,len) == 0) return -1; return len;}
2021-12-12 23:19:42 742
原创 漫话Redis源码之三十一
typedef struct _client { redisContext *context; sds obuf; char **randptr; /* Pointers to :rand: strings inside the command buf */ size_t randlen; /* Number of pointers in client->randptr */ size_t randfree; ...
2021-12-12 23:17:20 615 2
原创 漫话Redis源码之三十
int readLong(FILE *fp, char prefix, long *target) { char buf[128], *eptr; epos = ftello(fp); if (fgets(buf,sizeof(buf),fp) == NULL) { return 0; } if (buf[0] != prefix) { ERROR("Expected prefix '%c', got: '%c'",prefi...
2021-12-12 23:15:21 444
原创 漫话Redis源码之二十九
struct { rio *rio; robj *key; /* Current key we are reading. */ int key_type; /* Current key type if != -1. */ unsigned long keys; /* Number of keys processed. */ unsigned long exp...
2021-12-12 23:14:06 677
原创 漫话Redis源码之二十八
/* Cluster Manager Command Info */typedef struct clusterManagerCommand { char *name; int argc; char **argv; int flags; int replicas; char *from; char *to; char **weight; int weight_argc; char *master_id; ...
2021-12-12 23:11:54 380
原创 漫话Redis源码之二十七
#include <string.h>#include <stdio.h>#include "release.h"#include "version.h"#include "crc64.h"char *redisGitSHA1(void) { return REDIS_GIT_SHA1;}char *redisGitDirty(void) { return REDIS_GIT_DIRTY;}uint64_t redisBuild...
2021-12-05 21:55:56 883
原创 漫话Redis源码之二十六
#include "server.h"#include "cluster.h"#include "bio.h"#include <sys/time.h>#include <unistd.h>#include <fcntl.h>#include <sys/socket.h>#include <sys/stat.h>void replicationDiscardCachedMaster(void);void replic...
2021-12-05 21:54:16 1633
原创 漫话Redis源码之二十五
static const rio rioFileIO = { rioFileRead, rioFileWrite, rioFileTell, rioFileFlush, NULL, /* update_checksum */ 0, /* current checksum */ 0, /* flags */ 0, /* bytes re...
2021-12-05 21:51:13 360
原创 漫话Redis源码之二十四
/* Debugger shared state is stored inside this global structure. */#define LDB_BREAKPOINTS_MAX 64 /* Max number of breakpoints. */#define LDB_MAX_LEN_DEFAULT 256 /* Default len limit for replies / var dumps. */struct ldbState { connection *c...
2021-12-05 21:49:42 367
原创 漫话Redis源码之二十三
static inline char sdsReqType(size_t string_size) { if (string_size < 1<<5) return SDS_TYPE_5; if (string_size < 1<<8) return SDS_TYPE_8; if (string_size < 1<<16) return SDS_TYPE_16;#if (LO...
2021-12-05 21:48:15 404
原创 漫话Redis源码之二十二
/* This function is for checking whether sentinel config file has been set, * also checking whether we have write permissions. */void sentinelCheckConfigFile(void) { if (server.configfile == NULL) { serverLog(LL_WARNING, "Sen...
2021-12-05 21:47:03 513
原创 漫话Redis源码之二十一
/* Log a fixed message without printf-alike capabilities, in a way that is * safe to call from a signal handler. * * We actually use this only for signals that are not fatal from the point * of view of Redis. Signals that are going to kill the s...
2021-12-05 21:45:24 271
原创 漫话Redis源码之二十
/* set current thread cpu affinity to cpu list, this function works like * taskset command (actually cpulist parsing logic reference to util-linux). * example of this function: "0,2,3", "0,2-3", "0-20:2". */void setcpuaffinity(const char *cpulist) ...
2021-11-28 18:58:04 875
原创 漫话Redis源码之十九
#if __linux__ if (!(tmp = strdup(program_invocation_name))) goto syerr; program_invocation_name = tmp; if (!(tmp = strdup(program_invocation_short_name))) goto syerr; program_invocation_short_name = tmp;#elif __APPLE__ if (!(tmp = strdup(...
2021-11-28 18:56:58 656
原创 漫话Redis源码之十八
#else for (i = 0; i < 8; i++) { finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)] >> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */ }#endif c = 0200; SHA1Update(context, &...
2021-11-28 18:53:58 464
原创 漫话Redis源码之十七
void sha256_update(SHA256_CTX *ctx, const BYTE data[], size_t len){ WORD i; for (i = 0; i < len; ++i) { ctx->data[ctx->datalen] = data[i]; ctx->datalen++; if (ctx->datalen == 64) { sha256_transform(ctx, ctx->data); ct...
2021-11-28 18:52:15 302
原创 漫话Redis源码之十六
/* Test of the CPU is Little Endian and supports not aligned accesses. * Two interesting conditions to speedup the function that happen to be * in most of x86 servers. */#if defined(__X86_64__) || defined(__x86_64__) || defined (__i386__) \ || def...
2021-11-28 18:50:27 498
原创 漫话Redis源码之十五
#include "server.h"#include "slowlog.h"/* Create a new slowlog entry. * Incrementing the ref count of all the objects retained is up to * this function. */slowlogEntry *slowlogCreateEntry(client *c, robj **argv, int argc, long long duration) {...
2021-11-28 18:48:53 280
原创 漫话Redis源码之十四
/* The SORT command is the most complex command in Redis. Warning: this code * is optimized for speed and a bit less for readability */void sortCommand(client *c) { list *operations; unsigned int outputlen = 0; int desc = 0, alpha = 0; ...
2021-11-28 18:47:52 1320
原创 漫话Redis源码之十三
/* Render part of a sequence, so that render_sequence() call call this function * with different parts in order to create the full output without overflowing * the current terminal columns. */sds sparklineRenderRange(sds output, struct sequence *se...
2021-11-28 18:45:29 282
原创 漫话Redis源码之十二
#include "server.h"/* ----------------- Blocking sockets I/O with timeouts --------------------- *//* Redis performs most of the I/O in a nonblocking way, with the exception * of the SYNC command where the slave does it in a blocking way, and * ...
2021-11-28 18:43:39 308
原创 漫话Redis源码之十一
#define HASH_SET_TAKE_FIELD (1<<0)#define HASH_SET_TAKE_VALUE (1<<1)#define HASH_SET_COPY 0int hashTypeSet(robj *o, sds field, sds value, int flags) { int update = 0; if (o->encoding == OBJ_ENCODING_ZIPLIST) { uns...
2021-11-28 18:42:12 345
原创 蓝桥杯大赛获奖选手,可获研究生推免加分啦,挺好的呀
大家好,我是涛哥。我一直关注着各类大会和各类比赛,之前也写过蓝桥杯大赛的一些攻略,并用实际的题目和案例,为大家准备蓝桥杯比赛提供了指导。蓝桥杯大赛其实并不难,但好处很多。有的朋友可能对蓝桥杯还不太了解,不过没关系,我简单来跟大家说说,希望广大IT爱好者能了解更多,从中受益。
2021-11-22 20:52:47 15561 10
原创 很多事情,与决心有关
很多时候,我总是倾向于相信决心。事情到底能不能做成,这源于决心。后来,有人跟我说,仅仅有决心是不够的。年轻的我反驳道:那是因为决心不太大。逐渐长大后,意识到有些事情确实无能为力,跟决心无关。而且,这样的事情还很多。虽然有很多事情我们无法左右,再大的决心也无济于事。但是,我还是要说,决心在很大程度上能影响结果。就这样吧。加油。...
2021-11-21 23:14:26 720 2
原创 漫话Redis源码之十
#include "server.h"/* ----------------- Blocking sockets I/O with timeouts --------------------- *//* Redis performs most of the I/O in a nonblocking way, with the exception * of the SYNC command where the slave does it in a blocking way, and * th...
2021-11-21 23:09:38 640
原创 漫话Redis源码之九
/* This is a helper function for the COPY command. * Duplicate a hash object, with the guarantee that the returned object * has the same encoding as the original one. * * The resulting object always has refcount set to 1 */robj *hashTypeDup(robj ...
2021-11-21 23:07:42 531
原创 漫话Redis源码之八
if (!(flags & STREAM_RWR_RAWENTRIES)) arraylen_ptr = addReplyDeferredLen(c); streamIteratorStart(&si,s,start,end,rev); while(streamIteratorGetID(&si,&id,&numfields)) { /* Update the group last_id if needed. ...
2021-11-21 23:06:31 389
原创 漫话Redis源码之七
void getrangeCommand(client *c) { robj *o; long long start, end; char *str, llbuf[32]; size_t strlen; if (getLongLongFromObjectOrReply(c,c->argv[2],&start,NULL) != C_OK) return; if (getLongLongFromObjectOrReply(...
2021-11-21 23:03:43 420
原创 漫话Redis源码之六
/* Return a ziplist element as an SDS string. */sds ziplistGetObject(unsigned char *sptr) { unsigned char *vstr; unsigned int vlen; long long vlong; serverAssert(sptr != NULL); serverAssert(ziplistGet(sptr,&vstr,&vlen,&am...
2021-11-21 23:02:18 476
原创 漫话Redis源码之五
void tlsCleanup(void) { if (redis_tls_ctx) { SSL_CTX_free(redis_tls_ctx); redis_tls_ctx = NULL; } if (redis_tls_client_ctx) { SSL_CTX_free(redis_tls_client_ctx); redis_tls_client_ctx = NULL; } #if OPE...
2021-11-21 23:00:57 680
原创 浅聊选择和努力
大家好,我是涛哥。又到周末了,愿大家开心。昨天是七夕节,你是否约到了心仪的另外一半呢?不管怎样,愿有情人终成眷属。最近在玩画画,在我的文章中,大家以后可以看到我的手绘画画哦,挺有意思的,文章封面图不愁了。最近有几件重要事情,其中一件是:我续约了。我平时很少公开谈职场相关的话题,今天这篇,聊作随笔。 涛歌手绘再过几年,我就35岁了,这是IT圈疯传的尴尬年龄,网上...
2021-11-21 22:59:54 714 5
原创 漫话Redis源码之四
/* Modify the buffer replacing all occurrences of chars from the 'from' * set with the corresponding char in the 'to' set. Always returns s. */char *memmapchars(char *s, size_t len, const char *from, const char *to, size_t setlen) { for (size_t...
2021-11-21 22:57:35 336
原创 漫话Redis源码之三
} zlentry;#define ZIPLIST_ENTRY_ZERO(zle) { \ (zle)->prevrawlensize = (zle)->prevrawlen = 0; \ (zle)->lensize = (zle)->len = (zle)->headersize = 0; \ (zle)->encoding = 0; \ (zle)->p = NULL; \}/* Extract the en...
2021-11-21 22:55:58 338
linux protobuf安装文件
2016-11-04
linux tree命令的源码
2015-11-01
编译好的openssl库和头文件
2014-12-14
入门数据库sqlite3的最佳实践资料
2014-08-12
在Windows下学习Linux命令
2013-08-08
音频处理软件Gold Wave
2013-07-17
H.264visa软件
2013-07-13
YUVviewer :原始的YUV视频的播放器
2013-06-24
经典的C语言编译器:TC2.0
2013-06-23
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人