1extern crate c2rust_bitfields;
2extern crate libc;
3extern crate core;
4use std::cell::UnsafeCell;
5extern "C" {
6 pub type _IO_wide_data;
7 pub type _IO_codecvt;
8 pub type _IO_marker;
9 pub type RedisModuleCtx;
10 pub type RedisModuleDefragCtx;
11 pub type RedisModuleInfoCtx;
12 pub type RedisModuleKeyOptCtx;
13 pub type RedisModuleCommand;
14 pub type clusterSlotToKeyMapping;
15 pub type functionsLibCtx;
16 pub type clusterState;
17 static mut server: redisServer;
18 static mut shared: sharedObjectsStruct;
19 static mut R_PosInf: libc::c_double;
20 static mut R_NegInf: libc::c_double;
21 static mut R_Nan: libc::c_double;
22 static mut hashDictType: dictType;
23 fn moduleTypeLookupModuleByID(id: uint64_t) -> *mut moduleType;
24 fn moduleTypeNameByID(name: *mut libc::c_char, moduleid: uint64_t);
25 fn moduleTypeModuleName(mt: *mut moduleType) -> *const libc::c_char;
26 fn moduleFreeContext(ctx: *mut RedisModuleCtx);
27 fn moduleNotifyKeyspaceEvent(
28 type_0: libc::c_int,
29 event: *const libc::c_char,
30 key: *mut robj,
31 dbid: libc::c_int,
32 );
33 fn rdbSaveModulesAux(rdb: *mut rio, when: libc::c_int) -> ssize_t;
34 fn moduleFireServerEvent(eid: uint64_t, subid: libc::c_int, data: *mut libc::c_void);
35 fn processModuleLoadingProgressEvent(is_aof: libc::c_int);
36 fn mstime() -> libc::c_longlong;
37 fn getRandomHexChars(p: *mut libc::c_char, len: size_t);
38 fn exitFromChild(retcode: libc::c_int);
39 fn redisSetProcTitle(title: *mut libc::c_char) -> libc::c_int;
40 fn redisSetCpuAffinity(cpulist: *const libc::c_char);
41 fn addReply(c: *mut client, obj: *mut robj);
42 fn addReplyErrorObject(c: *mut client, err: *mut robj);
43 fn addReplyError(c: *mut client, err: *const libc::c_char);
44 fn addReplyStatus(c: *mut client, status: *const libc::c_char);
45 fn processEventsWhileBlocked();
46 fn blockingOperationStarts();
47 fn blockingOperationEnds();
48 fn decrRefCount(o: *mut robj);
49 fn dismissObject(o: *mut robj, dump_size: size_t);
50 fn createObject(type_0: libc::c_int, ptr: *mut libc::c_void) -> *mut robj;
51 fn createStringObject(ptr: *const libc::c_char, len: size_t) -> *mut robj;
52 fn tryCreateRawStringObject(ptr: *const libc::c_char, len: size_t) -> *mut robj;
53 fn tryCreateStringObject(ptr: *const libc::c_char, len: size_t) -> *mut robj;
54 fn isSdsRepresentableAsLongLong(s: sds, llval: *mut libc::c_longlong) -> libc::c_int;
55 fn tryObjectEncoding(o: *mut robj) -> *mut robj;
56 fn getDecodedObject(o: *mut robj) -> *mut robj;
57 fn createStringObjectFromLongLongForValue(value: libc::c_longlong) -> *mut robj;
58 fn createQuicklistObject() -> *mut robj;
59 fn createSetObject() -> *mut robj;
60 fn createIntsetObject() -> *mut robj;
61 fn createHashObject() -> *mut robj;
62 fn createZsetObject() -> *mut robj;
63 fn createStreamObject() -> *mut robj;
64 fn createModuleObject(mt: *mut moduleType, value: *mut libc::c_void) -> *mut robj;
65 fn rioInitWithFile(r: *mut rio, fp: *mut FILE);
66 fn rioInitWithFd(r: *mut rio, fd: libc::c_int);
67 fn rioFreeFd(r: *mut rio);
68 fn rioGenericUpdateChecksum(r: *mut rio, buf: *const libc::c_void, len: size_t);
69 fn rioSetAutoSync(r: *mut rio, bytes: off_t);
70 fn rioCheckType(r: *mut rio) -> uint8_t;
71 fn time(__timer: *mut time_t) -> time_t;
72 fn strtol(
73 _: *const libc::c_char,
74 _: *mut *mut libc::c_char,
75 _: libc::c_int,
76 ) -> libc::c_long;
77 fn strtoll(
78 _: *const libc::c_char,
79 _: *mut *mut libc::c_char,
80 _: libc::c_int,
81 ) -> libc::c_longlong;
82 fn exit(_: libc::c_int) -> !;
83 fn memcpy(
84 _: *mut libc::c_void,
85 _: *const libc::c_void,
86 _: libc::c_ulong,
87 ) -> *mut libc::c_void;
88 fn memcmp(
89 _: *const libc::c_void,
90 _: *const libc::c_void,
91 _: libc::c_ulong,
92 ) -> libc::c_int;
93 fn strcpy(_: *mut libc::c_char, _: *const libc::c_char) -> *mut libc::c_char;
94 fn strncpy(
95 _: *mut libc::c_char,
96 _: *const libc::c_char,
97 _: libc::c_ulong,
98 ) -> *mut libc::c_char;
99 fn strlen(_: *const libc::c_char) -> libc::c_ulong;
100 fn strerror(_: libc::c_int) -> *mut libc::c_char;
101 fn strcasecmp(__s1: *const libc::c_char, __s2: *const libc::c_char) -> libc::c_int;
102 fn close(__fd: libc::c_int) -> libc::c_int;
103 fn read(__fd: libc::c_int, __buf: *mut libc::c_void, __nbytes: size_t) -> ssize_t;
104 fn getcwd(__buf: *mut libc::c_char, __size: size_t) -> *mut libc::c_char;
105 fn getpid() -> __pid_t;
106 fn kill(__pid: __pid_t, __sig: libc::c_int) -> libc::c_int;
107 fn aeCreateFileEvent(
108 eventLoop: *mut aeEventLoop,
109 fd: libc::c_int,
110 mask: libc::c_int,
111 proc_0: Option::<aeFileProc>,
112 clientData: *mut libc::c_void,
113 ) -> libc::c_int;
114 fn aeDeleteFileEvent(
115 eventLoop: *mut aeEventLoop,
116 fd: libc::c_int,
117 mask: libc::c_int,
118 );
119 fn dictCreate(type_0: *mut dictType) -> *mut dict;
120 fn dictExpand(d: *mut dict, size: libc::c_ulong) -> libc::c_int;
121 fn dictTryExpand(d: *mut dict, size: libc::c_ulong) -> libc::c_int;
122 fn dictAdd(
123 d: *mut dict,
124 key: *mut libc::c_void,
125 val: *mut libc::c_void,
126 ) -> libc::c_int;
127 fn dictRelease(d: *mut dict);
128 fn dictGetIterator(d: *mut dict) -> *mut dictIterator;
129 fn dictGetSafeIterator(d: *mut dict) -> *mut dictIterator;
130 fn dictNext(iter: *mut dictIterator) -> *mut dictEntry;
131 fn dictReleaseIterator(iter: *mut dictIterator);
132 fn listNext(iter: *mut listIter) -> *mut listNode;
133 fn listRewind(list: *mut list, li: *mut listIter);
134 fn zmalloc(size: size_t) -> *mut libc::c_void;
135 fn ztrymalloc(size: size_t) -> *mut libc::c_void;
136 fn zfree(ptr: *mut libc::c_void);
137 fn zmalloc_used_memory() -> size_t;
138 fn anetPipe(
139 fds: *mut libc::c_int,
140 read_flags: libc::c_int,
141 write_flags: libc::c_int,
142 ) -> libc::c_int;
143 fn intsetAdd(is: *mut intset, value: int64_t, success: *mut uint8_t) -> *mut intset;
144 fn intsetLen(is: *const intset) -> uint32_t;
145 fn intsetBlobLen(is: *mut intset) -> size_t;
146 fn intsetValidateIntegrity(
147 is: *const libc::c_uchar,
148 size: size_t,
149 deep: libc::c_int,
150 ) -> libc::c_int;
151 fn ll2string(
152 s: *mut libc::c_char,
153 len: size_t,
154 value: libc::c_longlong,
155 ) -> libc::c_int;
156 fn string2ll(
157 s: *const libc::c_char,
158 slen: size_t,
159 value: *mut libc::c_longlong,
160 ) -> libc::c_int;
161 fn double2ll(d: libc::c_double, out: *mut libc::c_longlong) -> libc::c_int;
162 fn fsyncFileDir(filename: *const libc::c_char) -> libc::c_int;
163 fn latencyAddSample(event: *const libc::c_char, latency: mstime_t);
164 fn quicklistNew(fill: libc::c_int, compress: libc::c_int) -> *mut quicklist;
165 fn quicklistSetOptions(
166 quicklist: *mut quicklist,
167 fill: libc::c_int,
168 depth: libc::c_int,
169 );
170 fn quicklistRelease(quicklist: *mut quicklist);
171 fn quicklistPushTail(
172 quicklist: *mut quicklist,
173 value: *mut libc::c_void,
174 sz: size_t,
175 ) -> libc::c_int;
176 fn quicklistAppendListpack(quicklist: *mut quicklist, zl: *mut libc::c_uchar);
177 fn quicklistAppendPlainNode(
178 quicklist: *mut quicklist,
179 data: *mut libc::c_uchar,
180 sz: size_t,
181 );
182 fn quicklistCount(ql: *const quicklist) -> libc::c_ulong;
183 fn quicklistGetLzf(
184 node: *const quicklistNode,
185 data: *mut *mut libc::c_void,
186 ) -> size_t;
187 static mut raxNotFound: *mut libc::c_void;
188 fn raxTryInsert(
189 rax: *mut rax,
190 s: *mut libc::c_uchar,
191 len: size_t,
192 data: *mut libc::c_void,
193 old: *mut *mut libc::c_void,
194 ) -> libc::c_int;
195 fn raxFind(rax: *mut rax, s: *mut libc::c_uchar, len: size_t) -> *mut libc::c_void;
196 fn raxStart(it: *mut raxIterator, rt: *mut rax);
197 fn raxSeek(
198 it: *mut raxIterator,
199 op: *const libc::c_char,
200 ele: *mut libc::c_uchar,
201 len: size_t,
202 ) -> libc::c_int;
203 fn raxNext(it: *mut raxIterator) -> libc::c_int;
204 fn raxStop(it: *mut raxIterator);
205 fn raxSize(rax: *mut rax) -> uint64_t;
206 fn zipmapRewind(zm: *mut libc::c_uchar) -> *mut libc::c_uchar;
207 fn zipmapNext(
208 zm: *mut libc::c_uchar,
209 key: *mut *mut libc::c_uchar,
210 klen: *mut libc::c_uint,
211 value: *mut *mut libc::c_uchar,
212 vlen: *mut libc::c_uint,
213 ) -> *mut libc::c_uchar;
214 fn zipmapValidateIntegrity(
215 zm: *mut libc::c_uchar,
216 size: size_t,
217 deep: libc::c_int,
218 ) -> libc::c_int;
219 fn ziplistGet(
220 p: *mut libc::c_uchar,
221 sval: *mut *mut libc::c_uchar,
222 slen: *mut libc::c_uint,
223 lval: *mut libc::c_longlong,
224 ) -> libc::c_uint;
225 fn ziplistValidateIntegrity(
226 zl: *mut libc::c_uchar,
227 size: size_t,
228 deep: libc::c_int,
229 entry_cb: ziplistValidateEntryCB,
230 cb_userdata: *mut libc::c_void,
231 ) -> libc::c_int;
232 fn intrev64(v: uint64_t) -> uint64_t;
233 fn __errno_location() -> *mut libc::c_int;
234 fn sdsfromlonglong(value: libc::c_longlong) -> sds;
235 fn sdscatfmt(s: sds, fmt: *const libc::c_char, _: ...) -> sds;
236 fn sdsfree(s: sds);
237 fn sdsdup(s: sds) -> sds;
238 fn sdsempty() -> sds;
239 fn sdsnew(init: *const libc::c_char) -> sds;
240 fn sdstrynewlen(init: *const libc::c_void, initlen: size_t) -> sds;
241 fn sdsnewlen(init: *const libc::c_void, initlen: size_t) -> sds;
242 static mut SDS_NOINIT: *const libc::c_char;
243 fn fileno(__stream: *mut FILE) -> libc::c_int;
244 fn lpNew(capacity: size_t) -> *mut libc::c_uchar;
245 fn lpShrinkToFit(lp: *mut libc::c_uchar) -> *mut libc::c_uchar;
246 fn lpAppend(
247 lp: *mut libc::c_uchar,
248 s: *mut libc::c_uchar,
249 slen: uint32_t,
250 ) -> *mut libc::c_uchar;
251 fn lpAppendInteger(
252 lp: *mut libc::c_uchar,
253 lval: libc::c_longlong,
254 ) -> *mut libc::c_uchar;
255 fn lpLength(lp: *mut libc::c_uchar) -> libc::c_ulong;
256 fn lpGet(
257 p: *mut libc::c_uchar,
258 count: *mut int64_t,
259 intbuf: *mut libc::c_uchar,
260 ) -> *mut libc::c_uchar;
261 fn lpFirst(lp: *mut libc::c_uchar) -> *mut libc::c_uchar;
262 fn lpBytes(lp: *mut libc::c_uchar) -> size_t;
263 fn lpValidateIntegrity(
264 lp: *mut libc::c_uchar,
265 size: size_t,
266 deep: libc::c_int,
267 entry_cb: listpackValidateEntryCB,
268 cb_userdata: *mut libc::c_void,
269 ) -> libc::c_int;
270 fn lpSafeToAdd(lp: *mut libc::c_uchar, add: size_t) -> libc::c_int;
271 fn streamCreateConsumer(
272 cg: *mut streamCG,
273 name: sds,
274 key: *mut robj,
275 dbid: libc::c_int,
276 flags: libc::c_int,
277 ) -> *mut streamConsumer;
278 fn streamCreateCG(
279 s: *mut stream,
280 name: *mut libc::c_char,
281 namelen: size_t,
282 id: *mut streamID,
283 entries_read: libc::c_longlong,
284 ) -> *mut streamCG;
285 fn streamCreateNACK(consumer: *mut streamConsumer) -> *mut streamNACK;
286 fn streamFreeNACK(na: *mut streamNACK);
287 fn streamValidateListpackIntegrity(
288 lp: *mut libc::c_uchar,
289 size: size_t,
290 deep: libc::c_int,
291 ) -> libc::c_int;
292 fn streamGetEdgeID(
293 s: *mut stream,
294 first: libc::c_int,
295 skip_tombstones: libc::c_int,
296 edge_id: *mut streamID,
297 );
298 fn streamEstimateDistanceFromFirstEverEntry(
299 s: *mut stream,
300 id: *mut streamID,
301 ) -> libc::c_longlong;
302 fn sscanf(_: *const libc::c_char, _: *const libc::c_char, _: ...) -> libc::c_int;
303 fn vsnprintf(
304 _: *mut libc::c_char,
305 _: libc::c_ulong,
306 _: *const libc::c_char,
307 _: core::ffi::VaList,
308 ) -> libc::c_int;
309 fn snprintf(
310 _: *mut libc::c_char,
311 _: libc::c_ulong,
312 _: *const libc::c_char,
313 _: ...
314 ) -> libc::c_int;
315 fn fopen(_: *const libc::c_char, _: *const libc::c_char) -> *mut FILE;
316 fn fflush(__stream: *mut FILE) -> libc::c_int;
317 fn fclose(__stream: *mut FILE) -> libc::c_int;
318 fn rename(__old: *const libc::c_char, __new: *const libc::c_char) -> libc::c_int;
319 fn open(__file: *const libc::c_char, __oflag: libc::c_int, _: ...) -> libc::c_int;
320 fn estimateObjectIdleTime(o: *mut robj) -> libc::c_ulonglong;
321 fn replicationFeedSlaves(
322 slaves: *mut list,
323 dictid: libc::c_int,
324 argv: *mut *mut robj,
325 argc: libc::c_int,
326 );
327 fn updateSlavesWaitingBgsave(bgsaveerr: libc::c_int, type_0: libc::c_int);
328 fn replicationSendNewlineToMaster();
329 fn getPsyncInitialOffset() -> libc::c_longlong;
330 fn replicationSetupSlaveForFullResync(
331 slave: *mut client,
332 offset: libc::c_longlong,
333 ) -> libc::c_int;
334 fn rdbPipeReadHandler(
335 eventLoop: *mut aeEventLoop,
336 fd: libc::c_int,
337 clientData: *mut libc::c_void,
338 mask: libc::c_int,
339 );
340 fn _serverLog(level: libc::c_int, fmt: *const libc::c_char, _: ...);
341 fn redis_check_rdb_main(
342 argc: libc::c_int,
343 argv: *mut *mut libc::c_char,
344 fp: *mut FILE,
345 ) -> libc::c_int;
346 fn _serverPanic(
347 file: *const libc::c_char,
348 line: libc::c_int,
349 msg: *const libc::c_char,
350 _: ...
351 );
352 fn debugDelay(usec: libc::c_int);
353 fn LRU_CLOCK() -> libc::c_uint;
354 fn objectSetLRUOrLFU(
355 val: *mut robj,
356 lfu_freq: libc::c_longlong,
357 lru_idle: libc::c_longlong,
358 lru_clock: libc::c_longlong,
359 lru_multiplier: libc::c_int,
360 ) -> libc::c_int;
361 fn setExpire(
362 c: *mut client,
363 db: *mut redisDb,
364 key: *mut robj,
365 when: libc::c_longlong,
366 );
367 fn dbAddRDBLoad(db: *mut redisDb, key: sds, val: *mut robj) -> libc::c_int;
368 fn dbSyncDelete(db: *mut redisDb, key: *mut robj) -> libc::c_int;
369 fn _serverAssert(
370 estr: *const libc::c_char,
371 file: *const libc::c_char,
372 line: libc::c_int,
373 );
374 fn iAmMaster() -> libc::c_int;
375 fn hashTypeConvert(o: *mut robj, enc: libc::c_int);
376 fn hashTypeLength(o: *const robj) -> libc::c_ulong;
377 fn zsetConvert(zobj: *mut robj, encoding: libc::c_int);
378 fn zsetLength(zobj: *const robj) -> libc::c_ulong;
379 fn setTypeConvert(subject: *mut robj, enc: libc::c_int);
380 fn zslInsert(
381 zsl: *mut zskiplist,
382 score: libc::c_double,
383 ele: sds,
384 ) -> *mut zskiplistNode;
385 fn sendChildCowInfo(info_type: childInfoType, pname: *mut libc::c_char);
386 fn sendChildInfo(info_type: childInfoType, keys: size_t, pname: *mut libc::c_char);
387 fn _serverAssertWithInfo(
388 c: *const client,
389 o: *const robj,
390 estr: *const libc::c_char,
391 file: *const libc::c_char,
392 line: libc::c_int,
393 );
394 fn LFUDecrAndReturn(o: *mut robj) -> libc::c_ulong;
395 fn getExpire(db: *mut redisDb, key: *mut robj) -> libc::c_longlong;
396 fn redisFork(purpose: libc::c_int) -> libc::c_int;
397 fn hasActiveChildProcess() -> libc::c_int;
398 fn bg_unlink(filename: *const libc::c_char) -> libc::c_int;
399 fn unlink(__name: *const libc::c_char) -> libc::c_int;
400 fn fsync(__fd: libc::c_int) -> libc::c_int;
401 fn lzf_compress(
402 in_data: *const libc::c_void,
403 in_len: size_t,
404 out_data: *mut libc::c_void,
405 out_len: size_t,
406 ) -> size_t;
407 fn lzf_decompress(
408 in_data: *const libc::c_void,
409 in_len: size_t,
410 out_data: *mut libc::c_void,
411 out_len: size_t,
412 ) -> size_t;
413 fn functionsCreateWithLibraryCtx(
414 code: sds,
415 replace: libc::c_int,
416 err: *mut sds,
417 lib_ctx: *mut functionsLibCtx,
418 ) -> sds;
419 fn functionsLibGet() -> *mut dict;
420 fn functionsLibCtxGetCurrent() -> *mut functionsLibCtx;
421 fn __fxstat(
422 __ver: libc::c_int,
423 __fildes: libc::c_int,
424 __stat_buf: *mut stat,
425 ) -> libc::c_int;
426 static mut rdbCheckMode: libc::c_int;
427 fn rdbCheckError(fmt: *const libc::c_char, _: ...);
428}
429pub type __builtin_va_list = __va_list;
430#[derive(Copy, Clone)]
431#[repr(C)]
432pub struct __va_list {
433 pub __stack: *mut libc::c_void,
434 pub __gr_top: *mut libc::c_void,
435 pub __vr_top: *mut libc::c_void,
436 pub __gr_offs: libc::c_int,
437 pub __vr_offs: libc::c_int,
438}
439pub type __int8_t = libc::c_schar;
440pub type __uint8_t = libc::c_uchar;
441pub type __int16_t = libc::c_short;
442pub type __uint16_t = libc::c_ushort;
443pub type __int32_t = libc::c_int;
444pub type __uint32_t = libc::c_uint;
445pub type __int64_t = libc::c_long;
446pub type __uint64_t = libc::c_ulong;
447pub type __uint_least64_t = __uint64_t;
448pub type __dev_t = libc::c_ulong;
449pub type __uid_t = libc::c_uint;
450pub type __gid_t = libc::c_uint;
451pub type __ino64_t = libc::c_ulong;
452pub type __mode_t = libc::c_uint;
453pub type __nlink_t = libc::c_uint;
454pub type __off_t = libc::c_long;
455pub type __off64_t = libc::c_long;
456pub type __pid_t = libc::c_int;
457pub type __time_t = libc::c_long;
458pub type __blksize_t = libc::c_int;
459pub type __blkcnt64_t = libc::c_long;
460pub type __ssize_t = libc::c_long;
461pub type __syscall_slong_t = libc::c_long;
462pub type __sig_atomic_t = libc::c_int;
463pub type size_t = libc::c_ulong;
464#[derive(Copy, Clone)]
465#[repr(C)]
466pub struct iovec {
467 pub iov_base: *mut libc::c_void,
468 pub iov_len: size_t,
469}
470pub type mode_t = __mode_t;
471pub type off_t = __off64_t;
472pub type pid_t = __pid_t;
473#[derive(Copy, Clone)]
474#[repr(C)]
475pub struct timespec {
476 pub tv_sec: __time_t,
477 pub tv_nsec: __syscall_slong_t,
478}
479#[derive(Copy, Clone)]
480#[repr(C)]
481pub struct stat {
482 pub st_dev: __dev_t,
483 pub st_ino: __ino64_t,
484 pub st_mode: __mode_t,
485 pub st_nlink: __nlink_t,
486 pub st_uid: __uid_t,
487 pub st_gid: __gid_t,
488 pub st_rdev: __dev_t,
489 pub __pad1: __dev_t,
490 pub st_size: __off64_t,
491 pub st_blksize: __blksize_t,
492 pub __pad2: libc::c_int,
493 pub st_blocks: __blkcnt64_t,
494 pub st_atim: timespec,
495 pub st_mtim: timespec,
496 pub st_ctim: timespec,
497 pub __glibc_reserved: [libc::c_int; 2],
498}
499pub type ssize_t = __ssize_t;
500pub type time_t = __time_t;
501pub type int8_t = __int8_t;
502pub type int16_t = __int16_t;
503pub type int32_t = __int32_t;
504pub type int64_t = __int64_t;
505pub type pthread_t = libc::c_ulong;
506pub type va_list = __builtin_va_list;
507#[derive(Copy, Clone)]
508#[repr(C)]
509pub struct _IO_FILE {
510 pub _flags: libc::c_int,
511 pub _IO_read_ptr: *mut libc::c_char,
512 pub _IO_read_end: *mut libc::c_char,
513 pub _IO_read_base: *mut libc::c_char,
514 pub _IO_write_base: *mut libc::c_char,
515 pub _IO_write_ptr: *mut libc::c_char,
516 pub _IO_write_end: *mut libc::c_char,
517 pub _IO_buf_base: *mut libc::c_char,
518 pub _IO_buf_end: *mut libc::c_char,
519 pub _IO_save_base: *mut libc::c_char,
520 pub _IO_backup_base: *mut libc::c_char,
521 pub _IO_save_end: *mut libc::c_char,
522 pub _markers: *mut _IO_marker,
523 pub _chain: *mut _IO_FILE,
524 pub _fileno: libc::c_int,
525 pub _flags2: libc::c_int,
526 pub _old_offset: __off_t,
527 pub _cur_column: libc::c_ushort,
528 pub _vtable_offset: libc::c_schar,
529 pub _shortbuf: [libc::c_char; 1],
530 pub _lock: *mut libc::c_void,
531 pub _offset: __off64_t,
532 pub _codecvt: *mut _IO_codecvt,
533 pub _wide_data: *mut _IO_wide_data,
534 pub _freeres_list: *mut _IO_FILE,
535 pub _freeres_buf: *mut libc::c_void,
536 pub __pad5: size_t,
537 pub _mode: libc::c_int,
538 pub _unused2: [libc::c_char; 20],
539}
540pub type _IO_lock_t = ();
541pub type FILE = _IO_FILE;
542pub type uint8_t = __uint8_t;
543pub type uint16_t = __uint16_t;
544pub type uint32_t = __uint32_t;
545pub type uint64_t = __uint64_t;
546pub type uint_least64_t = __uint_least64_t;
547pub type sds = *mut libc::c_char;
548#[derive(Copy, Clone)]
549#[repr(C, packed)]
550pub struct sdshdr8 {
551 pub len: uint8_t,
552 pub alloc: uint8_t,
553 pub flags: libc::c_uchar,
554 pub buf: [libc::c_char; 0],
555}
556#[derive(Copy, Clone)]
557#[repr(C, packed)]
558pub struct sdshdr16 {
559 pub len: uint16_t,
560 pub alloc: uint16_t,
561 pub flags: libc::c_uchar,
562 pub buf: [libc::c_char; 0],
563}
564#[derive(Copy, Clone)]
565#[repr(C, packed)]
566pub struct sdshdr32 {
567 pub len: uint32_t,
568 pub alloc: uint32_t,
569 pub flags: libc::c_uchar,
570 pub buf: [libc::c_char; 0],
571}
572#[derive(Copy, Clone)]
573#[repr(C, packed)]
574pub struct sdshdr64 {
575 pub len: uint64_t,
576 pub alloc: uint64_t,
577 pub flags: libc::c_uchar,
578 pub buf: [libc::c_char; 0],
579}
580#[derive(Copy, Clone)]
581#[repr(C)]
582pub struct aeEventLoop {
583 pub maxfd: libc::c_int,
584 pub setsize: libc::c_int,
585 pub timeEventNextId: libc::c_longlong,
586 pub events: *mut aeFileEvent,
587 pub fired: *mut aeFiredEvent,
588 pub timeEventHead: *mut aeTimeEvent,
589 pub stop: libc::c_int,
590 pub apidata: *mut libc::c_void,
591 pub beforesleep: Option::<aeBeforeSleepProc>,
592 pub aftersleep: Option::<aeBeforeSleepProc>,
593 pub flags: libc::c_int,
594}
595pub type aeBeforeSleepProc = unsafe extern "C" fn(*mut aeEventLoop) -> ();
596#[derive(Copy, Clone)]
597#[repr(C)]
598pub struct aeTimeEvent {
599 pub id: libc::c_longlong,
600 pub when: monotime,
601 pub timeProc: Option::<aeTimeProc>,
602 pub finalizerProc: Option::<aeEventFinalizerProc>,
603 pub clientData: *mut libc::c_void,
604 pub prev: *mut aeTimeEvent,
605 pub next: *mut aeTimeEvent,
606 pub refcount: libc::c_int,
607}
608pub type aeEventFinalizerProc = unsafe extern "C" fn(
609 *mut aeEventLoop,
610 *mut libc::c_void,
611) -> ();
612pub type aeTimeProc = unsafe extern "C" fn(
613 *mut aeEventLoop,
614 libc::c_longlong,
615 *mut libc::c_void,
616) -> libc::c_int;
617pub type monotime = uint64_t;
618#[derive(Copy, Clone)]
619#[repr(C)]
620pub struct aeFiredEvent {
621 pub fd: libc::c_int,
622 pub mask: libc::c_int,
623}
624#[derive(Copy, Clone)]
625#[repr(C)]
626pub struct aeFileEvent {
627 pub mask: libc::c_int,
628 pub rfileProc: Option::<aeFileProc>,
629 pub wfileProc: Option::<aeFileProc>,
630 pub clientData: *mut libc::c_void,
631}
632pub type aeFileProc = unsafe extern "C" fn(
633 *mut aeEventLoop,
634 libc::c_int,
635 *mut libc::c_void,
636 libc::c_int,
637) -> ();
638#[derive(Copy, Clone)]
639#[repr(C)]
640pub struct connection {
641 pub type_0: *mut ConnectionType,
642 pub state: ConnectionState,
643 pub flags: libc::c_short,
644 pub refs: libc::c_short,
645 pub last_errno: libc::c_int,
646 pub private_data: *mut libc::c_void,
647 pub conn_handler: ConnectionCallbackFunc,
648 pub write_handler: ConnectionCallbackFunc,
649 pub read_handler: ConnectionCallbackFunc,
650 pub fd: libc::c_int,
651}
652pub type ConnectionCallbackFunc = Option::<unsafe extern "C" fn(*mut connection) -> ()>;
653pub type ConnectionState = libc::c_uint;
654pub const CONN_STATE_ERROR: ConnectionState = 5;
655pub const CONN_STATE_CLOSED: ConnectionState = 4;
656pub const CONN_STATE_CONNECTED: ConnectionState = 3;
657pub const CONN_STATE_ACCEPTING: ConnectionState = 2;
658pub const CONN_STATE_CONNECTING: ConnectionState = 1;
659pub const CONN_STATE_NONE: ConnectionState = 0;
660#[derive(Copy, Clone)]
661#[repr(C)]
662pub struct ConnectionType {
663 pub ae_handler: Option::<
664 unsafe extern "C" fn(
665 *mut aeEventLoop,
666 libc::c_int,
667 *mut libc::c_void,
668 libc::c_int,
669 ) -> (),
670 >,
671 pub connect: Option::<
672 unsafe extern "C" fn(
673 *mut connection,
674 *const libc::c_char,
675 libc::c_int,
676 *const libc::c_char,
677 ConnectionCallbackFunc,
678 ) -> libc::c_int,
679 >,
680 pub write: Option::<
681 unsafe extern "C" fn(*mut connection, *const libc::c_void, size_t) -> libc::c_int,
682 >,
683 pub writev: Option::<
684 unsafe extern "C" fn(*mut connection, *const iovec, libc::c_int) -> libc::c_int,
685 >,
686 pub read: Option::<
687 unsafe extern "C" fn(*mut connection, *mut libc::c_void, size_t) -> libc::c_int,
688 >,
689 pub close: Option::<unsafe extern "C" fn(*mut connection) -> ()>,
690 pub accept: Option::<
691 unsafe extern "C" fn(*mut connection, ConnectionCallbackFunc) -> libc::c_int,
692 >,
693 pub set_write_handler: Option::<
694 unsafe extern "C" fn(
695 *mut connection,
696 ConnectionCallbackFunc,
697 libc::c_int,
698 ) -> libc::c_int,
699 >,
700 pub set_read_handler: Option::<
701 unsafe extern "C" fn(*mut connection, ConnectionCallbackFunc) -> libc::c_int,
702 >,
703 pub get_last_error: Option::<
704 unsafe extern "C" fn(*mut connection) -> *const libc::c_char,
705 >,
706 pub blocking_connect: Option::<
707 unsafe extern "C" fn(
708 *mut connection,
709 *const libc::c_char,
710 libc::c_int,
711 libc::c_longlong,
712 ) -> libc::c_int,
713 >,
714 pub sync_write: Option::<
715 unsafe extern "C" fn(
716 *mut connection,
717 *mut libc::c_char,
718 ssize_t,
719 libc::c_longlong,
720 ) -> ssize_t,
721 >,
722 pub sync_read: Option::<
723 unsafe extern "C" fn(
724 *mut connection,
725 *mut libc::c_char,
726 ssize_t,
727 libc::c_longlong,
728 ) -> ssize_t,
729 >,
730 pub sync_readline: Option::<
731 unsafe extern "C" fn(
732 *mut connection,
733 *mut libc::c_char,
734 ssize_t,
735 libc::c_longlong,
736 ) -> ssize_t,
737 >,
738 pub get_type: Option::<unsafe extern "C" fn(*mut connection) -> libc::c_int>,
739}
740#[derive(Copy, Clone)]
741#[repr(C)]
742pub struct _rio {
743 pub read: Option::<
744 unsafe extern "C" fn(*mut _rio, *mut libc::c_void, size_t) -> size_t,
745 >,
746 pub write: Option::<
747 unsafe extern "C" fn(*mut _rio, *const libc::c_void, size_t) -> size_t,
748 >,
749 pub tell: Option::<unsafe extern "C" fn(*mut _rio) -> off_t>,
750 pub flush: Option::<unsafe extern "C" fn(*mut _rio) -> libc::c_int>,
751 pub update_cksum: Option::<
752 unsafe extern "C" fn(*mut _rio, *const libc::c_void, size_t) -> (),
753 >,
754 pub cksum: uint64_t,
755 pub flags: uint64_t,
756 pub processed_bytes: size_t,
757 pub max_processing_chunk: size_t,
758 pub io: C2RustUnnamed,
759}
760#[derive(Copy, Clone)]
761#[repr(C)]
762pub union C2RustUnnamed {
763 pub buffer: C2RustUnnamed_3,
764 pub file: C2RustUnnamed_2,
765 pub conn: C2RustUnnamed_1,
766 pub fd: C2RustUnnamed_0,
767}
768#[derive(Copy, Clone)]
769#[repr(C)]
770pub struct C2RustUnnamed_0 {
771 pub fd: libc::c_int,
772 pub pos: off_t,
773 pub buf: sds,
774}
775#[derive(Copy, Clone)]
776#[repr(C)]
777pub struct C2RustUnnamed_1 {
778 pub conn: *mut connection,
779 pub pos: off_t,
780 pub buf: sds,
781 pub read_limit: size_t,
782 pub read_so_far: size_t,
783}
784#[derive(Copy, Clone)]
785#[repr(C)]
786pub struct C2RustUnnamed_2 {
787 pub fp: *mut FILE,
788 pub buffered: off_t,
789 pub autosync: off_t,
790}
791#[derive(Copy, Clone)]
792#[repr(C)]
793pub struct C2RustUnnamed_3 {
794 pub ptr: sds,
795 pub pos: off_t,
796}
797pub type rio = _rio;
798#[derive(Copy, Clone,c2rust_bitfields::BitfieldStruct)]
799#[repr(C)]
800pub struct redisObject {
801 #[bitfield(name = "type_0", ty = "libc::c_uint", bits = "0..=3")]
802 #[bitfield(name = "encoding", ty = "libc::c_uint", bits = "4..=7")]
803 #[bitfield(name = "lru", ty = "libc::c_uint", bits = "8..=31")]
804 pub type_0_encoding_lru: [u8; 4],
805 pub refcount: libc::c_int,
806 pub ptr: *mut libc::c_void,
807}
808pub type memory_order = libc::c_uint;
809pub const memory_order_seq_cst: memory_order = 5;
810pub const memory_order_acq_rel: memory_order = 4;
811pub const memory_order_release: memory_order = 3;
812pub const memory_order_acquire: memory_order = 2;
813pub const memory_order_consume: memory_order = 1;
814pub const memory_order_relaxed: memory_order = 0;
815pub type atomic_int = libc::c_int;
816pub type atomic_uint = libc::c_uint;
817pub type atomic_llong = libc::c_longlong;
818pub type sig_atomic_t = __sig_atomic_t;
819#[derive(Copy, Clone)]
820#[repr(C)]
821pub struct hdr_histogram {
822 pub lowest_discernible_value: int64_t,
823 pub highest_trackable_value: int64_t,
824 pub unit_magnitude: int32_t,
825 pub significant_figures: int32_t,
826 pub sub_bucket_half_count_magnitude: int32_t,
827 pub sub_bucket_half_count: int32_t,
828 pub sub_bucket_mask: int64_t,
829 pub sub_bucket_count: int32_t,
830 pub bucket_count: int32_t,
831 pub min_value: int64_t,
832 pub max_value: int64_t,
833 pub normalizing_index_offset: int32_t,
834 pub conversion_ratio: libc::c_double,
835 pub counts_len: int32_t,
836 pub total_count: int64_t,
837 pub counts: *mut int64_t,
838}
839pub type mstime_t = libc::c_longlong;
840pub type ustime_t = libc::c_longlong;
841#[derive(Copy, Clone)]
842#[repr(C)]
843pub struct dictEntry {
844 pub key: *mut libc::c_void,
845 pub v: C2RustUnnamed_4,
846 pub next: *mut dictEntry,
847 pub metadata: [*mut libc::c_void; 0],
848}
849#[derive(Copy, Clone)]
850#[repr(C)]
851pub union C2RustUnnamed_4 {
852 pub val: *mut libc::c_void,
853 pub u64_0: uint64_t,
854 pub s64: int64_t,
855 pub d: libc::c_double,
856}
857#[derive(Copy, Clone)]
858#[repr(C)]
859pub struct dict {
860 pub type_0: *mut dictType,
861 pub ht_table: [*mut *mut dictEntry; 2],
862 pub ht_used: [libc::c_ulong; 2],
863 pub rehashidx: libc::c_long,
864 pub pauserehash: int16_t,
865 pub ht_size_exp: [libc::c_schar; 2],
866}
867#[derive(Copy, Clone)]
868#[repr(C)]
869pub struct dictType {
870 pub hashFunction: Option::<unsafe extern "C" fn(*const libc::c_void) -> uint64_t>,
871 pub keyDup: Option::<
872 unsafe extern "C" fn(*mut dict, *const libc::c_void) -> *mut libc::c_void,
873 >,
874 pub valDup: Option::<
875 unsafe extern "C" fn(*mut dict, *const libc::c_void) -> *mut libc::c_void,
876 >,
877 pub keyCompare: Option::<
878 unsafe extern "C" fn(
879 *mut dict,
880 *const libc::c_void,
881 *const libc::c_void,
882 ) -> libc::c_int,
883 >,
884 pub keyDestructor: Option::<
885 unsafe extern "C" fn(*mut dict, *mut libc::c_void) -> (),
886 >,
887 pub valDestructor: Option::<
888 unsafe extern "C" fn(*mut dict, *mut libc::c_void) -> (),
889 >,
890 pub expandAllowed: Option::<
891 unsafe extern "C" fn(size_t, libc::c_double) -> libc::c_int,
892 >,
893 pub dictEntryMetadataBytes: Option::<unsafe extern "C" fn(*mut dict) -> size_t>,
894}
895#[derive(Copy, Clone)]
896#[repr(C)]
897pub struct dictIterator {
898 pub d: *mut dict,
899 pub index: libc::c_long,
900 pub table: libc::c_int,
901 pub safe: libc::c_int,
902 pub entry: *mut dictEntry,
903 pub nextEntry: *mut dictEntry,
904 pub fingerprint: libc::c_ulonglong,
905}
906#[derive(Copy, Clone)]
907#[repr(C)]
908pub struct listNode {
909 pub prev: *mut listNode,
910 pub next: *mut listNode,
911 pub value: *mut libc::c_void,
912}
913#[derive(Copy, Clone)]
914#[repr(C)]
915pub struct listIter {
916 pub next: *mut listNode,
917 pub direction: libc::c_int,
918}
919#[derive(Copy, Clone)]
920#[repr(C)]
921pub struct list {
922 pub head: *mut listNode,
923 pub tail: *mut listNode,
924 pub dup: Option::<unsafe extern "C" fn(*mut libc::c_void) -> *mut libc::c_void>,
925 pub free: Option::<unsafe extern "C" fn(*mut libc::c_void) -> ()>,
926 pub match_0: Option::<
927 unsafe extern "C" fn(*mut libc::c_void, *mut libc::c_void) -> libc::c_int,
928 >,
929 pub len: libc::c_ulong,
930}
931#[derive(Copy, Clone)]
932#[repr(C)]
933pub struct intset {
934 pub encoding: uint32_t,
935 pub length: uint32_t,
936 pub contents: [int8_t; 0],
937}
938#[derive(Copy, Clone,c2rust_bitfields:: BitfieldStruct)]
939#[repr(C)]
940pub struct quicklistNode {
941 pub prev: *mut quicklistNode,
942 pub next: *mut quicklistNode,
943 pub entry: *mut libc::c_uchar,
944 pub sz: size_t,
945 #[bitfield(name = "count", ty = "libc::c_uint", bits = "0..=15")]
946 #[bitfield(name = "encoding", ty = "libc::c_uint", bits = "16..=17")]
947 #[bitfield(name = "container", ty = "libc::c_uint", bits = "18..=19")]
948 #[bitfield(name = "recompress", ty = "libc::c_uint", bits = "20..=20")]
949 #[bitfield(name = "attempted_compress", ty = "libc::c_uint", bits = "21..=21")]
950 #[bitfield(name = "dont_compress", ty = "libc::c_uint", bits = "22..=22")]
951 #[bitfield(name = "extra", ty = "libc::c_uint", bits = "23..=31")]
952 pub count_encoding_container_recompress_attempted_compress_dont_compress_extra: [u8; 4],
953 #[bitfield(padding)]
954 pub c2rust_padding: [u8; 4],
955}
956#[derive(Copy, Clone)]
957#[repr(C)]
958pub struct quicklistBookmark {
959 pub node: *mut quicklistNode,
960 pub name: *mut libc::c_char,
961}
962#[derive(Copy, Clone,c2rust_bitfields:: BitfieldStruct)]
963#[repr(C)]
964pub struct quicklist {
965 pub head: *mut quicklistNode,
966 pub tail: *mut quicklistNode,
967 pub count: libc::c_ulong,
968 pub len: libc::c_ulong,
969 #[bitfield(name = "fill", ty = "libc::c_int", bits = "0..=15")]
970 #[bitfield(name = "compress", ty = "libc::c_uint", bits = "16..=31")]
971 #[bitfield(name = "bookmark_count", ty = "libc::c_uint", bits = "32..=35")]
972 pub fill_compress_bookmark_count: [u8; 5],
973 #[bitfield(padding)]
974 pub c2rust_padding: [u8; 3],
975 pub bookmarks: [quicklistBookmark; 0],
976}
977#[derive(Copy, Clone,c2rust_bitfields:: BitfieldStruct)]
978#[repr(C)]
979pub struct raxNode {
980 #[bitfield(name = "iskey", ty = "uint32_t", bits = "0..=0")]
981 #[bitfield(name = "isnull", ty = "uint32_t", bits = "1..=1")]
982 #[bitfield(name = "iscompr", ty = "uint32_t", bits = "2..=2")]
983 #[bitfield(name = "size", ty = "uint32_t", bits = "3..=31")]
984 pub iskey_isnull_iscompr_size: [u8; 4],
985 pub data: [libc::c_uchar; 0],
986}
987#[derive(Copy, Clone)]
988#[repr(C)]
989pub struct rax {
990 pub head: *mut raxNode,
991 pub numele: uint64_t,
992 pub numnodes: uint64_t,
993}
994#[derive(Copy, Clone)]
995#[repr(C)]
996pub struct raxStack {
997 pub stack: *mut *mut libc::c_void,
998 pub items: size_t,
999 pub maxitems: size_t,
1000 pub static_items: [*mut libc::c_void; 32],
1001 pub oom: libc::c_int,
1002}
1003pub type raxNodeCallback = Option::<
1004 unsafe extern "C" fn(*mut *mut raxNode) -> libc::c_int,
1005>;
1006#[derive(Copy, Clone)]
1007#[repr(C)]
1008pub struct raxIterator {
1009 pub flags: libc::c_int,
1010 pub rt: *mut rax,
1011 pub key: *mut libc::c_uchar,
1012 pub data: *mut libc::c_void,
1013 pub key_len: size_t,
1014 pub key_max: size_t,
1015 pub key_static_string: [libc::c_uchar; 128],
1016 pub node: *mut raxNode,
1017 pub stack: raxStack,
1018 pub node_cb: raxNodeCallback,
1019}
1020pub type ziplistValidateEntryCB = Option::<
1021 unsafe extern "C" fn(
1022 *mut libc::c_uchar,
1023 libc::c_uint,
1024 *mut libc::c_void,
1025 ) -> libc::c_int,
1026>;
1027pub type C2RustUnnamed_5 = libc::c_uint;
1028pub const REPL_STATE_CONNECTED: C2RustUnnamed_5 = 12;
1029pub const REPL_STATE_TRANSFER: C2RustUnnamed_5 = 11;
1030pub const REPL_STATE_RECEIVE_PSYNC_REPLY: C2RustUnnamed_5 = 10;
1031pub const REPL_STATE_SEND_PSYNC: C2RustUnnamed_5 = 9;
1032pub const REPL_STATE_RECEIVE_CAPA_REPLY: C2RustUnnamed_5 = 8;
1033pub const REPL_STATE_RECEIVE_IP_REPLY: C2RustUnnamed_5 = 7;
1034pub const REPL_STATE_RECEIVE_PORT_REPLY: C2RustUnnamed_5 = 6;
1035pub const REPL_STATE_RECEIVE_AUTH_REPLY: C2RustUnnamed_5 = 5;
1036pub const REPL_STATE_SEND_HANDSHAKE: C2RustUnnamed_5 = 4;
1037pub const REPL_STATE_RECEIVE_PING_REPLY: C2RustUnnamed_5 = 3;
1038pub const REPL_STATE_CONNECTING: C2RustUnnamed_5 = 2;
1039pub const REPL_STATE_CONNECT: C2RustUnnamed_5 = 1;
1040pub const REPL_STATE_NONE: C2RustUnnamed_5 = 0;
1041pub type pause_type = libc::c_uint;
1042pub const CLIENT_PAUSE_ALL: pause_type = 2;
1043pub const CLIENT_PAUSE_WRITE: pause_type = 1;
1044pub const CLIENT_PAUSE_OFF: pause_type = 0;
1045#[derive(Copy, Clone)]
1046#[repr(C)]
1047pub struct pause_event {
1048 pub type_0: pause_type,
1049 pub end: mstime_t,
1050}
1051#[derive(Copy, Clone)]
1052#[repr(C)]
1053pub struct RedisModule {
1054 pub handle: *mut libc::c_void,
1055 pub name: *mut libc::c_char,
1056 pub ver: libc::c_int,
1057 pub apiver: libc::c_int,
1058 pub types: *mut list,
1059 pub usedby: *mut list,
1060 pub using: *mut list,
1061 pub filters: *mut list,
1062 pub module_configs: *mut list,
1063 pub configs_initialized: libc::c_int,
1064 pub in_call: libc::c_int,
1065 pub in_hook: libc::c_int,
1066 pub options: libc::c_int,
1067 pub blocked_clients: libc::c_int,
1068 pub info_cb: RedisModuleInfoFunc,
1069 pub defrag_cb: RedisModuleDefragFunc,
1070 pub loadmod: *mut moduleLoadQueueEntry,
1071}
1072#[derive(Copy, Clone)]
1073#[repr(C)]
1074pub struct moduleLoadQueueEntry {
1075 pub path: sds,
1076 pub argc: libc::c_int,
1077 pub argv: *mut *mut robj,
1078}
1079pub type robj = redisObject;
1080pub type RedisModuleDefragFunc = Option::<
1081 unsafe extern "C" fn(*mut RedisModuleDefragCtx) -> (),
1082>;
1083pub type RedisModuleInfoFunc = Option::<
1084 unsafe extern "C" fn(*mut RedisModuleInfoCtx, libc::c_int) -> (),
1085>;
1086#[derive(Copy, Clone)]
1087#[repr(C)]
1088pub struct RedisModuleIO {
1089 pub bytes: size_t,
1090 pub rio: *mut rio,
1091 pub type_0: *mut moduleType,
1092 pub error: libc::c_int,
1093 pub ver: libc::c_int,
1094 pub ctx: *mut RedisModuleCtx,
1095 pub key: *mut redisObject,
1096 pub dbid: libc::c_int,
1097}
1098pub type moduleType = RedisModuleType;
1099#[derive(Copy, Clone)]
1100#[repr(C)]
1101pub struct RedisModuleType {
1102 pub id: uint64_t,
1103 pub module: *mut RedisModule,
1104 pub rdb_load: moduleTypeLoadFunc,
1105 pub rdb_save: moduleTypeSaveFunc,
1106 pub aof_rewrite: moduleTypeRewriteFunc,
1107 pub mem_usage: moduleTypeMemUsageFunc,
1108 pub digest: moduleTypeDigestFunc,
1109 pub free: moduleTypeFreeFunc,
1110 pub free_effort: moduleTypeFreeEffortFunc,
1111 pub unlink: moduleTypeUnlinkFunc,
1112 pub copy: moduleTypeCopyFunc,
1113 pub defrag: moduleTypeDefragFunc,
1114 pub aux_load: moduleTypeAuxLoadFunc,
1115 pub aux_save: moduleTypeAuxSaveFunc,
1116 pub mem_usage2: moduleTypeMemUsageFunc2,
1117 pub free_effort2: moduleTypeFreeEffortFunc2,
1118 pub unlink2: moduleTypeUnlinkFunc2,
1119 pub copy2: moduleTypeCopyFunc2,
1120 pub aux_save_triggers: libc::c_int,
1121 pub name: [libc::c_char; 10],
1122}
1123pub type moduleTypeCopyFunc2 = Option::<
1124 unsafe extern "C" fn(
1125 *mut RedisModuleKeyOptCtx,
1126 *const libc::c_void,
1127 ) -> *mut libc::c_void,
1128>;
1129pub type moduleTypeUnlinkFunc2 = Option::<
1130 unsafe extern "C" fn(*mut RedisModuleKeyOptCtx, *mut libc::c_void) -> (),
1131>;
1132pub type moduleTypeFreeEffortFunc2 = Option::<
1133 unsafe extern "C" fn(*mut RedisModuleKeyOptCtx, *const libc::c_void) -> size_t,
1134>;
1135pub type moduleTypeMemUsageFunc2 = Option::<
1136 unsafe extern "C" fn(
1137 *mut RedisModuleKeyOptCtx,
1138 *const libc::c_void,
1139 size_t,
1140 ) -> size_t,
1141>;
1142pub type moduleTypeAuxSaveFunc = Option::<
1143 unsafe extern "C" fn(*mut RedisModuleIO, libc::c_int) -> (),
1144>;
1145pub type moduleTypeAuxLoadFunc = Option::<
1146 unsafe extern "C" fn(*mut RedisModuleIO, libc::c_int, libc::c_int) -> libc::c_int,
1147>;
1148pub type moduleTypeDefragFunc = Option::<
1149 unsafe extern "C" fn(
1150 *mut RedisModuleDefragCtx,
1151 *mut redisObject,
1152 *mut *mut libc::c_void,
1153 ) -> libc::c_int,
1154>;
1155pub type moduleTypeCopyFunc = Option::<
1156 unsafe extern "C" fn(
1157 *mut redisObject,
1158 *mut redisObject,
1159 *const libc::c_void,
1160 ) -> *mut libc::c_void,
1161>;
1162pub type moduleTypeUnlinkFunc = Option::<
1163 unsafe extern "C" fn(*mut redisObject, *mut libc::c_void) -> (),
1164>;
1165pub type moduleTypeFreeEffortFunc = Option::<
1166 unsafe extern "C" fn(*mut redisObject, *const libc::c_void) -> size_t,
1167>;
1168pub type moduleTypeFreeFunc = Option::<unsafe extern "C" fn(*mut libc::c_void) -> ()>;
1169pub type moduleTypeDigestFunc = Option::<
1170 unsafe extern "C" fn(*mut RedisModuleDigest, *mut libc::c_void) -> (),
1171>;
1172#[derive(Copy, Clone)]
1173#[repr(C)]
1174pub struct RedisModuleDigest {
1175 pub o: [libc::c_uchar; 20],
1176 pub x: [libc::c_uchar; 20],
1177 pub key: *mut redisObject,
1178 pub dbid: libc::c_int,
1179}
1180pub type moduleTypeMemUsageFunc = Option::<
1181 unsafe extern "C" fn(*const libc::c_void) -> size_t,
1182>;
1183pub type moduleTypeRewriteFunc = Option::<
1184 unsafe extern "C" fn(*mut RedisModuleIO, *mut redisObject, *mut libc::c_void) -> (),
1185>;
1186pub type moduleTypeSaveFunc = Option::<
1187 unsafe extern "C" fn(*mut RedisModuleIO, *mut libc::c_void) -> (),
1188>;
1189pub type moduleTypeLoadFunc = Option::<
1190 unsafe extern "C" fn(*mut RedisModuleIO, libc::c_int) -> *mut libc::c_void,
1191>;
1192pub type RedisModuleUserChangedFunc = Option::<
1193 unsafe extern "C" fn(uint64_t, *mut libc::c_void) -> (),
1194>;
1195#[derive(Copy, Clone)]
1196#[repr(C)]
1197pub struct moduleValue {
1198 pub type_0: *mut moduleType,
1199 pub value: *mut libc::c_void,
1200}
1201#[derive(Copy, Clone)]
1202#[repr(C)]
1203pub struct redisDb {
1204 pub dict: *mut dict,
1205 pub expires: *mut dict,
1206 pub blocking_keys: *mut dict,
1207 pub ready_keys: *mut dict,
1208 pub watched_keys: *mut dict,
1209 pub id: libc::c_int,
1210 pub avg_ttl: libc::c_longlong,
1211 pub expires_cursor: libc::c_ulong,
1212 pub defrag_later: *mut list,
1213 pub slots_to_keys: *mut clusterSlotToKeyMapping,
1214}
1215#[derive(Copy, Clone)]
1216#[repr(C)]
1217pub struct rdbLoadingCtx {
1218 pub dbarray: *mut redisDb,
1219 pub functions_lib_ctx: *mut functionsLibCtx,
1220}
1221#[derive(Copy, Clone)]
1222#[repr(C)]
1223pub struct multiCmd {
1224 pub argv: *mut *mut robj,
1225 pub argv_len: libc::c_int,
1226 pub argc: libc::c_int,
1227 pub cmd: *mut redisCommand,
1228}
1229#[derive(Copy, Clone)]
1230#[repr(C)]
1231pub struct redisCommand {
1232 pub declared_name: *const libc::c_char,
1233 pub summary: *const libc::c_char,
1234 pub complexity: *const libc::c_char,
1235 pub since: *const libc::c_char,
1236 pub doc_flags: libc::c_int,
1237 pub replaced_by: *const libc::c_char,
1238 pub deprecated_since: *const libc::c_char,
1239 pub group: redisCommandGroup,
1240 pub history: *mut commandHistory,
1241 pub tips: *mut *const libc::c_char,
1242 pub proc_0: Option::<redisCommandProc>,
1243 pub arity: libc::c_int,
1244 pub flags: uint64_t,
1245 pub acl_categories: uint64_t,
1246 pub key_specs_static: [keySpec; 4],
1247 pub getkeys_proc: Option::<redisGetKeysProc>,
1248 pub subcommands: *mut redisCommand,
1249 pub args: *mut redisCommandArg,
1250 pub microseconds: libc::c_longlong,
1251 pub calls: libc::c_longlong,
1252 pub rejected_calls: libc::c_longlong,
1253 pub failed_calls: libc::c_longlong,
1254 pub id: libc::c_int,
1255 pub fullname: sds,
1256 pub latency_histogram: *mut hdr_histogram,
1257 pub key_specs: *mut keySpec,
1258 pub legacy_range_key_spec: keySpec,
1259 pub num_args: libc::c_int,
1260 pub num_history: libc::c_int,
1261 pub num_tips: libc::c_int,
1262 pub key_specs_num: libc::c_int,
1263 pub key_specs_max: libc::c_int,
1264 pub subcommands_dict: *mut dict,
1265 pub parent: *mut redisCommand,
1266 pub module_cmd: *mut RedisModuleCommand,
1267}
1268#[derive(Copy, Clone)]
1269#[repr(C)]
1270pub struct keySpec {
1271 pub notes: *const libc::c_char,
1272 pub flags: uint64_t,
1273 pub begin_search_type: kspec_bs_type,
1274 pub bs: C2RustUnnamed_9,
1275 pub find_keys_type: kspec_fk_type,
1276 pub fk: C2RustUnnamed_6,
1277}
1278#[derive(Copy, Clone)]
1279#[repr(C)]
1280pub union C2RustUnnamed_6 {
1281 pub range: C2RustUnnamed_8,
1282 pub keynum: C2RustUnnamed_7,
1283}
1284#[derive(Copy, Clone)]
1285#[repr(C)]
1286pub struct C2RustUnnamed_7 {
1287 pub keynumidx: libc::c_int,
1288 pub firstkey: libc::c_int,
1289 pub keystep: libc::c_int,
1290}
1291#[derive(Copy, Clone)]
1292#[repr(C)]
1293pub struct C2RustUnnamed_8 {
1294 pub lastkey: libc::c_int,
1295 pub keystep: libc::c_int,
1296 pub limit: libc::c_int,
1297}
1298pub type kspec_fk_type = libc::c_uint;
1299pub const KSPEC_FK_KEYNUM: kspec_fk_type = 3;
1300pub const KSPEC_FK_RANGE: kspec_fk_type = 2;
1301pub const KSPEC_FK_UNKNOWN: kspec_fk_type = 1;
1302pub const KSPEC_FK_INVALID: kspec_fk_type = 0;
1303#[derive(Copy, Clone)]
1304#[repr(C)]
1305pub union C2RustUnnamed_9 {
1306 pub index: C2RustUnnamed_11,
1307 pub keyword: C2RustUnnamed_10,
1308}
1309#[derive(Copy, Clone)]
1310#[repr(C)]
1311pub struct C2RustUnnamed_10 {
1312 pub keyword: *const libc::c_char,
1313 pub startfrom: libc::c_int,
1314}
1315#[derive(Copy, Clone)]
1316#[repr(C)]
1317pub struct C2RustUnnamed_11 {
1318 pub pos: libc::c_int,
1319}
1320pub type kspec_bs_type = libc::c_uint;
1321pub const KSPEC_BS_KEYWORD: kspec_bs_type = 3;
1322pub const KSPEC_BS_INDEX: kspec_bs_type = 2;
1323pub const KSPEC_BS_UNKNOWN: kspec_bs_type = 1;
1324pub const KSPEC_BS_INVALID: kspec_bs_type = 0;
1325#[derive(Copy, Clone)]
1326#[repr(C)]
1327pub struct redisCommandArg {
1328 pub name: *const libc::c_char,
1329 pub type_0: redisCommandArgType,
1330 pub key_spec_index: libc::c_int,
1331 pub token: *const libc::c_char,
1332 pub summary: *const libc::c_char,
1333 pub since: *const libc::c_char,
1334 pub flags: libc::c_int,
1335 pub deprecated_since: *const libc::c_char,
1336 pub subargs: *mut redisCommandArg,
1337 pub num_args: libc::c_int,
1338}
1339pub type redisCommandArgType = libc::c_uint;
1340pub const ARG_TYPE_BLOCK: redisCommandArgType = 8;
1341pub const ARG_TYPE_ONEOF: redisCommandArgType = 7;
1342pub const ARG_TYPE_PURE_TOKEN: redisCommandArgType = 6;
1343pub const ARG_TYPE_UNIX_TIME: redisCommandArgType = 5;
1344pub const ARG_TYPE_PATTERN: redisCommandArgType = 4;
1345pub const ARG_TYPE_KEY: redisCommandArgType = 3;
1346pub const ARG_TYPE_DOUBLE: redisCommandArgType = 2;
1347pub const ARG_TYPE_INTEGER: redisCommandArgType = 1;
1348pub const ARG_TYPE_STRING: redisCommandArgType = 0;
1349pub type redisGetKeysProc = unsafe extern "C" fn(
1350 *mut redisCommand,
1351 *mut *mut robj,
1352 libc::c_int,
1353 *mut getKeysResult,
1354) -> libc::c_int;
1355#[derive(Copy, Clone)]
1356#[repr(C)]
1357pub struct getKeysResult {
1358 pub keysbuf: [keyReference; 256],
1359 pub keys: *mut keyReference,
1360 pub numkeys: libc::c_int,
1361 pub size: libc::c_int,
1362}
1363#[derive(Copy, Clone)]
1364#[repr(C)]
1365pub struct keyReference {
1366 pub pos: libc::c_int,
1367 pub flags: libc::c_int,
1368}
1369pub type redisCommandProc = unsafe extern "C" fn(*mut client) -> ();
1370#[derive(Copy, Clone)]
1371#[repr(C)]
1372pub struct client {
1373 pub id: uint64_t,
1374 pub flags: uint64_t,
1375 pub conn: *mut connection,
1376 pub resp: libc::c_int,
1377 pub db: *mut redisDb,
1378 pub name: *mut robj,
1379 pub querybuf: sds,
1380 pub qb_pos: size_t,
1381 pub querybuf_peak: size_t,
1382 pub argc: libc::c_int,
1383 pub argv: *mut *mut robj,
1384 pub argv_len: libc::c_int,
1385 pub original_argc: libc::c_int,
1386 pub original_argv: *mut *mut robj,
1387 pub argv_len_sum: size_t,
1388 pub cmd: *mut redisCommand,
1389 pub lastcmd: *mut redisCommand,
1390 pub realcmd: *mut redisCommand,
1391 pub user: *mut user,
1392 pub reqtype: libc::c_int,
1393 pub multibulklen: libc::c_int,
1394 pub bulklen: libc::c_long,
1395 pub reply: *mut list,
1396 pub reply_bytes: libc::c_ulonglong,
1397 pub deferred_reply_errors: *mut list,
1398 pub sentlen: size_t,
1399 pub ctime: time_t,
1400 pub duration: libc::c_long,
1401 pub slot: libc::c_int,
1402 pub cur_script: *mut dictEntry,
1403 pub lastinteraction: time_t,
1404 pub obuf_soft_limit_reached_time: time_t,
1405 pub authenticated: libc::c_int,
1406 pub replstate: libc::c_int,
1407 pub repl_start_cmd_stream_on_ack: libc::c_int,
1408 pub repldbfd: libc::c_int,
1409 pub repldboff: off_t,
1410 pub repldbsize: off_t,
1411 pub replpreamble: sds,
1412 pub read_reploff: libc::c_longlong,
1413 pub reploff: libc::c_longlong,
1414 pub repl_applied: libc::c_longlong,
1415 pub repl_ack_off: libc::c_longlong,
1416 pub repl_ack_time: libc::c_longlong,
1417 pub repl_last_partial_write: libc::c_longlong,
1418 pub psync_initial_offset: libc::c_longlong,
1419 pub replid: [libc::c_char; 41],
1420 pub slave_listening_port: libc::c_int,
1421 pub slave_addr: *mut libc::c_char,
1422 pub slave_capa: libc::c_int,
1423 pub slave_req: libc::c_int,
1424 pub mstate: multiState,
1425 pub btype: libc::c_int,
1426 pub bpop: blockingState,
1427 pub woff: libc::c_longlong,
1428 pub watched_keys: *mut list,
1429 pub pubsub_channels: *mut dict,
1430 pub pubsub_patterns: *mut list,
1431 pub pubsubshard_channels: *mut dict,
1432 pub peerid: sds,
1433 pub sockname: sds,
1434 pub client_list_node: *mut listNode,
1435 pub postponed_list_node: *mut listNode,
1436 pub pending_read_list_node: *mut listNode,
1437 pub auth_callback: RedisModuleUserChangedFunc,
1438 pub auth_callback_privdata: *mut libc::c_void,
1439 pub auth_module: *mut libc::c_void,
1440 pub client_tracking_redirection: uint64_t,
1441 pub client_tracking_prefixes: *mut rax,
1442 pub last_memory_usage: size_t,
1443 pub last_memory_type: libc::c_int,
1444 pub mem_usage_bucket_node: *mut listNode,
1445 pub mem_usage_bucket: *mut clientMemUsageBucket,
1446 pub ref_repl_buf_node: *mut listNode,
1447 pub ref_block_pos: size_t,
1448 pub buf_peak: size_t,
1449 pub buf_peak_last_reset_time: mstime_t,
1450 pub bufpos: libc::c_int,
1451 pub buf_usable_size: size_t,
1452 pub buf: *mut libc::c_char,
1453}
1454#[derive(Copy, Clone)]
1455#[repr(C)]
1456pub struct clientMemUsageBucket {
1457 pub clients: *mut list,
1458 pub mem_usage_sum: size_t,
1459}
1460#[derive(Copy, Clone)]
1461#[repr(C)]
1462pub struct blockingState {
1463 pub count: libc::c_long,
1464 pub timeout: mstime_t,
1465 pub keys: *mut dict,
1466 pub target: *mut robj,
1467 pub blockpos: blockPos,
1468 pub xread_count: size_t,
1469 pub xread_group: *mut robj,
1470 pub xread_consumer: *mut robj,
1471 pub xread_group_noack: libc::c_int,
1472 pub numreplicas: libc::c_int,
1473 pub reploffset: libc::c_longlong,
1474 pub module_blocked_handle: *mut libc::c_void,
1475}
1476#[derive(Copy, Clone)]
1477#[repr(C)]
1478pub struct blockPos {
1479 pub wherefrom: libc::c_int,
1480 pub whereto: libc::c_int,
1481}
1482#[derive(Copy, Clone)]
1483#[repr(C)]
1484pub struct multiState {
1485 pub commands: *mut multiCmd,
1486 pub count: libc::c_int,
1487 pub cmd_flags: libc::c_int,
1488 pub cmd_inv_flags: libc::c_int,
1489 pub argv_len_sums: size_t,
1490 pub alloc_count: libc::c_int,
1491}
1492#[derive(Copy, Clone)]
1493#[repr(C)]
1494pub struct user {
1495 pub name: sds,
1496 pub flags: uint32_t,
1497 pub passwords: *mut list,
1498 pub selectors: *mut list,
1499 pub acl_string: *mut robj,
1500}
1501#[derive(Copy, Clone)]
1502#[repr(C)]
1503pub struct commandHistory {
1504 pub since: *const libc::c_char,
1505 pub changes: *const libc::c_char,
1506}
1507pub type redisCommandGroup = libc::c_uint;
1508pub const COMMAND_GROUP_MODULE: redisCommandGroup = 17;
1509pub const COMMAND_GROUP_BITMAP: redisCommandGroup = 16;
1510pub const COMMAND_GROUP_STREAM: redisCommandGroup = 15;
1511pub const COMMAND_GROUP_GEO: redisCommandGroup = 14;
1512pub const COMMAND_GROUP_SENTINEL: redisCommandGroup = 13;
1513pub const COMMAND_GROUP_CLUSTER: redisCommandGroup = 12;
1514pub const COMMAND_GROUP_HYPERLOGLOG: redisCommandGroup = 11;
1515pub const COMMAND_GROUP_SCRIPTING: redisCommandGroup = 10;
1516pub const COMMAND_GROUP_SERVER: redisCommandGroup = 9;
1517pub const COMMAND_GROUP_CONNECTION: redisCommandGroup = 8;
1518pub const COMMAND_GROUP_TRANSACTIONS: redisCommandGroup = 7;
1519pub const COMMAND_GROUP_PUBSUB: redisCommandGroup = 6;
1520pub const COMMAND_GROUP_HASH: redisCommandGroup = 5;
1521pub const COMMAND_GROUP_SORTED_SET: redisCommandGroup = 4;
1522pub const COMMAND_GROUP_SET: redisCommandGroup = 3;
1523pub const COMMAND_GROUP_LIST: redisCommandGroup = 2;
1524pub const COMMAND_GROUP_STRING: redisCommandGroup = 1;
1525pub const COMMAND_GROUP_GENERIC: redisCommandGroup = 0;
1526#[derive(Copy, Clone)]
1527#[repr(C)]
1528pub struct replBacklog {
1529 pub ref_repl_buf_node: *mut listNode,
1530 pub unindexed_count: size_t,
1531 pub blocks_index: *mut rax,
1532 pub histlen: libc::c_longlong,
1533 pub offset: libc::c_longlong,
1534}
1535#[derive(Copy, Clone)]
1536#[repr(C)]
1537pub struct saveparam {
1538 pub seconds: time_t,
1539 pub changes: libc::c_int,
1540}
1541#[derive(Copy, Clone)]
1542#[repr(C)]
1543pub struct sentinelConfig {
1544 pub pre_monitor_cfg: *mut list,
1545 pub monitor_cfg: *mut list,
1546 pub post_monitor_cfg: *mut list,
1547}
1548#[derive(Copy, Clone)]
1549#[repr(C)]
1550pub struct sharedObjectsStruct {
1551 pub crlf: *mut robj,
1552 pub ok: *mut robj,
1553 pub err: *mut robj,
1554 pub emptybulk: *mut robj,
1555 pub czero: *mut robj,
1556 pub cone: *mut robj,
1557 pub pong: *mut robj,
1558 pub space: *mut robj,
1559 pub queued: *mut robj,
1560 pub null: [*mut robj; 4],
1561 pub nullarray: [*mut robj; 4],
1562 pub emptymap: [*mut robj; 4],
1563 pub emptyset: [*mut robj; 4],
1564 pub emptyarray: *mut robj,
1565 pub wrongtypeerr: *mut robj,
1566 pub nokeyerr: *mut robj,
1567 pub syntaxerr: *mut robj,
1568 pub sameobjecterr: *mut robj,
1569 pub outofrangeerr: *mut robj,
1570 pub noscripterr: *mut robj,
1571 pub loadingerr: *mut robj,
1572 pub slowevalerr: *mut robj,
1573 pub slowscripterr: *mut robj,
1574 pub slowmoduleerr: *mut robj,
1575 pub bgsaveerr: *mut robj,
1576 pub masterdownerr: *mut robj,
1577 pub roslaveerr: *mut robj,
1578 pub execaborterr: *mut robj,
1579 pub noautherr: *mut robj,
1580 pub noreplicaserr: *mut robj,
1581 pub busykeyerr: *mut robj,
1582 pub oomerr: *mut robj,
1583 pub plus: *mut robj,
1584 pub messagebulk: *mut robj,
1585 pub pmessagebulk: *mut robj,
1586 pub subscribebulk: *mut robj,
1587 pub unsubscribebulk: *mut robj,
1588 pub psubscribebulk: *mut robj,
1589 pub punsubscribebulk: *mut robj,
1590 pub del: *mut robj,
1591 pub unlink: *mut robj,
1592 pub rpop: *mut robj,
1593 pub lpop: *mut robj,
1594 pub lpush: *mut robj,
1595 pub rpoplpush: *mut robj,
1596 pub lmove: *mut robj,
1597 pub blmove: *mut robj,
1598 pub zpopmin: *mut robj,
1599 pub zpopmax: *mut robj,
1600 pub emptyscan: *mut robj,
1601 pub multi: *mut robj,
1602 pub exec: *mut robj,
1603 pub left: *mut robj,
1604 pub right: *mut robj,
1605 pub hset: *mut robj,
1606 pub srem: *mut robj,
1607 pub xgroup: *mut robj,
1608 pub xclaim: *mut robj,
1609 pub script: *mut robj,
1610 pub replconf: *mut robj,
1611 pub eval: *mut robj,
1612 pub persist: *mut robj,
1613 pub set: *mut robj,
1614 pub pexpireat: *mut robj,
1615 pub pexpire: *mut robj,
1616 pub time: *mut robj,
1617 pub pxat: *mut robj,
1618 pub absttl: *mut robj,
1619 pub retrycount: *mut robj,
1620 pub force: *mut robj,
1621 pub justid: *mut robj,
1622 pub entriesread: *mut robj,
1623 pub lastid: *mut robj,
1624 pub ping: *mut robj,
1625 pub setid: *mut robj,
1626 pub keepttl: *mut robj,
1627 pub load: *mut robj,
1628 pub createconsumer: *mut robj,
1629 pub getack: *mut robj,
1630 pub special_asterick: *mut robj,
1631 pub special_equals: *mut robj,
1632 pub default_username: *mut robj,
1633 pub redacted: *mut robj,
1634 pub ssubscribebulk: *mut robj,
1635 pub sunsubscribebulk: *mut robj,
1636 pub smessagebulk: *mut robj,
1637 pub select: [*mut robj; 10],
1638 pub integers: [*mut robj; 10000],
1639 pub mbulkhdr: [*mut robj; 32],
1640 pub bulkhdr: [*mut robj; 32],
1641 pub maphdr: [*mut robj; 32],
1642 pub sethdr: [*mut robj; 32],
1643 pub minstring: sds,
1644 pub maxstring: sds,
1645}
1646#[derive(Copy, Clone)]
1647#[repr(C)]
1648pub struct zskiplistNode {
1649 pub ele: sds,
1650 pub score: libc::c_double,
1651 pub backward: *mut zskiplistNode,
1652 pub level: [zskiplistLevel; 0],
1653}
1654#[derive(Copy, Clone)]
1655#[repr(C)]
1656pub struct zskiplistLevel {
1657 pub forward: *mut zskiplistNode,
1658 pub span: libc::c_ulong,
1659}
1660#[derive(Copy, Clone)]
1661#[repr(C)]
1662pub struct zskiplist {
1663 pub header: *mut zskiplistNode,
1664 pub tail: *mut zskiplistNode,
1665 pub length: libc::c_ulong,
1666 pub level: libc::c_int,
1667}
1668#[derive(Copy, Clone)]
1669#[repr(C)]
1670pub struct zset {
1671 pub dict: *mut dict,
1672 pub zsl: *mut zskiplist,
1673}
1674#[derive(Copy, Clone)]
1675#[repr(C)]
1676pub struct clientBufferLimitsConfig {
1677 pub hard_limit_bytes: libc::c_ulonglong,
1678 pub soft_limit_bytes: libc::c_ulonglong,
1679 pub soft_limit_seconds: time_t,
1680}
1681#[derive(Copy, Clone)]
1682#[repr(C)]
1683pub struct redisOp {
1684 pub argv: *mut *mut robj,
1685 pub argc: libc::c_int,
1686 pub dbid: libc::c_int,
1687 pub target: libc::c_int,
1688}
1689#[derive(Copy, Clone)]
1690#[repr(C)]
1691pub struct redisOpArray {
1692 pub ops: *mut redisOp,
1693 pub numops: libc::c_int,
1694 pub capacity: libc::c_int,
1695}
1696#[derive(Copy, Clone)]
1697#[repr(C)]
1698pub struct rdbSaveInfo {
1699 pub repl_stream_db: libc::c_int,
1700 pub repl_id_is_set: libc::c_int,
1701 pub repl_id: [libc::c_char; 41],
1702 pub repl_offset: libc::c_longlong,
1703}
1704#[derive(Copy, Clone)]
1705#[repr(C)]
1706pub struct malloc_stats {
1707 pub zmalloc_used: size_t,
1708 pub process_rss: size_t,
1709 pub allocator_allocated: size_t,
1710 pub allocator_active: size_t,
1711 pub allocator_resident: size_t,
1712}
1713#[derive(Copy, Clone)]
1714#[repr(C)]
1715pub struct socketFds {
1716 pub fd: [libc::c_int; 16],
1717 pub count: libc::c_int,
1718}
1719#[derive(Copy, Clone)]
1720#[repr(C)]
1721pub struct redisTLSContextConfig {
1722 pub cert_file: *mut libc::c_char,
1723 pub key_file: *mut libc::c_char,
1724 pub key_file_pass: *mut libc::c_char,
1725 pub client_cert_file: *mut libc::c_char,
1726 pub client_key_file: *mut libc::c_char,
1727 pub client_key_file_pass: *mut libc::c_char,
1728 pub dh_params_file: *mut libc::c_char,
1729 pub ca_cert_file: *mut libc::c_char,
1730 pub ca_cert_dir: *mut libc::c_char,
1731 pub protocols: *mut libc::c_char,
1732 pub ciphers: *mut libc::c_char,
1733 pub ciphersuites: *mut libc::c_char,
1734 pub prefer_server_ciphers: libc::c_int,
1735 pub session_caching: libc::c_int,
1736 pub session_cache_size: libc::c_int,
1737 pub session_cache_timeout: libc::c_int,
1738}
1739pub type aof_file_type = libc::c_uint;
1740pub const AOF_FILE_TYPE_INCR: aof_file_type = 105;
1741pub const AOF_FILE_TYPE_HIST: aof_file_type = 104;
1742pub const AOF_FILE_TYPE_BASE: aof_file_type = 98;
1743#[derive(Copy, Clone)]
1744#[repr(C)]
1745pub struct aofInfo {
1746 pub file_name: sds,
1747 pub file_seq: libc::c_longlong,
1748 pub file_type: aof_file_type,
1749}
1750#[derive(Copy, Clone)]
1751#[repr(C)]
1752pub struct aofManifest {
1753 pub base_aof_info: *mut aofInfo,
1754 pub incr_aof_list: *mut list,
1755 pub history_aof_list: *mut list,
1756 pub curr_base_file_seq: libc::c_longlong,
1757 pub curr_incr_file_seq: libc::c_longlong,
1758 pub dirty: libc::c_int,
1759}
1760pub type childInfoType = libc::c_uint;
1761pub const CHILD_INFO_TYPE_MODULE_COW_SIZE: childInfoType = 3;
1762pub const CHILD_INFO_TYPE_RDB_COW_SIZE: childInfoType = 2;
1763pub const CHILD_INFO_TYPE_AOF_COW_SIZE: childInfoType = 1;
1764pub const CHILD_INFO_TYPE_CURRENT_INFO: childInfoType = 0;
1765#[derive(Copy, Clone)]
1766#[repr(C)]
1767pub struct redisServer {
1768 pub pid: pid_t,
1769 pub main_thread_id: pthread_t,
1770 pub configfile: *mut libc::c_char,
1771 pub executable: *mut libc::c_char,
1772 pub exec_argv: *mut *mut libc::c_char,
1773 pub dynamic_hz: libc::c_int,
1774 pub config_hz: libc::c_int,
1775 pub umask: mode_t,
1776 pub hz: libc::c_int,
1777 pub in_fork_child: libc::c_int,
1778 pub db: *mut redisDb,
1779 pub commands: *mut dict,
1780 pub orig_commands: *mut dict,
1781 pub el: *mut aeEventLoop,
1782 pub errors: *mut rax,
1783 pub lruclock: atomic_uint,
1784 pub shutdown_asap: sig_atomic_t,
1785 pub shutdown_mstime: mstime_t,
1786 pub last_sig_received: libc::c_int,
1787 pub shutdown_flags: libc::c_int,
1788 pub activerehashing: libc::c_int,
1789 pub active_defrag_running: libc::c_int,
1790 pub pidfile: *mut libc::c_char,
1791 pub arch_bits: libc::c_int,
1792 pub cronloops: libc::c_int,
1793 pub runid: [libc::c_char; 41],
1794 pub sentinel_mode: libc::c_int,
1795 pub initial_memory_usage: size_t,
1796 pub always_show_logo: libc::c_int,
1797 pub in_exec: libc::c_int,
1798 pub busy_module_yield_flags: libc::c_int,
1799 pub busy_module_yield_reply: *const libc::c_char,
1800 pub core_propagates: libc::c_int,
1801 pub propagate_no_multi: libc::c_int,
1802 pub module_ctx_nesting: libc::c_int,
1803 pub ignore_warnings: *mut libc::c_char,
1804 pub client_pause_in_transaction: libc::c_int,
1805 pub thp_enabled: libc::c_int,
1806 pub page_size: size_t,
1807 pub moduleapi: *mut dict,
1808 pub sharedapi: *mut dict,
1809 pub module_configs_queue: *mut dict,
1810 pub loadmodule_queue: *mut list,
1811 pub module_pipe: [libc::c_int; 2],
1812 pub child_pid: pid_t,
1813 pub child_type: libc::c_int,
1814 pub port: libc::c_int,
1815 pub tls_port: libc::c_int,
1816 pub tcp_backlog: libc::c_int,
1817 pub bindaddr: [*mut libc::c_char; 16],
1818 pub bindaddr_count: libc::c_int,
1819 pub bind_source_addr: *mut libc::c_char,
1820 pub unixsocket: *mut libc::c_char,
1821 pub unixsocketperm: libc::c_uint,
1822 pub ipfd: socketFds,
1823 pub tlsfd: socketFds,
1824 pub sofd: libc::c_int,
1825 pub socket_mark_id: uint32_t,
1826 pub cfd: socketFds,
1827 pub clients: *mut list,
1828 pub clients_to_close: *mut list,
1829 pub clients_pending_write: *mut list,
1830 pub clients_pending_read: *mut list,
1831 pub slaves: *mut list,
1832 pub monitors: *mut list,
1833 pub current_client: *mut client,
1834 pub client_mem_usage_buckets: *mut clientMemUsageBucket,
1835 pub clients_timeout_table: *mut rax,
1836 pub fixed_time_expire: libc::c_long,
1837 pub in_nested_call: libc::c_int,
1838 pub clients_index: *mut rax,
1839 pub client_pause_type: pause_type,
1840 pub postponed_clients: *mut list,
1841 pub client_pause_end_time: mstime_t,
1842 pub client_pause_per_purpose: [*mut pause_event; 3],
1843 pub neterr: [libc::c_char; 256],
1844 pub migrate_cached_sockets: *mut dict,
1845 pub next_client_id: uint_least64_t,
1846 pub protected_mode: libc::c_int,
1847 pub io_threads_num: libc::c_int,
1848 pub io_threads_do_reads: libc::c_int,
1849 pub io_threads_active: libc::c_int,
1850 pub events_processed_while_blocked: libc::c_longlong,
1851 pub enable_protected_configs: libc::c_int,
1852 pub enable_debug_cmd: libc::c_int,
1853 pub enable_module_cmd: libc::c_int,
1854 pub loading: sig_atomic_t,
1855 pub async_loading: sig_atomic_t,
1856 pub loading_total_bytes: off_t,
1857 pub loading_rdb_used_mem: off_t,
1858 pub loading_loaded_bytes: off_t,
1859 pub loading_start_time: time_t,
1860 pub loading_process_events_interval_bytes: off_t,
1861 pub stat_starttime: time_t,
1862 pub stat_numcommands: libc::c_longlong,
1863 pub stat_numconnections: libc::c_longlong,
1864 pub stat_expiredkeys: libc::c_longlong,
1865 pub stat_expired_stale_perc: libc::c_double,
1866 pub stat_expired_time_cap_reached_count: libc::c_longlong,
1867 pub stat_expire_cycle_time_used: libc::c_longlong,
1868 pub stat_evictedkeys: libc::c_longlong,
1869 pub stat_evictedclients: libc::c_longlong,
1870 pub stat_total_eviction_exceeded_time: libc::c_longlong,
1871 pub stat_last_eviction_exceeded_time: monotime,
1872 pub stat_keyspace_hits: libc::c_longlong,
1873 pub stat_keyspace_misses: libc::c_longlong,
1874 pub stat_active_defrag_hits: libc::c_longlong,
1875 pub stat_active_defrag_misses: libc::c_longlong,
1876 pub stat_active_defrag_key_hits: libc::c_longlong,
1877 pub stat_active_defrag_key_misses: libc::c_longlong,
1878 pub stat_active_defrag_scanned: libc::c_longlong,
1879 pub stat_total_active_defrag_time: libc::c_longlong,
1880 pub stat_last_active_defrag_time: monotime,
1881 pub stat_peak_memory: size_t,
1882 pub stat_aof_rewrites: libc::c_longlong,
1883 pub stat_aofrw_consecutive_failures: libc::c_longlong,
1884 pub stat_rdb_saves: libc::c_longlong,
1885 pub stat_fork_time: libc::c_longlong,
1886 pub stat_fork_rate: libc::c_double,
1887 pub stat_total_forks: libc::c_longlong,
1888 pub stat_rejected_conn: libc::c_longlong,
1889 pub stat_sync_full: libc::c_longlong,
1890 pub stat_sync_partial_ok: libc::c_longlong,
1891 pub stat_sync_partial_err: libc::c_longlong,
1892 pub slowlog: *mut list,
1893 pub slowlog_entry_id: libc::c_longlong,
1894 pub slowlog_log_slower_than: libc::c_longlong,
1895 pub slowlog_max_len: libc::c_ulong,
1896 pub cron_malloc_stats: malloc_stats,
1897 pub stat_net_input_bytes: atomic_llong,
1898 pub stat_net_output_bytes: atomic_llong,
1899 pub stat_net_repl_input_bytes: atomic_llong,
1900 pub stat_net_repl_output_bytes: atomic_llong,
1901 pub stat_current_cow_peak: size_t,
1902 pub stat_current_cow_bytes: size_t,
1903 pub stat_current_cow_updated: monotime,
1904 pub stat_current_save_keys_processed: size_t,
1905 pub stat_current_save_keys_total: size_t,
1906 pub stat_rdb_cow_bytes: size_t,
1907 pub stat_aof_cow_bytes: size_t,
1908 pub stat_module_cow_bytes: size_t,
1909 pub stat_module_progress: libc::c_double,
1910 pub stat_clients_type_memory: [size_t; 4],
1911 pub stat_cluster_links_memory: size_t,
1912 pub stat_unexpected_error_replies: libc::c_longlong,
1913 pub stat_total_error_replies: libc::c_longlong,
1914 pub stat_dump_payload_sanitizations: libc::c_longlong,
1915 pub stat_io_reads_processed: libc::c_longlong,
1916 pub stat_io_writes_processed: libc::c_longlong,
1917 pub stat_total_reads_processed: atomic_llong,
1918 pub stat_total_writes_processed: atomic_llong,
1919 pub inst_metric: [C2RustUnnamed_12; 5],
1920 pub stat_reply_buffer_shrinks: libc::c_longlong,
1921 pub stat_reply_buffer_expands: libc::c_longlong,
1922 pub verbosity: libc::c_int,
1923 pub maxidletime: libc::c_int,
1924 pub tcpkeepalive: libc::c_int,
1925 pub active_expire_enabled: libc::c_int,
1926 pub active_expire_effort: libc::c_int,
1927 pub active_defrag_enabled: libc::c_int,
1928 pub sanitize_dump_payload: libc::c_int,
1929 pub skip_checksum_validation: libc::c_int,
1930 pub jemalloc_bg_thread: libc::c_int,
1931 pub active_defrag_ignore_bytes: size_t,
1932 pub active_defrag_threshold_lower: libc::c_int,
1933 pub active_defrag_threshold_upper: libc::c_int,
1934 pub active_defrag_cycle_min: libc::c_int,
1935 pub active_defrag_cycle_max: libc::c_int,
1936 pub active_defrag_max_scan_fields: libc::c_ulong,
1937 pub client_max_querybuf_len: size_t,
1938 pub dbnum: libc::c_int,
1939 pub supervised: libc::c_int,
1940 pub supervised_mode: libc::c_int,
1941 pub daemonize: libc::c_int,
1942 pub set_proc_title: libc::c_int,
1943 pub proc_title_template: *mut libc::c_char,
1944 pub client_obuf_limits: [clientBufferLimitsConfig; 3],
1945 pub pause_cron: libc::c_int,
1946 pub latency_tracking_enabled: libc::c_int,
1947 pub latency_tracking_info_percentiles: *mut libc::c_double,
1948 pub latency_tracking_info_percentiles_len: libc::c_int,
1949 pub aof_enabled: libc::c_int,
1950 pub aof_state: libc::c_int,
1951 pub aof_fsync: libc::c_int,
1952 pub aof_filename: *mut libc::c_char,
1953 pub aof_dirname: *mut libc::c_char,
1954 pub aof_no_fsync_on_rewrite: libc::c_int,
1955 pub aof_rewrite_perc: libc::c_int,
1956 pub aof_rewrite_min_size: off_t,
1957 pub aof_rewrite_base_size: off_t,
1958 pub aof_current_size: off_t,
1959 pub aof_last_incr_size: off_t,
1960 pub aof_fsync_offset: off_t,
1961 pub aof_flush_sleep: libc::c_int,
1962 pub aof_rewrite_scheduled: libc::c_int,
1963 pub aof_buf: sds,
1964 pub aof_fd: libc::c_int,
1965 pub aof_selected_db: libc::c_int,
1966 pub aof_flush_postponed_start: time_t,
1967 pub aof_last_fsync: time_t,
1968 pub aof_rewrite_time_last: time_t,
1969 pub aof_rewrite_time_start: time_t,
1970 pub aof_cur_timestamp: time_t,
1971 pub aof_timestamp_enabled: libc::c_int,
1972 pub aof_lastbgrewrite_status: libc::c_int,
1973 pub aof_delayed_fsync: libc::c_ulong,
1974 pub aof_rewrite_incremental_fsync: libc::c_int,
1975 pub rdb_save_incremental_fsync: libc::c_int,
1976 pub aof_last_write_status: libc::c_int,
1977 pub aof_last_write_errno: libc::c_int,
1978 pub aof_load_truncated: libc::c_int,
1979 pub aof_use_rdb_preamble: libc::c_int,
1980 pub aof_bio_fsync_status: atomic_int,
1981 pub aof_bio_fsync_errno: atomic_int,
1982 pub aof_manifest: *mut aofManifest,
1983 pub aof_disable_auto_gc: libc::c_int,
1984 pub dirty: libc::c_longlong,
1985 pub dirty_before_bgsave: libc::c_longlong,
1986 pub rdb_last_load_keys_expired: libc::c_longlong,
1987 pub rdb_last_load_keys_loaded: libc::c_longlong,
1988 pub saveparams: *mut saveparam,
1989 pub saveparamslen: libc::c_int,
1990 pub rdb_filename: *mut libc::c_char,
1991 pub rdb_compression: libc::c_int,
1992 pub rdb_checksum: libc::c_int,
1993 pub rdb_del_sync_files: libc::c_int,
1994 pub lastsave: time_t,
1995 pub lastbgsave_try: time_t,
1996 pub rdb_save_time_last: time_t,
1997 pub rdb_save_time_start: time_t,
1998 pub rdb_bgsave_scheduled: libc::c_int,
1999 pub rdb_child_type: libc::c_int,
2000 pub lastbgsave_status: libc::c_int,
2001 pub stop_writes_on_bgsave_err: libc::c_int,
2002 pub rdb_pipe_read: libc::c_int,
2003 pub rdb_child_exit_pipe: libc::c_int,
2004 pub rdb_pipe_conns: *mut *mut connection,
2005 pub rdb_pipe_numconns: libc::c_int,
2006 pub rdb_pipe_numconns_writing: libc::c_int,
2007 pub rdb_pipe_buff: *mut libc::c_char,
2008 pub rdb_pipe_bufflen: libc::c_int,
2009 pub rdb_key_save_delay: libc::c_int,
2010 pub key_load_delay: libc::c_int,
2011 pub child_info_pipe: [libc::c_int; 2],
2012 pub child_info_nread: libc::c_int,
2013 pub also_propagate: redisOpArray,
2014 pub replication_allowed: libc::c_int,
2015 pub logfile: *mut libc::c_char,
2016 pub syslog_enabled: libc::c_int,
2017 pub syslog_ident: *mut libc::c_char,
2018 pub syslog_facility: libc::c_int,
2019 pub crashlog_enabled: libc::c_int,
2020 pub memcheck_enabled: libc::c_int,
2021 pub use_exit_on_panic: libc::c_int,
2022 pub shutdown_timeout: libc::c_int,
2023 pub shutdown_on_sigint: libc::c_int,
2024 pub shutdown_on_sigterm: libc::c_int,
2025 pub replid: [libc::c_char; 41],
2026 pub replid2: [libc::c_char; 41],
2027 pub master_repl_offset: libc::c_longlong,
2028 pub second_replid_offset: libc::c_longlong,
2029 pub slaveseldb: libc::c_int,
2030 pub repl_ping_slave_period: libc::c_int,
2031 pub repl_backlog: *mut replBacklog,
2032 pub repl_backlog_size: libc::c_longlong,
2033 pub repl_backlog_time_limit: time_t,
2034 pub repl_no_slaves_since: time_t,
2035 pub repl_min_slaves_to_write: libc::c_int,
2036 pub repl_min_slaves_max_lag: libc::c_int,
2037 pub repl_good_slaves_count: libc::c_int,
2038 pub repl_diskless_sync: libc::c_int,
2039 pub repl_diskless_load: libc::c_int,
2040 pub repl_diskless_sync_delay: libc::c_int,
2041 pub repl_diskless_sync_max_replicas: libc::c_int,
2042 pub repl_buffer_mem: size_t,
2043 pub repl_buffer_blocks: *mut list,
2044 pub masteruser: *mut libc::c_char,
2045 pub masterauth: sds,
2046 pub masterhost: *mut libc::c_char,
2047 pub masterport: libc::c_int,
2048 pub repl_timeout: libc::c_int,
2049 pub master: *mut client,
2050 pub cached_master: *mut client,
2051 pub repl_syncio_timeout: libc::c_int,
2052 pub repl_state: libc::c_int,
2053 pub repl_transfer_size: off_t,
2054 pub repl_transfer_read: off_t,
2055 pub repl_transfer_last_fsync_off: off_t,
2056 pub repl_transfer_s: *mut connection,
2057 pub repl_transfer_fd: libc::c_int,
2058 pub repl_transfer_tmpfile: *mut libc::c_char,
2059 pub repl_transfer_lastio: time_t,
2060 pub repl_serve_stale_data: libc::c_int,
2061 pub repl_slave_ro: libc::c_int,
2062 pub repl_slave_ignore_maxmemory: libc::c_int,
2063 pub repl_down_since: time_t,
2064 pub repl_disable_tcp_nodelay: libc::c_int,
2065 pub slave_priority: libc::c_int,
2066 pub replica_announced: libc::c_int,
2067 pub slave_announce_port: libc::c_int,
2068 pub slave_announce_ip: *mut libc::c_char,
2069 pub propagation_error_behavior: libc::c_int,
2070 pub repl_ignore_disk_write_error: libc::c_int,
2071 pub master_replid: [libc::c_char; 41],
2072 pub master_initial_offset: libc::c_longlong,
2073 pub repl_slave_lazy_flush: libc::c_int,
2074 pub clients_waiting_acks: *mut list,
2075 pub get_ack_from_slaves: libc::c_int,
2076 pub maxclients: libc::c_uint,
2077 pub maxmemory: libc::c_ulonglong,
2078 pub maxmemory_clients: ssize_t,
2079 pub maxmemory_policy: libc::c_int,
2080 pub maxmemory_samples: libc::c_int,
2081 pub maxmemory_eviction_tenacity: libc::c_int,
2082 pub lfu_log_factor: libc::c_int,
2083 pub lfu_decay_time: libc::c_int,
2084 pub proto_max_bulk_len: libc::c_longlong,
2085 pub oom_score_adj_values: [libc::c_int; 3],
2086 pub oom_score_adj: libc::c_int,
2087 pub disable_thp: libc::c_int,
2088 pub blocked_clients: libc::c_uint,
2089 pub blocked_clients_by_type: [libc::c_uint; 8],
2090 pub unblocked_clients: *mut list,
2091 pub ready_keys: *mut list,
2092 pub tracking_clients: libc::c_uint,
2093 pub tracking_table_max_keys: size_t,
2094 pub tracking_pending_keys: *mut list,
2095 pub sort_desc: libc::c_int,
2096 pub sort_alpha: libc::c_int,
2097 pub sort_bypattern: libc::c_int,
2098 pub sort_store: libc::c_int,
2099 pub hash_max_listpack_entries: size_t,
2100 pub hash_max_listpack_value: size_t,
2101 pub set_max_intset_entries: size_t,
2102 pub zset_max_listpack_entries: size_t,
2103 pub zset_max_listpack_value: size_t,
2104 pub hll_sparse_max_bytes: size_t,
2105 pub stream_node_max_bytes: size_t,
2106 pub stream_node_max_entries: libc::c_longlong,
2107 pub list_max_listpack_size: libc::c_int,
2108 pub list_compress_depth: libc::c_int,
2109 pub unixtime: atomic_int,
2110 pub timezone: time_t,
2111 pub daylight_active: libc::c_int,
2112 pub mstime: mstime_t,
2113 pub ustime: ustime_t,
2114 pub blocking_op_nesting: size_t,
2115 pub blocked_last_cron: libc::c_longlong,
2116 pub pubsub_channels: *mut dict,
2117 pub pubsub_patterns: *mut dict,
2118 pub notify_keyspace_events: libc::c_int,
2119 pub pubsubshard_channels: *mut dict,
2120 pub cluster_enabled: libc::c_int,
2121 pub cluster_port: libc::c_int,
2122 pub cluster_node_timeout: mstime_t,
2123 pub cluster_configfile: *mut libc::c_char,
2124 pub cluster: *mut clusterState,
2125 pub cluster_migration_barrier: libc::c_int,
2126 pub cluster_allow_replica_migration: libc::c_int,
2127 pub cluster_slave_validity_factor: libc::c_int,
2128 pub cluster_require_full_coverage: libc::c_int,
2129 pub cluster_slave_no_failover: libc::c_int,
2130 pub cluster_announce_ip: *mut libc::c_char,
2131 pub cluster_announce_hostname: *mut libc::c_char,
2132 pub cluster_preferred_endpoint_type: libc::c_int,
2133 pub cluster_announce_port: libc::c_int,
2134 pub cluster_announce_tls_port: libc::c_int,
2135 pub cluster_announce_bus_port: libc::c_int,
2136 pub cluster_module_flags: libc::c_int,
2137 pub cluster_allow_reads_when_down: libc::c_int,
2138 pub cluster_config_file_lock_fd: libc::c_int,
2139 pub cluster_link_sendbuf_limit_bytes: libc::c_ulonglong,
2140 pub cluster_drop_packet_filter: libc::c_int,
2141 pub script_caller: *mut client,
2142 pub busy_reply_threshold: mstime_t,
2143 pub pre_command_oom_state: libc::c_int,
2144 pub script_disable_deny_script: libc::c_int,
2145 pub lazyfree_lazy_eviction: libc::c_int,
2146 pub lazyfree_lazy_expire: libc::c_int,
2147 pub lazyfree_lazy_server_del: libc::c_int,
2148 pub lazyfree_lazy_user_del: libc::c_int,
2149 pub lazyfree_lazy_user_flush: libc::c_int,
2150 pub latency_monitor_threshold: libc::c_longlong,
2151 pub latency_events: *mut dict,
2152 pub acl_filename: *mut libc::c_char,
2153 pub acllog_max_len: libc::c_ulong,
2154 pub requirepass: sds,
2155 pub acl_pubsub_default: libc::c_int,
2156 pub watchdog_period: libc::c_int,
2157 pub system_memory_size: size_t,
2158 pub tls_cluster: libc::c_int,
2159 pub tls_replication: libc::c_int,
2160 pub tls_auth_clients: libc::c_int,
2161 pub tls_ctx_config: redisTLSContextConfig,
2162 pub server_cpulist: *mut libc::c_char,
2163 pub bio_cpulist: *mut libc::c_char,
2164 pub aof_rewrite_cpulist: *mut libc::c_char,
2165 pub bgsave_cpulist: *mut libc::c_char,
2166 pub sentinel_config: *mut sentinelConfig,
2167 pub failover_end_time: mstime_t,
2168 pub force_failover: libc::c_int,
2169 pub target_replica_host: *mut libc::c_char,
2170 pub target_replica_port: libc::c_int,
2171 pub failover_state: libc::c_int,
2172 pub cluster_allow_pubsubshard_when_down: libc::c_int,
2173 pub reply_buffer_peak_reset_time: libc::c_long,
2174 pub reply_buffer_resizing_enabled: libc::c_int,
2175}
2176#[derive(Copy, Clone)]
2177#[repr(C)]
2178pub struct C2RustUnnamed_12 {
2179 pub last_sample_time: libc::c_longlong,
2180 pub last_sample_count: libc::c_longlong,
2181 pub samples: [libc::c_longlong; 16],
2182 pub idx: libc::c_int,
2183}
2184pub type listpackValidateEntryCB = Option::<
2185 unsafe extern "C" fn(
2186 *mut libc::c_uchar,
2187 libc::c_uint,
2188 *mut libc::c_void,
2189 ) -> libc::c_int,
2190>;
2191#[derive(Copy, Clone)]
2192#[repr(C)]
2193pub struct streamID {
2194 pub ms: uint64_t,
2195 pub seq: uint64_t,
2196}
2197#[derive(Copy, Clone)]
2198#[repr(C)]
2199pub struct stream {
2200 pub rax: *mut rax,
2201 pub length: uint64_t,
2202 pub last_id: streamID,
2203 pub first_id: streamID,
2204 pub max_deleted_entry_id: streamID,
2205 pub entries_added: uint64_t,
2206 pub cgroups: *mut rax,
2207}
2208#[derive(Copy, Clone)]
2209#[repr(C)]
2210pub struct streamCG {
2211 pub last_id: streamID,
2212 pub entries_read: libc::c_longlong,
2213 pub pel: *mut rax,
2214 pub consumers: *mut rax,
2215}
2216#[derive(Copy, Clone)]
2217#[repr(C)]
2218pub struct streamConsumer {
2219 pub seen_time: mstime_t,
2220 pub name: sds,
2221 pub pel: *mut rax,
2222}
2223#[derive(Copy, Clone)]
2224#[repr(C)]
2225pub struct streamNACK {
2226 pub delivery_time: mstime_t,
2227 pub delivery_count: uint64_t,
2228 pub consumer: *mut streamConsumer,
2229}
2230#[derive(Copy, Clone)]
2231#[repr(C)]
2232pub struct C2RustUnnamed_13 {
2233 pub count: libc::c_long,
2234 pub fields: *mut dict,
2235}
2236#[derive(Copy, Clone)]
2237#[repr(C)]
2238pub struct C2RustUnnamed_14 {
2239 pub count: libc::c_long,
2240 pub fields: *mut dict,
2241}
2242#[derive(Copy, Clone)]
2243#[repr(C)]
2244pub struct C2RustUnnamed_15 {
2245 pub count: libc::c_long,
2246 pub fields: *mut dict,
2247 pub lp: *mut *mut libc::c_uchar,
2248}
2249#[derive(Copy, Clone)]
2250#[repr(C)]
2251pub struct C2RustUnnamed_16 {
2252 pub count: libc::c_long,
2253 pub fields: *mut dict,
2254 pub lp: *mut *mut libc::c_uchar,
2255}
2256#[derive(Copy, Clone)]
2257#[repr(C)]
2258pub struct functionLibInfo {
2259 pub name: sds,
2260 pub functions: *mut dict,
2261 pub ei: *mut engineInfo,
2262 pub code: sds,
2263}
2264#[derive(Copy, Clone)]
2265#[repr(C)]
2266pub struct engineInfo {
2267 pub name: sds,
2268 pub engine: *mut engine,
2269 pub c: *mut client,
2270}
2271#[derive(Copy, Clone)]
2272#[repr(C)]
2273pub struct engine {
2274 pub engine_ctx: *mut libc::c_void,
2275 pub create: Option::<
2276 unsafe extern "C" fn(
2277 *mut libc::c_void,
2278 *mut functionLibInfo,
2279 sds,
2280 *mut sds,
2281 ) -> libc::c_int,
2282 >,
2283 pub call: Option::<
2284 unsafe extern "C" fn(
2285 *mut scriptRunCtx,
2286 *mut libc::c_void,
2287 *mut libc::c_void,
2288 *mut *mut robj,
2289 size_t,
2290 *mut *mut robj,
2291 size_t,
2292 ) -> (),
2293 >,
2294 pub get_used_memory: Option::<unsafe extern "C" fn(*mut libc::c_void) -> size_t>,
2295 pub get_function_memory_overhead: Option::<
2296 unsafe extern "C" fn(*mut libc::c_void) -> size_t,
2297 >,
2298 pub get_engine_memory_overhead: Option::<
2299 unsafe extern "C" fn(*mut libc::c_void) -> size_t,
2300 >,
2301 pub free_function: Option::<
2302 unsafe extern "C" fn(*mut libc::c_void, *mut libc::c_void) -> (),
2303 >,
2304}
2305#[derive(Copy, Clone)]
2306#[repr(C)]
2307pub struct scriptRunCtx {
2308 pub funcname: *const libc::c_char,
2309 pub c: *mut client,
2310 pub original_client: *mut client,
2311 pub flags: libc::c_int,
2312 pub repl_flags: libc::c_int,
2313 pub start_time: monotime,
2314 pub snapshot_time: mstime_t,
2315}
2316#[inline]
2317unsafe extern "C" fn rioWrite(
2318 mut r: *mut rio,
2319 mut buf: *const libc::c_void,
2320 mut len: size_t,
2321) -> size_t {
2322 if (*r).flags & ((1 as libc::c_int) << 1 as libc::c_int) as libc::c_ulong != 0 {
2323 return 0 as libc::c_int as size_t;
2324 }
2325 while len != 0 {
2326 let mut bytes_to_write: size_t = if (*r).max_processing_chunk != 0
2327 && (*r).max_processing_chunk < len
2328 {
2329 (*r).max_processing_chunk
2330 } else {
2331 len
2332 };
2333 if ((*r).update_cksum).is_some() {
2334 ((*r).update_cksum)
2335 .expect("non-null function pointer")(r, buf, bytes_to_write);
2336 }
2337 if ((*r).write).expect("non-null function pointer")(r, buf, bytes_to_write)
2338 == 0 as libc::c_int as libc::c_ulong
2339 {
2340 (*r).flags |= ((1 as libc::c_int) << 1 as libc::c_int) as libc::c_ulong;
2341 return 0 as libc::c_int as size_t;
2342 }
2343 buf = (buf as *mut libc::c_char).offset(bytes_to_write as isize)
2344 as *const libc::c_void;
2345 len = (len as libc::c_ulong).wrapping_sub(bytes_to_write) as size_t as size_t;
2346 (*r)
2347 .processed_bytes = ((*r).processed_bytes as libc::c_ulong)
2348 .wrapping_add(bytes_to_write) as size_t as size_t;
2349 }
2350 return 1 as libc::c_int as size_t;
2351}
2352#[inline]
2353unsafe extern "C" fn rioRead(
2354 mut r: *mut rio,
2355 mut buf: *mut libc::c_void,
2356 mut len: size_t,
2357) -> size_t {
2358 if (*r).flags & ((1 as libc::c_int) << 0 as libc::c_int) as libc::c_ulong != 0 {
2359 return 0 as libc::c_int as size_t;
2360 }
2361 while len != 0 {
2362 let mut bytes_to_read: size_t = if (*r).max_processing_chunk != 0
2363 && (*r).max_processing_chunk < len
2364 {
2365 (*r).max_processing_chunk
2366 } else {
2367 len
2368 };
2369 if ((*r).read).expect("non-null function pointer")(r, buf, bytes_to_read)
2370 == 0 as libc::c_int as libc::c_ulong
2371 {
2372 (*r).flags |= ((1 as libc::c_int) << 0 as libc::c_int) as libc::c_ulong;
2373 return 0 as libc::c_int as size_t;
2374 }
2375 if ((*r).update_cksum).is_some() {
2376 ((*r).update_cksum)
2377 .expect("non-null function pointer")(r, buf, bytes_to_read);
2378 }
2379 buf = (buf as *mut libc::c_char).offset(bytes_to_read as isize)
2380 as *mut libc::c_void;
2381 len = (len as libc::c_ulong).wrapping_sub(bytes_to_read) as size_t as size_t;
2382 (*r)
2383 .processed_bytes = ((*r).processed_bytes as libc::c_ulong)
2384 .wrapping_add(bytes_to_read) as size_t as size_t;
2385 }
2386 return 1 as libc::c_int as size_t;
2387}
2388#[inline]
2389unsafe extern "C" fn rioFlush(mut r: *mut rio) -> libc::c_int {
2390 return ((*r).flush).expect("non-null function pointer")(r);
2391}
2392#[inline]
2393unsafe extern "C" fn rioGetReadError(mut r: *mut rio) -> libc::c_int {
2394 return ((*r).flags & ((1 as libc::c_int) << 0 as libc::c_int) as libc::c_ulong
2395 != 0 as libc::c_int as libc::c_ulong) as libc::c_int;
2396}
2397#[inline]
2398unsafe extern "C" fn atoi(mut __nptr: *const libc::c_char) -> libc::c_int {
2399 return strtol(
2400 __nptr,
2401 0 as *mut libc::c_void as *mut *mut libc::c_char,
2402 10 as libc::c_int,
2403 ) as libc::c_int;
2404}
2405#[inline]
2406unsafe extern "C" fn sdslen(s: sds) -> size_t {
2407 let mut flags: libc::c_uchar = *s.offset(-(1 as libc::c_int) as isize)
2408 as libc::c_uchar;
2409 match flags as libc::c_int & 7 as libc::c_int {
2410 0 => return (flags as libc::c_int >> 3 as libc::c_int) as size_t,
2411 1 => {
2412 return (*(s
2413 .offset(-(core::mem::size_of::<sdshdr8>() as libc::c_ulong as isize))
2414 as *mut sdshdr8))
2415 .len as size_t;
2416 }
2417 2 => {
2418 return (*(s
2419 .offset(-(core::mem::size_of::<sdshdr16>() as libc::c_ulong as isize))
2420 as *mut sdshdr16))
2421 .len as size_t;
2422 }
2423 3 => {
2424 return (*(s
2425 .offset(-(core::mem::size_of::<sdshdr32>() as libc::c_ulong as isize))
2426 as *mut sdshdr32))
2427 .len as size_t;
2428 }
2429 4 => {
2430 return (*(s
2431 .offset(-(core::mem::size_of::<sdshdr64>() as libc::c_ulong as isize))
2432 as *mut sdshdr64))
2433 .len;
2434 }
2435 _ => {}
2436 }
2437 return 0 as libc::c_int as size_t;
2438}
2439#[inline]
2440unsafe extern "C" fn __bswap_32(mut __bsx: __uint32_t) -> __uint32_t {
2441 return (__bsx & 0xff000000 as libc::c_uint) >> 24 as libc::c_int
2442 | (__bsx & 0xff0000 as libc::c_uint) >> 8 as libc::c_int
2443 | (__bsx & 0xff00 as libc::c_uint) << 8 as libc::c_int
2444 | (__bsx & 0xff as libc::c_uint) << 24 as libc::c_int;
2445}
2446#[inline]
2447unsafe extern "C" fn fstat(
2448 mut __fd: libc::c_int,
2449 mut __statbuf: *mut stat,
2450) -> libc::c_int {
2451 return __fxstat(0 as libc::c_int, __fd, __statbuf);
2452}
2453#[no_mangle]
2454pub static mut rdbFileBeingLoaded: *mut libc::c_char = 0 as *const libc::c_char
2455 as *mut libc::c_char;
2456#[no_mangle]
2457pub unsafe extern "C" fn rdbReportError(
2458 mut corruption_error: libc::c_int,
2459 mut linenum: libc::c_int,
2460 mut reason: *mut libc::c_char,
2461 mut args: ...
2462) {
2463 let mut ap: core::ffi::VaListImpl;
2464 let mut msg: [libc::c_char; 1024] = [0; 1024];
2465 let mut len: libc::c_int = 0;
2466 len = snprintf(
2467 msg.as_mut_ptr(),
2468 core::mem::size_of::<[libc::c_char; 1024]>() as libc::c_ulong,
2469 b"Internal error in RDB reading offset %llu, function at rdb.c:%d -> \0"
2470 as *const u8 as *const libc::c_char,
2471 server.loading_loaded_bytes as libc::c_ulonglong,
2472 linenum,
2473 );
2474 ap = args.clone();
2475 vsnprintf(
2476 msg.as_mut_ptr().offset(len as isize),
2477 (core::mem::size_of::<[libc::c_char; 1024]>() as libc::c_ulong)
2478 .wrapping_sub(len as libc::c_ulong),
2479 reason,
2480 ap.as_va_list(),
2481 );
2482 if if (server.current_client).is_null()
2483 || (*server.current_client).id == 18446744073709551615 as libc::c_ulong
2484 {
2485 0 as libc::c_int
2486 } else {
2487 1 as libc::c_int
2488 } != 0
2489 {
2490 if !((1 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
2491 _serverLog(
2492 1 as libc::c_int,
2493 b"%s\0" as *const u8 as *const libc::c_char,
2494 msg.as_mut_ptr(),
2495 );
2496 }
2497 return;
2498 } else {
2499 if rdbCheckMode != 0 {
2500 rdbCheckError(b"%s\0" as *const u8 as *const libc::c_char, msg.as_mut_ptr());
2501 } else if !rdbFileBeingLoaded.is_null() {
2502 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
2503 _serverLog(
2504 3 as libc::c_int,
2505 b"%s\0" as *const u8 as *const libc::c_char,
2506 msg.as_mut_ptr(),
2507 );
2508 }
2509 let mut argv: [*mut libc::c_char; 2] = [
2510 b"\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
2511 rdbFileBeingLoaded,
2512 ];
2513 redis_check_rdb_main(2 as libc::c_int, argv.as_mut_ptr(), 0 as *mut FILE);
2514 } else if corruption_error != 0 {
2515 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
2516 _serverLog(
2517 3 as libc::c_int,
2518 b"%s. Failure loading rdb format\0" as *const u8
2519 as *const libc::c_char,
2520 msg.as_mut_ptr(),
2521 );
2522 }
2523 } else {
2524 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
2525 _serverLog(
2526 3 as libc::c_int,
2527 b"%s. Failure loading rdb format from socket, assuming connection error, resuming operation.\0"
2528 as *const u8 as *const libc::c_char,
2529 msg.as_mut_ptr(),
2530 );
2531 }
2532 return;
2533 }
2534 }
2535 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
2536 _serverLog(
2537 3 as libc::c_int,
2538 b"Terminating server after rdb file reading failure.\0" as *const u8
2539 as *const libc::c_char,
2540 );
2541 }
2542 exit(1 as libc::c_int);
2543}
2544unsafe extern "C" fn rdbWriteRaw(
2545 mut rdb: *mut rio,
2546 mut p: *mut libc::c_void,
2547 mut len: size_t,
2548) -> ssize_t {
2549 if !rdb.is_null() && rioWrite(rdb, p, len) == 0 as libc::c_int as libc::c_ulong {
2550 return -(1 as libc::c_int) as ssize_t;
2551 }
2552 return len as ssize_t;
2553}
2554#[no_mangle]
2555pub unsafe extern "C" fn rdbSaveType(
2556 mut rdb: *mut rio,
2557 mut type_0: libc::c_uchar,
2558) -> libc::c_int {
2559 return rdbWriteRaw(
2560 rdb,
2561 &mut type_0 as *mut libc::c_uchar as *mut libc::c_void,
2562 1 as libc::c_int as size_t,
2563 ) as libc::c_int;
2564}
2565#[no_mangle]
2566pub unsafe extern "C" fn rdbLoadType(mut rdb: *mut rio) -> libc::c_int {
2567 let mut type_0: libc::c_uchar = 0;
2568 if rioRead(
2569 rdb,
2570 &mut type_0 as *mut libc::c_uchar as *mut libc::c_void,
2571 1 as libc::c_int as size_t,
2572 ) == 0 as libc::c_int as libc::c_ulong
2573 {
2574 return -(1 as libc::c_int);
2575 }
2576 return type_0 as libc::c_int;
2577}
2578#[no_mangle]
2579pub unsafe extern "C" fn rdbLoadTime(mut rdb: *mut rio) -> time_t {
2580 let mut t32: int32_t = 0;
2581 if rioRead(
2582 rdb,
2583 &mut t32 as *mut int32_t as *mut libc::c_void,
2584 4 as libc::c_int as size_t,
2585 ) == 0 as libc::c_int as libc::c_ulong
2586 {
2587 return -(1 as libc::c_int) as time_t;
2588 }
2589 return t32 as time_t;
2590}
2591#[no_mangle]
2592pub unsafe extern "C" fn rdbSaveMillisecondTime(
2593 mut rdb: *mut rio,
2594 mut t: libc::c_longlong,
2595) -> libc::c_int {
2596 let mut t64: int64_t = t as int64_t;
2597 return rdbWriteRaw(
2598 rdb,
2599 &mut t64 as *mut int64_t as *mut libc::c_void,
2600 8 as libc::c_int as size_t,
2601 ) as libc::c_int;
2602}
2603#[no_mangle]
2604pub unsafe extern "C" fn rdbLoadMillisecondTime(
2605 mut rdb: *mut rio,
2606 mut rdbver: libc::c_int,
2607) -> libc::c_longlong {
2608 let mut t64: int64_t = 0;
2609 if rioRead(
2610 rdb,
2611 &mut t64 as *mut int64_t as *mut libc::c_void,
2612 8 as libc::c_int as size_t,
2613 ) == 0 as libc::c_int as libc::c_ulong
2614 {
2615 return 9223372036854775807 as libc::c_longlong;
2616 }
2617 rdbver >= 9 as libc::c_int;
2618 return t64 as libc::c_longlong;
2619}
2620#[no_mangle]
2621pub unsafe extern "C" fn rdbSaveLen(
2622 mut rdb: *mut rio,
2623 mut len: uint64_t,
2624) -> libc::c_int {
2625 let mut buf: [libc::c_uchar; 2] = [0; 2];
2626 let mut nwritten: size_t = 0;
2627 if len < ((1 as libc::c_int) << 6 as libc::c_int) as libc::c_ulong {
2628 buf[0 as libc::c_int
2629 as usize] = (len & 0xff as libc::c_int as libc::c_ulong
2630 | ((0 as libc::c_int) << 6 as libc::c_int) as libc::c_ulong)
2631 as libc::c_uchar;
2632 if rdbWriteRaw(
2633 rdb,
2634 buf.as_mut_ptr() as *mut libc::c_void,
2635 1 as libc::c_int as size_t,
2636 ) == -(1 as libc::c_int) as libc::c_long
2637 {
2638 return -(1 as libc::c_int);
2639 }
2640 nwritten = 1 as libc::c_int as size_t;
2641 } else if len < ((1 as libc::c_int) << 14 as libc::c_int) as libc::c_ulong {
2642 buf[0 as libc::c_int
2643 as usize] = (len >> 8 as libc::c_int & 0xff as libc::c_int as libc::c_ulong
2644 | ((1 as libc::c_int) << 6 as libc::c_int) as libc::c_ulong)
2645 as libc::c_uchar;
2646 buf[1 as libc::c_int
2647 as usize] = (len & 0xff as libc::c_int as libc::c_ulong) as libc::c_uchar;
2648 if rdbWriteRaw(
2649 rdb,
2650 buf.as_mut_ptr() as *mut libc::c_void,
2651 2 as libc::c_int as size_t,
2652 ) == -(1 as libc::c_int) as libc::c_long
2653 {
2654 return -(1 as libc::c_int);
2655 }
2656 nwritten = 2 as libc::c_int as size_t;
2657 } else if len <= 4294967295 as libc::c_uint as libc::c_ulong {
2658 buf[0 as libc::c_int as usize] = 0x80 as libc::c_int as libc::c_uchar;
2659 if rdbWriteRaw(
2660 rdb,
2661 buf.as_mut_ptr() as *mut libc::c_void,
2662 1 as libc::c_int as size_t,
2663 ) == -(1 as libc::c_int) as libc::c_long
2664 {
2665 return -(1 as libc::c_int);
2666 }
2667 let mut len32: uint32_t = __bswap_32(len as __uint32_t);
2668 if rdbWriteRaw(
2669 rdb,
2670 &mut len32 as *mut uint32_t as *mut libc::c_void,
2671 4 as libc::c_int as size_t,
2672 ) == -(1 as libc::c_int) as libc::c_long
2673 {
2674 return -(1 as libc::c_int);
2675 }
2676 nwritten = (1 as libc::c_int + 4 as libc::c_int) as size_t;
2677 } else {
2678 buf[0 as libc::c_int as usize] = 0x81 as libc::c_int as libc::c_uchar;
2679 if rdbWriteRaw(
2680 rdb,
2681 buf.as_mut_ptr() as *mut libc::c_void,
2682 1 as libc::c_int as size_t,
2683 ) == -(1 as libc::c_int) as libc::c_long
2684 {
2685 return -(1 as libc::c_int);
2686 }
2687 len = intrev64(len);
2688 if rdbWriteRaw(
2689 rdb,
2690 &mut len as *mut uint64_t as *mut libc::c_void,
2691 8 as libc::c_int as size_t,
2692 ) == -(1 as libc::c_int) as libc::c_long
2693 {
2694 return -(1 as libc::c_int);
2695 }
2696 nwritten = (1 as libc::c_int + 8 as libc::c_int) as size_t;
2697 }
2698 return nwritten as libc::c_int;
2699}
2700#[no_mangle]
2701pub unsafe extern "C" fn rdbLoadLenByRef(
2702 mut rdb: *mut rio,
2703 mut isencoded: *mut libc::c_int,
2704 mut lenptr: *mut uint64_t,
2705) -> libc::c_int {
2706 let mut buf: [libc::c_uchar; 2] = [0; 2];
2707 let mut type_0: libc::c_int = 0;
2708 if !isencoded.is_null() {
2709 *isencoded = 0 as libc::c_int;
2710 }
2711 if rioRead(rdb, buf.as_mut_ptr() as *mut libc::c_void, 1 as libc::c_int as size_t)
2712 == 0 as libc::c_int as libc::c_ulong
2713 {
2714 return -(1 as libc::c_int);
2715 }
2716 type_0 = (buf[0 as libc::c_int as usize] as libc::c_int & 0xc0 as libc::c_int)
2717 >> 6 as libc::c_int;
2718 if type_0 == 3 as libc::c_int {
2719 if !isencoded.is_null() {
2720 *isencoded = 1 as libc::c_int;
2721 }
2722 *lenptr = (buf[0 as libc::c_int as usize] as libc::c_int & 0x3f as libc::c_int)
2723 as uint64_t;
2724 } else if type_0 == 0 as libc::c_int {
2725 *lenptr = (buf[0 as libc::c_int as usize] as libc::c_int & 0x3f as libc::c_int)
2726 as uint64_t;
2727 } else if type_0 == 1 as libc::c_int {
2728 if rioRead(
2729 rdb,
2730 buf.as_mut_ptr().offset(1 as libc::c_int as isize) as *mut libc::c_void,
2731 1 as libc::c_int as size_t,
2732 ) == 0 as libc::c_int as libc::c_ulong
2733 {
2734 return -(1 as libc::c_int);
2735 }
2736 *lenptr = ((buf[0 as libc::c_int as usize] as libc::c_int & 0x3f as libc::c_int)
2737 << 8 as libc::c_int | buf[1 as libc::c_int as usize] as libc::c_int)
2738 as uint64_t;
2739 } else if buf[0 as libc::c_int as usize] as libc::c_int == 0x80 as libc::c_int {
2740 let mut len: uint32_t = 0;
2741 if rioRead(
2742 rdb,
2743 &mut len as *mut uint32_t as *mut libc::c_void,
2744 4 as libc::c_int as size_t,
2745 ) == 0 as libc::c_int as libc::c_ulong
2746 {
2747 return -(1 as libc::c_int);
2748 }
2749 *lenptr = __bswap_32(len) as uint64_t;
2750 } else if buf[0 as libc::c_int as usize] as libc::c_int == 0x81 as libc::c_int {
2751 let mut len_0: uint64_t = 0;
2752 if rioRead(
2753 rdb,
2754 &mut len_0 as *mut uint64_t as *mut libc::c_void,
2755 8 as libc::c_int as size_t,
2756 ) == 0 as libc::c_int as libc::c_ulong
2757 {
2758 return -(1 as libc::c_int);
2759 }
2760 *lenptr = intrev64(len_0);
2761 } else {
2762 rdbReportError(
2763 1 as libc::c_int,
2764 237 as libc::c_int,
2765 b"Unknown length encoding %d in rdbLoadLen()\0" as *const u8
2766 as *const libc::c_char as *mut libc::c_char,
2767 type_0,
2768 );
2769 return -(1 as libc::c_int);
2770 }
2771 return 0 as libc::c_int;
2772}
2773#[no_mangle]
2774pub unsafe extern "C" fn rdbLoadLen(
2775 mut rdb: *mut rio,
2776 mut isencoded: *mut libc::c_int,
2777) -> uint64_t {
2778 let mut len: uint64_t = 0;
2779 if rdbLoadLenByRef(rdb, isencoded, &mut len) == -(1 as libc::c_int) {
2780 return 18446744073709551615 as libc::c_ulong;
2781 }
2782 return len;
2783}
2784#[no_mangle]
2785pub unsafe extern "C" fn rdbEncodeInteger(
2786 mut value: libc::c_longlong,
2787 mut enc: *mut libc::c_uchar,
2788) -> libc::c_int {
2789 if value >= -((1 as libc::c_int) << 7 as libc::c_int) as libc::c_longlong
2790 && value
2791 <= (((1 as libc::c_int) << 7 as libc::c_int) - 1 as libc::c_int)
2792 as libc::c_longlong
2793 {
2794 *enc
2795 .offset(
2796 0 as libc::c_int as isize,
2797 ) = ((3 as libc::c_int) << 6 as libc::c_int | 0 as libc::c_int)
2798 as libc::c_uchar;
2799 *enc
2800 .offset(
2801 1 as libc::c_int as isize,
2802 ) = (value & 0xff as libc::c_int as libc::c_longlong) as libc::c_uchar;
2803 return 2 as libc::c_int;
2804 } else if value >= -((1 as libc::c_int) << 15 as libc::c_int) as libc::c_longlong
2805 && value
2806 <= (((1 as libc::c_int) << 15 as libc::c_int) - 1 as libc::c_int)
2807 as libc::c_longlong
2808 {
2809 *enc
2810 .offset(
2811 0 as libc::c_int as isize,
2812 ) = ((3 as libc::c_int) << 6 as libc::c_int | 1 as libc::c_int)
2813 as libc::c_uchar;
2814 *enc
2815 .offset(
2816 1 as libc::c_int as isize,
2817 ) = (value & 0xff as libc::c_int as libc::c_longlong) as libc::c_uchar;
2818 *enc
2819 .offset(
2820 2 as libc::c_int as isize,
2821 ) = (value >> 8 as libc::c_int & 0xff as libc::c_int as libc::c_longlong)
2822 as libc::c_uchar;
2823 return 3 as libc::c_int;
2824 } else if value >= -((1 as libc::c_int as libc::c_longlong) << 31 as libc::c_int)
2825 && value
2826 <= ((1 as libc::c_int as libc::c_longlong) << 31 as libc::c_int)
2827 - 1 as libc::c_int as libc::c_longlong
2828 {
2829 *enc
2830 .offset(
2831 0 as libc::c_int as isize,
2832 ) = ((3 as libc::c_int) << 6 as libc::c_int | 2 as libc::c_int)
2833 as libc::c_uchar;
2834 *enc
2835 .offset(
2836 1 as libc::c_int as isize,
2837 ) = (value & 0xff as libc::c_int as libc::c_longlong) as libc::c_uchar;
2838 *enc
2839 .offset(
2840 2 as libc::c_int as isize,
2841 ) = (value >> 8 as libc::c_int & 0xff as libc::c_int as libc::c_longlong)
2842 as libc::c_uchar;
2843 *enc
2844 .offset(
2845 3 as libc::c_int as isize,
2846 ) = (value >> 16 as libc::c_int & 0xff as libc::c_int as libc::c_longlong)
2847 as libc::c_uchar;
2848 *enc
2849 .offset(
2850 4 as libc::c_int as isize,
2851 ) = (value >> 24 as libc::c_int & 0xff as libc::c_int as libc::c_longlong)
2852 as libc::c_uchar;
2853 return 5 as libc::c_int;
2854 } else {
2855 return 0 as libc::c_int
2856 };
2857}
2858#[no_mangle]
2859pub unsafe extern "C" fn rdbLoadIntegerObject(
2860 mut rdb: *mut rio,
2861 mut enctype: libc::c_int,
2862 mut flags: libc::c_int,
2863 mut lenptr: *mut size_t,
2864) -> *mut libc::c_void {
2865 let mut plain: libc::c_int = flags & (1 as libc::c_int) << 1 as libc::c_int;
2866 let mut sds: libc::c_int = flags & (1 as libc::c_int) << 2 as libc::c_int;
2867 let mut encode: libc::c_int = flags & (1 as libc::c_int) << 0 as libc::c_int;
2868 let mut enc: [libc::c_uchar; 4] = [0; 4];
2869 let mut val: libc::c_longlong = 0;
2870 if enctype == 0 as libc::c_int {
2871 if rioRead(
2872 rdb,
2873 enc.as_mut_ptr() as *mut libc::c_void,
2874 1 as libc::c_int as size_t,
2875 ) == 0 as libc::c_int as libc::c_ulong
2876 {
2877 return 0 as *mut libc::c_void;
2878 }
2879 val = enc[0 as libc::c_int as usize] as libc::c_schar as libc::c_longlong;
2880 } else if enctype == 1 as libc::c_int {
2881 let mut v: uint16_t = 0;
2882 if rioRead(
2883 rdb,
2884 enc.as_mut_ptr() as *mut libc::c_void,
2885 2 as libc::c_int as size_t,
2886 ) == 0 as libc::c_int as libc::c_ulong
2887 {
2888 return 0 as *mut libc::c_void;
2889 }
2890 v = (enc[0 as libc::c_int as usize] as uint32_t
2891 | (enc[1 as libc::c_int as usize] as uint32_t) << 8 as libc::c_int)
2892 as uint16_t;
2893 val = v as int16_t as libc::c_longlong;
2894 } else if enctype == 2 as libc::c_int {
2895 let mut v_0: uint32_t = 0;
2896 if rioRead(
2897 rdb,
2898 enc.as_mut_ptr() as *mut libc::c_void,
2899 4 as libc::c_int as size_t,
2900 ) == 0 as libc::c_int as libc::c_ulong
2901 {
2902 return 0 as *mut libc::c_void;
2903 }
2904 v_0 = enc[0 as libc::c_int as usize] as uint32_t
2905 | (enc[1 as libc::c_int as usize] as uint32_t) << 8 as libc::c_int
2906 | (enc[2 as libc::c_int as usize] as uint32_t) << 16 as libc::c_int
2907 | (enc[3 as libc::c_int as usize] as uint32_t) << 24 as libc::c_int;
2908 val = v_0 as int32_t as libc::c_longlong;
2909 } else {
2910 rdbReportError(
2911 1 as libc::c_int,
2912 308 as libc::c_int,
2913 b"Unknown RDB integer encoding type %d\0" as *const u8 as *const libc::c_char
2914 as *mut libc::c_char,
2915 enctype,
2916 );
2917 return 0 as *mut libc::c_void;
2918 }
2919 if plain != 0 || sds != 0 {
2920 let mut buf: [libc::c_char; 21] = [0; 21];
2921 let mut p: *mut libc::c_char = 0 as *mut libc::c_char;
2922 let mut len: libc::c_int = ll2string(
2923 buf.as_mut_ptr(),
2924 core::mem::size_of::<[libc::c_char; 21]>() as libc::c_ulong,
2925 val,
2926 );
2927 if !lenptr.is_null() {
2928 *lenptr = len as size_t;
2929 }
2930 p = (if plain != 0 {
2931 zmalloc(len as size_t)
2932 } else {
2933 sdsnewlen(SDS_NOINIT as *const libc::c_void, len as size_t)
2934 as *mut libc::c_void
2935 }) as *mut libc::c_char;
2936 memcpy(
2937 p as *mut libc::c_void,
2938 buf.as_mut_ptr() as *const libc::c_void,
2939 len as libc::c_ulong,
2940 );
2941 return p as *mut libc::c_void;
2942 } else if encode != 0 {
2943 return createStringObjectFromLongLongForValue(val) as *mut libc::c_void
2944 } else {
2945 return createObject(0 as libc::c_int, sdsfromlonglong(val) as *mut libc::c_void)
2946 as *mut libc::c_void
2947 };
2948}
2949#[no_mangle]
2950pub unsafe extern "C" fn rdbTryIntegerEncoding(
2951 mut s: *mut libc::c_char,
2952 mut len: size_t,
2953 mut enc: *mut libc::c_uchar,
2954) -> libc::c_int {
2955 let mut value: libc::c_longlong = 0;
2956 if string2ll(s, len, &mut value) != 0 {
2957 return rdbEncodeInteger(value, enc)
2958 } else {
2959 return 0 as libc::c_int
2960 };
2961}
2962#[no_mangle]
2963pub unsafe extern "C" fn rdbSaveLzfBlob(
2964 mut rdb: *mut rio,
2965 mut data: *mut libc::c_void,
2966 mut compress_len: size_t,
2967 mut original_len: size_t,
2968) -> ssize_t {
2969 let mut byte: libc::c_uchar = 0;
2970 let mut n: ssize_t = 0;
2971 let mut nwritten: ssize_t = 0 as libc::c_int as ssize_t;
2972 byte = ((3 as libc::c_int) << 6 as libc::c_int | 3 as libc::c_int) as libc::c_uchar;
2973 n = rdbWriteRaw(
2974 rdb,
2975 &mut byte as *mut libc::c_uchar as *mut libc::c_void,
2976 1 as libc::c_int as size_t,
2977 );
2978 if !(n == -(1 as libc::c_int) as libc::c_long) {
2979 nwritten += n;
2980 n = rdbSaveLen(rdb, compress_len) as ssize_t;
2981 if !(n == -(1 as libc::c_int) as libc::c_long) {
2982 nwritten += n;
2983 n = rdbSaveLen(rdb, original_len) as ssize_t;
2984 if !(n == -(1 as libc::c_int) as libc::c_long) {
2985 nwritten += n;
2986 n = rdbWriteRaw(rdb, data, compress_len);
2987 if !(n == -(1 as libc::c_int) as libc::c_long) {
2988 nwritten += n;
2989 return nwritten;
2990 }
2991 }
2992 }
2993 }
2994 return -(1 as libc::c_int) as ssize_t;
2995}
2996#[no_mangle]
2997pub unsafe extern "C" fn rdbSaveLzfStringObject(
2998 mut rdb: *mut rio,
2999 mut s: *mut libc::c_uchar,
3000 mut len: size_t,
3001) -> ssize_t {
3002 let mut comprlen: size_t = 0;
3003 let mut outlen: size_t = 0;
3004 let mut out: *mut libc::c_void = 0 as *mut libc::c_void;
3005 if len <= 4 as libc::c_int as libc::c_ulong {
3006 return 0 as libc::c_int as ssize_t;
3007 }
3008 outlen = len.wrapping_sub(4 as libc::c_int as libc::c_ulong);
3009 out = zmalloc(outlen.wrapping_add(1 as libc::c_int as libc::c_ulong));
3010 if out.is_null() {
3011 return 0 as libc::c_int as ssize_t;
3012 }
3013 comprlen = lzf_compress(s as *const libc::c_void, len, out, outlen);
3014 if comprlen == 0 as libc::c_int as libc::c_ulong {
3015 zfree(out);
3016 return 0 as libc::c_int as ssize_t;
3017 }
3018 let mut nwritten: ssize_t = rdbSaveLzfBlob(rdb, out, comprlen, len);
3019 zfree(out);
3020 return nwritten;
3021}
3022#[no_mangle]
3023pub unsafe extern "C" fn rdbLoadLzfStringObject(
3024 mut rdb: *mut rio,
3025 mut flags: libc::c_int,
3026 mut lenptr: *mut size_t,
3027) -> *mut libc::c_void {
3028 let mut plain: libc::c_int = flags & (1 as libc::c_int) << 1 as libc::c_int;
3029 let mut sds: libc::c_int = flags & (1 as libc::c_int) << 2 as libc::c_int;
3030 let mut len: uint64_t = 0;
3031 let mut clen: uint64_t = 0;
3032 let mut c: *mut libc::c_uchar = 0 as *mut libc::c_uchar;
3033 let mut val: *mut libc::c_char = 0 as *mut libc::c_char;
3034 clen = rdbLoadLen(rdb, 0 as *mut libc::c_int);
3035 if clen == 18446744073709551615 as libc::c_ulong {
3036 return 0 as *mut libc::c_void;
3037 }
3038 len = rdbLoadLen(rdb, 0 as *mut libc::c_int);
3039 if len == 18446744073709551615 as libc::c_ulong {
3040 return 0 as *mut libc::c_void;
3041 }
3042 c = ztrymalloc(clen) as *mut libc::c_uchar;
3043 if c.is_null() {
3044 if !(((if (server.current_client).is_null()
3045 || (*server.current_client).id == 18446744073709551615 as libc::c_ulong
3046 {
3047 0 as libc::c_int
3048 } else {
3049 (if 1 as libc::c_int != 0 { 1 as libc::c_int } else { 3 as libc::c_int })
3050 }) & 0xff as libc::c_int) < server.verbosity)
3051 {
3052 _serverLog(
3053 if (server.current_client).is_null()
3054 || (*server.current_client).id
3055 == 18446744073709551615 as libc::c_ulong
3056 {
3057 0 as libc::c_int
3058 } else if 1 as libc::c_int != 0 {
3059 1 as libc::c_int
3060 } else {
3061 3 as libc::c_int
3062 },
3063 b"rdbLoadLzfStringObject failed allocating %llu bytes\0" as *const u8
3064 as *const libc::c_char,
3065 clen as libc::c_ulonglong,
3066 );
3067 }
3068 } else {
3069 if plain != 0 {
3070 val = ztrymalloc(len) as *mut libc::c_char;
3071 } else {
3072 val = sdstrynewlen(SDS_NOINIT as *const libc::c_void, len);
3073 }
3074 if val.is_null() {
3075 if !(((if (server.current_client).is_null()
3076 || (*server.current_client).id == 18446744073709551615 as libc::c_ulong
3077 {
3078 0 as libc::c_int
3079 } else {
3080 (if 1 as libc::c_int != 0 { 1 as libc::c_int } else { 3 as libc::c_int })
3081 }) & 0xff as libc::c_int) < server.verbosity)
3082 {
3083 _serverLog(
3084 if (server.current_client).is_null()
3085 || (*server.current_client).id
3086 == 18446744073709551615 as libc::c_ulong
3087 {
3088 0 as libc::c_int
3089 } else if 1 as libc::c_int != 0 {
3090 1 as libc::c_int
3091 } else {
3092 3 as libc::c_int
3093 },
3094 b"rdbLoadLzfStringObject failed allocating %llu bytes\0" as *const u8
3095 as *const libc::c_char,
3096 len as libc::c_ulonglong,
3097 );
3098 }
3099 } else {
3100 if !lenptr.is_null() {
3101 *lenptr = len;
3102 }
3103 if !(rioRead(rdb, c as *mut libc::c_void, clen)
3104 == 0 as libc::c_int as libc::c_ulong)
3105 {
3106 if lzf_decompress(
3107 c as *const libc::c_void,
3108 clen,
3109 val as *mut libc::c_void,
3110 len,
3111 ) != len
3112 {
3113 rdbReportError(
3114 1 as libc::c_int,
3115 413 as libc::c_int,
3116 b"Invalid LZF compressed string\0" as *const u8
3117 as *const libc::c_char as *mut libc::c_char,
3118 );
3119 } else {
3120 zfree(c as *mut libc::c_void);
3121 if plain != 0 || sds != 0 {
3122 return val as *mut libc::c_void
3123 } else {
3124 return createObject(0 as libc::c_int, val as *mut libc::c_void)
3125 as *mut libc::c_void
3126 }
3127 }
3128 }
3129 }
3130 }
3131 zfree(c as *mut libc::c_void);
3132 if plain != 0 {
3133 zfree(val as *mut libc::c_void);
3134 } else {
3135 sdsfree(val);
3136 }
3137 return 0 as *mut libc::c_void;
3138}
3139#[no_mangle]
3140pub unsafe extern "C" fn rdbSaveRawString(
3141 mut rdb: *mut rio,
3142 mut s: *mut libc::c_uchar,
3143 mut len: size_t,
3144) -> ssize_t {
3145 let mut enclen: libc::c_int = 0;
3146 let mut n: ssize_t = 0;
3147 let mut nwritten: ssize_t = 0 as libc::c_int as ssize_t;
3148 if len <= 11 as libc::c_int as libc::c_ulong {
3149 let mut buf: [libc::c_uchar; 5] = [0; 5];
3150 enclen = rdbTryIntegerEncoding(s as *mut libc::c_char, len, buf.as_mut_ptr());
3151 if enclen > 0 as libc::c_int {
3152 if rdbWriteRaw(rdb, buf.as_mut_ptr() as *mut libc::c_void, enclen as size_t)
3153 == -(1 as libc::c_int) as libc::c_long
3154 {
3155 return -(1 as libc::c_int) as ssize_t;
3156 }
3157 return enclen as ssize_t;
3158 }
3159 }
3160 if server.rdb_compression != 0 && len > 20 as libc::c_int as libc::c_ulong {
3161 n = rdbSaveLzfStringObject(rdb, s, len);
3162 if n == -(1 as libc::c_int) as libc::c_long {
3163 return -(1 as libc::c_int) as ssize_t;
3164 }
3165 if n > 0 as libc::c_int as libc::c_long {
3166 return n;
3167 }
3168 }
3169 n = rdbSaveLen(rdb, len) as ssize_t;
3170 if n == -(1 as libc::c_int) as libc::c_long {
3171 return -(1 as libc::c_int) as ssize_t;
3172 }
3173 nwritten += n;
3174 if len > 0 as libc::c_int as libc::c_ulong {
3175 if rdbWriteRaw(rdb, s as *mut libc::c_void, len)
3176 == -(1 as libc::c_int) as libc::c_long
3177 {
3178 return -(1 as libc::c_int) as ssize_t;
3179 }
3180 nwritten = (nwritten as libc::c_ulong).wrapping_add(len) as ssize_t as ssize_t;
3181 }
3182 return nwritten;
3183}
3184#[no_mangle]
3185pub unsafe extern "C" fn rdbSaveLongLongAsStringObject(
3186 mut rdb: *mut rio,
3187 mut value: libc::c_longlong,
3188) -> ssize_t {
3189 let mut buf: [libc::c_uchar; 32] = [0; 32];
3190 let mut n: ssize_t = 0;
3191 let mut nwritten: ssize_t = 0 as libc::c_int as ssize_t;
3192 let mut enclen: libc::c_int = rdbEncodeInteger(value, buf.as_mut_ptr());
3193 if enclen > 0 as libc::c_int {
3194 return rdbWriteRaw(rdb, buf.as_mut_ptr() as *mut libc::c_void, enclen as size_t)
3195 } else {
3196 enclen = ll2string(
3197 buf.as_mut_ptr() as *mut libc::c_char,
3198 32 as libc::c_int as size_t,
3199 value,
3200 );
3201 if enclen < 32 as libc::c_int {} else {
3202 _serverAssert(
3203 b"enclen < 32\0" as *const u8 as *const libc::c_char,
3204 b"rdb.c\0" as *const u8 as *const libc::c_char,
3205 476 as libc::c_int,
3206 );
3207 unreachable!();
3208 };
3209 n = rdbSaveLen(rdb, enclen as uint64_t) as ssize_t;
3210 if n == -(1 as libc::c_int) as libc::c_long {
3211 return -(1 as libc::c_int) as ssize_t;
3212 }
3213 nwritten += n;
3214 n = rdbWriteRaw(rdb, buf.as_mut_ptr() as *mut libc::c_void, enclen as size_t);
3215 if n == -(1 as libc::c_int) as libc::c_long {
3216 return -(1 as libc::c_int) as ssize_t;
3217 }
3218 nwritten += n;
3219 }
3220 return nwritten;
3221}
3222#[no_mangle]
3223pub unsafe extern "C" fn rdbSaveStringObject(
3224 mut rdb: *mut rio,
3225 mut obj: *mut robj,
3226) -> ssize_t {
3227 if (*obj).encoding() as libc::c_int == 1 as libc::c_int {
3228 return rdbSaveLongLongAsStringObject(
3229 rdb,
3230 (*obj).ptr as libc::c_long as libc::c_longlong,
3231 )
3232 } else {
3233 if (*obj).encoding() as libc::c_int == 0 as libc::c_int
3234 || (*obj).encoding() as libc::c_int == 8 as libc::c_int
3235 {} else {
3236 _serverAssertWithInfo(
3237 0 as *const client,
3238 obj,
3239 b"sdsEncodedObject(obj)\0" as *const u8 as *const libc::c_char,
3240 b"rdb.c\0" as *const u8 as *const libc::c_char,
3241 492 as libc::c_int,
3242 );
3243 unreachable!();
3244 };
3245 return rdbSaveRawString(
3246 rdb,
3247 (*obj).ptr as *mut libc::c_uchar,
3248 sdslen((*obj).ptr as sds),
3249 );
3250 };
3251}
3252#[no_mangle]
3253pub unsafe extern "C" fn rdbGenericLoadStringObject(
3254 mut rdb: *mut rio,
3255 mut flags: libc::c_int,
3256 mut lenptr: *mut size_t,
3257) -> *mut libc::c_void {
3258 let mut encode: libc::c_int = flags & (1 as libc::c_int) << 0 as libc::c_int;
3259 let mut plain: libc::c_int = flags & (1 as libc::c_int) << 1 as libc::c_int;
3260 let mut sds: libc::c_int = flags & (1 as libc::c_int) << 2 as libc::c_int;
3261 let mut isencoded: libc::c_int = 0;
3262 let mut len: libc::c_ulonglong = 0;
3263 len = rdbLoadLen(rdb, &mut isencoded) as libc::c_ulonglong;
3264 if len == 18446744073709551615 as libc::c_ulong as libc::c_ulonglong {
3265 return 0 as *mut libc::c_void;
3266 }
3267 if isencoded != 0 {
3268 match len {
3269 0 | 1 | 2 => {
3270 return rdbLoadIntegerObject(rdb, len as libc::c_int, flags, lenptr);
3271 }
3272 3 => return rdbLoadLzfStringObject(rdb, flags, lenptr),
3273 _ => {
3274 rdbReportError(
3275 1 as libc::c_int,
3276 529 as libc::c_int,
3277 b"Unknown RDB string encoding type %llu\0" as *const u8
3278 as *const libc::c_char as *mut libc::c_char,
3279 len,
3280 );
3281 return 0 as *mut libc::c_void;
3282 }
3283 }
3284 }
3285 if plain != 0 || sds != 0 {
3286 let mut buf: *mut libc::c_void = if plain != 0 {
3287 ztrymalloc(len as size_t)
3288 } else {
3289 sdstrynewlen(SDS_NOINIT as *const libc::c_void, len as size_t)
3290 as *mut libc::c_void
3291 };
3292 if buf.is_null() {
3293 if !(((if (server.current_client).is_null()
3294 || (*server.current_client).id == 18446744073709551615 as libc::c_ulong
3295 {
3296 0 as libc::c_int
3297 } else {
3298 (if 1 as libc::c_int != 0 { 1 as libc::c_int } else { 3 as libc::c_int })
3299 }) & 0xff as libc::c_int) < server.verbosity)
3300 {
3301 _serverLog(
3302 if (server.current_client).is_null()
3303 || (*server.current_client).id
3304 == 18446744073709551615 as libc::c_ulong
3305 {
3306 0 as libc::c_int
3307 } else if 1 as libc::c_int != 0 {
3308 1 as libc::c_int
3309 } else {
3310 3 as libc::c_int
3311 },
3312 b"rdbGenericLoadStringObject failed allocating %llu bytes\0"
3313 as *const u8 as *const libc::c_char,
3314 len,
3315 );
3316 }
3317 return 0 as *mut libc::c_void;
3318 }
3319 if !lenptr.is_null() {
3320 *lenptr = len as size_t;
3321 }
3322 if len != 0
3323 && rioRead(rdb, buf, len as size_t) == 0 as libc::c_int as libc::c_ulong
3324 {
3325 if plain != 0 {
3326 zfree(buf);
3327 } else {
3328 sdsfree(buf as sds);
3329 }
3330 return 0 as *mut libc::c_void;
3331 }
3332 return buf;
3333 } else {
3334 let mut o: *mut robj = if encode != 0 {
3335 tryCreateStringObject(SDS_NOINIT, len as size_t)
3336 } else {
3337 tryCreateRawStringObject(SDS_NOINIT, len as size_t)
3338 };
3339 if o.is_null() {
3340 if !(((if (server.current_client).is_null()
3341 || (*server.current_client).id == 18446744073709551615 as libc::c_ulong
3342 {
3343 0 as libc::c_int
3344 } else {
3345 (if 1 as libc::c_int != 0 { 1 as libc::c_int } else { 3 as libc::c_int })
3346 }) & 0xff as libc::c_int) < server.verbosity)
3347 {
3348 _serverLog(
3349 if (server.current_client).is_null()
3350 || (*server.current_client).id
3351 == 18446744073709551615 as libc::c_ulong
3352 {
3353 0 as libc::c_int
3354 } else if 1 as libc::c_int != 0 {
3355 1 as libc::c_int
3356 } else {
3357 3 as libc::c_int
3358 },
3359 b"rdbGenericLoadStringObject failed allocating %llu bytes\0"
3360 as *const u8 as *const libc::c_char,
3361 len,
3362 );
3363 }
3364 return 0 as *mut libc::c_void;
3365 }
3366 if len != 0
3367 && rioRead(rdb, (*o).ptr, len as size_t) == 0 as libc::c_int as libc::c_ulong
3368 {
3369 decrRefCount(o);
3370 return 0 as *mut libc::c_void;
3371 }
3372 return o as *mut libc::c_void;
3373 };
3374}
3375#[no_mangle]
3376pub unsafe extern "C" fn rdbLoadStringObject(mut rdb: *mut rio) -> *mut robj {
3377 return rdbGenericLoadStringObject(rdb, 0 as libc::c_int, 0 as *mut size_t)
3378 as *mut robj;
3379}
3380#[no_mangle]
3381pub unsafe extern "C" fn rdbLoadEncodedStringObject(mut rdb: *mut rio) -> *mut robj {
3382 return rdbGenericLoadStringObject(
3383 rdb,
3384 (1 as libc::c_int) << 0 as libc::c_int,
3385 0 as *mut size_t,
3386 ) as *mut robj;
3387}
3388#[no_mangle]
3389pub unsafe extern "C" fn rdbSaveDoubleValue(
3390 mut rdb: *mut rio,
3391 mut val: libc::c_double,
3392) -> libc::c_int {
3393 let mut buf: [libc::c_uchar; 128] = [0; 128];
3394 let mut len: libc::c_int = 0;
3395 if val.is_nan() as i32 != 0 {
3396 buf[0 as libc::c_int as usize] = 253 as libc::c_int as libc::c_uchar;
3397 len = 1 as libc::c_int;
3398 } else if val.is_finite() as i32 == 0 {
3399 len = 1 as libc::c_int;
3400 buf[0 as libc::c_int
3401 as usize] = (if val < 0 as libc::c_int as libc::c_double {
3402 255 as libc::c_int
3403 } else {
3404 254 as libc::c_int
3405 }) as libc::c_uchar;
3406 } else {
3407 let mut lvalue: libc::c_longlong = 0;
3408 if double2ll(val, &mut lvalue) != 0 {
3409 ll2string(
3410 (buf.as_mut_ptr() as *mut libc::c_char)
3411 .offset(1 as libc::c_int as isize),
3412 (core::mem::size_of::<[libc::c_uchar; 128]>() as libc::c_ulong)
3413 .wrapping_sub(1 as libc::c_int as libc::c_ulong),
3414 lvalue,
3415 );
3416 } else {
3417 snprintf(
3418 (buf.as_mut_ptr() as *mut libc::c_char)
3419 .offset(1 as libc::c_int as isize),
3420 (core::mem::size_of::<[libc::c_uchar; 128]>() as libc::c_ulong)
3421 .wrapping_sub(1 as libc::c_int as libc::c_ulong),
3422 b"%.17g\0" as *const u8 as *const libc::c_char,
3423 val,
3424 );
3425 }
3426 buf[0 as libc::c_int
3427 as usize] = strlen(
3428 (buf.as_mut_ptr() as *mut libc::c_char).offset(1 as libc::c_int as isize),
3429 ) as libc::c_uchar;
3430 len = buf[0 as libc::c_int as usize] as libc::c_int + 1 as libc::c_int;
3431 }
3432 return rdbWriteRaw(rdb, buf.as_mut_ptr() as *mut libc::c_void, len as size_t)
3433 as libc::c_int;
3434}
3435#[no_mangle]
3436pub unsafe extern "C" fn rdbLoadDoubleValue(
3437 mut rdb: *mut rio,
3438 mut val: *mut libc::c_double,
3439) -> libc::c_int {
3440 let mut buf: [libc::c_char; 256] = [0; 256];
3441 let mut len: libc::c_uchar = 0;
3442 if rioRead(
3443 rdb,
3444 &mut len as *mut libc::c_uchar as *mut libc::c_void,
3445 1 as libc::c_int as size_t,
3446 ) == 0 as libc::c_int as libc::c_ulong
3447 {
3448 return -(1 as libc::c_int);
3449 }
3450 match len as libc::c_int {
3451 255 => {
3452 *val = R_NegInf;
3453 return 0 as libc::c_int;
3454 }
3455 254 => {
3456 *val = R_PosInf;
3457 return 0 as libc::c_int;
3458 }
3459 253 => {
3460 *val = R_Nan;
3461 return 0 as libc::c_int;
3462 }
3463 _ => {
3464 if rioRead(rdb, buf.as_mut_ptr() as *mut libc::c_void, len as size_t)
3465 == 0 as libc::c_int as libc::c_ulong
3466 {
3467 return -(1 as libc::c_int);
3468 }
3469 buf[len as usize] = '\0' as i32 as libc::c_char;
3470 if sscanf(
3471 buf.as_mut_ptr(),
3472 b"%lg\0" as *const u8 as *const libc::c_char,
3473 val,
3474 ) != 1 as libc::c_int
3475 {
3476 return -(1 as libc::c_int);
3477 }
3478 return 0 as libc::c_int;
3479 }
3480 };
3481}
3482#[no_mangle]
3483pub unsafe extern "C" fn rdbSaveBinaryDoubleValue(
3484 mut rdb: *mut rio,
3485 mut val: libc::c_double,
3486) -> libc::c_int {
3487 return rdbWriteRaw(
3488 rdb,
3489 &mut val as *mut libc::c_double as *mut libc::c_void,
3490 core::mem::size_of::<libc::c_double>() as libc::c_ulong,
3491 ) as libc::c_int;
3492}
3493#[no_mangle]
3494pub unsafe extern "C" fn rdbLoadBinaryDoubleValue(
3495 mut rdb: *mut rio,
3496 mut val: *mut libc::c_double,
3497) -> libc::c_int {
3498 if rioRead(
3499 rdb,
3500 val as *mut libc::c_void,
3501 core::mem::size_of::<libc::c_double>() as libc::c_ulong,
3502 ) == 0 as libc::c_int as libc::c_ulong
3503 {
3504 return -(1 as libc::c_int);
3505 }
3506 return 0 as libc::c_int;
3507}
3508#[no_mangle]
3509pub unsafe extern "C" fn rdbSaveBinaryFloatValue(
3510 mut rdb: *mut rio,
3511 mut val: libc::c_float,
3512) -> libc::c_int {
3513 return rdbWriteRaw(
3514 rdb,
3515 &mut val as *mut libc::c_float as *mut libc::c_void,
3516 core::mem::size_of::<libc::c_float>() as libc::c_ulong,
3517 ) as libc::c_int;
3518}
3519#[no_mangle]
3520pub unsafe extern "C" fn rdbLoadBinaryFloatValue(
3521 mut rdb: *mut rio,
3522 mut val: *mut libc::c_float,
3523) -> libc::c_int {
3524 if rioRead(
3525 rdb,
3526 val as *mut libc::c_void,
3527 core::mem::size_of::<libc::c_float>() as libc::c_ulong,
3528 ) == 0 as libc::c_int as libc::c_ulong
3529 {
3530 return -(1 as libc::c_int);
3531 }
3532 return 0 as libc::c_int;
3533}
3534#[no_mangle]
3535pub unsafe extern "C" fn rdbSaveObjectType(
3536 mut rdb: *mut rio,
3537 mut o: *mut robj,
3538) -> libc::c_int {
3539 's_100: {
3540 let mut current_block_21: u64;
3541 match (*o).type_0() as libc::c_int {
3542 0 => return rdbSaveType(rdb, 0 as libc::c_int as libc::c_uchar),
3543 1 => {
3544 if (*o).encoding() as libc::c_int == 9 as libc::c_int {
3545 return rdbSaveType(rdb, 18 as libc::c_int as libc::c_uchar)
3546 } else {
3547 _serverPanic(
3548 b"rdb.c\0" as *const u8 as *const libc::c_char,
3549 661 as libc::c_int,
3550 b"Unknown list encoding\0" as *const u8 as *const libc::c_char,
3551 );
3552 unreachable!();
3553 }
3554 current_block_21 = 9205717943706311272;
3555 }
3556 2 => {
3557 current_block_21 = 9205717943706311272;
3558 }
3559 3 => {
3560 current_block_21 = 1760194286177680343;
3561 }
3562 4 => {
3563 current_block_21 = 459104737412379174;
3564 }
3565 6 => {
3566 current_block_21 = 1017447862132263635;
3567 }
3568 5 => return rdbSaveType(rdb, 7 as libc::c_int as libc::c_uchar),
3569 _ => {
3570 _serverPanic(
3571 b"rdb.c\0" as *const u8 as *const libc::c_char,
3572 688 as libc::c_int,
3573 b"Unknown object type\0" as *const u8 as *const libc::c_char,
3574 );
3575 unreachable!();
3576 break 's_100;
3577 }
3578 }
3579 match current_block_21 {
3580 9205717943706311272 => {
3581 if (*o).encoding() as libc::c_int == 6 as libc::c_int {
3582 return rdbSaveType(rdb, 11 as libc::c_int as libc::c_uchar)
3583 } else {
3584 if (*o).encoding() as libc::c_int == 2 as libc::c_int {
3585 return rdbSaveType(rdb, 2 as libc::c_int as libc::c_uchar)
3586 } else {
3587 _serverPanic(
3588 b"rdb.c\0" as *const u8 as *const libc::c_char,
3589 668 as libc::c_int,
3590 b"Unknown set encoding\0" as *const u8 as *const libc::c_char,
3591 );
3592 unreachable!();
3593 }
3594 }
3595 current_block_21 = 1760194286177680343;
3596 }
3597 _ => {}
3598 }
3599 match current_block_21 {
3600 1760194286177680343 => {
3601 if (*o).encoding() as libc::c_int == 11 as libc::c_int {
3602 return rdbSaveType(rdb, 17 as libc::c_int as libc::c_uchar)
3603 } else {
3604 if (*o).encoding() as libc::c_int == 7 as libc::c_int {
3605 return rdbSaveType(rdb, 5 as libc::c_int as libc::c_uchar)
3606 } else {
3607 _serverPanic(
3608 b"rdb.c\0" as *const u8 as *const libc::c_char,
3609 675 as libc::c_int,
3610 b"Unknown sorted set encoding\0" as *const u8
3611 as *const libc::c_char,
3612 );
3613 unreachable!();
3614 }
3615 }
3616 current_block_21 = 459104737412379174;
3617 }
3618 _ => {}
3619 }
3620 match current_block_21 {
3621 459104737412379174 => {
3622 if (*o).encoding() as libc::c_int == 11 as libc::c_int {
3623 return rdbSaveType(rdb, 16 as libc::c_int as libc::c_uchar)
3624 } else {
3625 if (*o).encoding() as libc::c_int == 2 as libc::c_int {
3626 return rdbSaveType(rdb, 4 as libc::c_int as libc::c_uchar)
3627 } else {
3628 _serverPanic(
3629 b"rdb.c\0" as *const u8 as *const libc::c_char,
3630 682 as libc::c_int,
3631 b"Unknown hash encoding\0" as *const u8
3632 as *const libc::c_char,
3633 );
3634 unreachable!();
3635 }
3636 }
3637 }
3638 _ => {}
3639 }
3640 return rdbSaveType(rdb, 19 as libc::c_int as libc::c_uchar);
3641 }
3642 return -(1 as libc::c_int);
3643}
3644#[no_mangle]
3645pub unsafe extern "C" fn rdbLoadObjectType(mut rdb: *mut rio) -> libc::c_int {
3646 let mut type_0: libc::c_int = 0;
3647 type_0 = rdbLoadType(rdb);
3648 if type_0 == -(1 as libc::c_int) {
3649 return -(1 as libc::c_int);
3650 }
3651 if !(type_0 >= 0 as libc::c_int && type_0 <= 7 as libc::c_int
3652 || type_0 >= 9 as libc::c_int && type_0 <= 19 as libc::c_int)
3653 {
3654 return -(1 as libc::c_int);
3655 }
3656 return type_0;
3657}
3658#[no_mangle]
3659pub unsafe extern "C" fn rdbSaveStreamPEL(
3660 mut rdb: *mut rio,
3661 mut pel: *mut rax,
3662 mut nacks: libc::c_int,
3663) -> ssize_t {
3664 let mut n: ssize_t = 0;
3665 let mut nwritten: ssize_t = 0 as libc::c_int as ssize_t;
3666 n = rdbSaveLen(rdb, raxSize(pel)) as ssize_t;
3667 if n == -(1 as libc::c_int) as libc::c_long {
3668 return -(1 as libc::c_int) as ssize_t;
3669 }
3670 nwritten += n;
3671 let mut ri: raxIterator = raxIterator {
3672 flags: 0,
3673 rt: 0 as *mut rax,
3674 key: 0 as *mut libc::c_uchar,
3675 data: 0 as *mut libc::c_void,
3676 key_len: 0,
3677 key_max: 0,
3678 key_static_string: [0; 128],
3679 node: 0 as *mut raxNode,
3680 stack: raxStack {
3681 stack: 0 as *mut *mut libc::c_void,
3682 items: 0,
3683 maxitems: 0,
3684 static_items: [0 as *mut libc::c_void; 32],
3685 oom: 0,
3686 },
3687 node_cb: None,
3688 };
3689 raxStart(&mut ri, pel);
3690 raxSeek(
3691 &mut ri,
3692 b"^\0" as *const u8 as *const libc::c_char,
3693 0 as *mut libc::c_uchar,
3694 0 as libc::c_int as size_t,
3695 );
3696 while raxNext(&mut ri) != 0 {
3697 n = rdbWriteRaw(
3698 rdb,
3699 ri.key as *mut libc::c_void,
3700 core::mem::size_of::<streamID>() as libc::c_ulong,
3701 );
3702 if n == -(1 as libc::c_int) as libc::c_long {
3703 raxStop(&mut ri);
3704 return -(1 as libc::c_int) as ssize_t;
3705 }
3706 nwritten += n;
3707 if nacks != 0 {
3708 let mut nack: *mut streamNACK = ri.data as *mut streamNACK;
3709 n = rdbSaveMillisecondTime(rdb, (*nack).delivery_time) as ssize_t;
3710 if n == -(1 as libc::c_int) as libc::c_long {
3711 raxStop(&mut ri);
3712 return -(1 as libc::c_int) as ssize_t;
3713 }
3714 nwritten += n;
3715 n = rdbSaveLen(rdb, (*nack).delivery_count) as ssize_t;
3716 if n == -(1 as libc::c_int) as libc::c_long {
3717 raxStop(&mut ri);
3718 return -(1 as libc::c_int) as ssize_t;
3719 }
3720 nwritten += n;
3721 }
3722 }
3723 raxStop(&mut ri);
3724 return nwritten;
3725}
3726#[no_mangle]
3727pub unsafe extern "C" fn rdbSaveStreamConsumers(
3728 mut rdb: *mut rio,
3729 mut cg: *mut streamCG,
3730) -> size_t {
3731 let mut n: ssize_t = 0;
3732 let mut nwritten: ssize_t = 0 as libc::c_int as ssize_t;
3733 n = rdbSaveLen(rdb, raxSize((*cg).consumers)) as ssize_t;
3734 if n == -(1 as libc::c_int) as libc::c_long {
3735 return -(1 as libc::c_int) as size_t;
3736 }
3737 nwritten += n;
3738 let mut ri: raxIterator = raxIterator {
3739 flags: 0,
3740 rt: 0 as *mut rax,
3741 key: 0 as *mut libc::c_uchar,
3742 data: 0 as *mut libc::c_void,
3743 key_len: 0,
3744 key_max: 0,
3745 key_static_string: [0; 128],
3746 node: 0 as *mut raxNode,
3747 stack: raxStack {
3748 stack: 0 as *mut *mut libc::c_void,
3749 items: 0,
3750 maxitems: 0,
3751 static_items: [0 as *mut libc::c_void; 32],
3752 oom: 0,
3753 },
3754 node_cb: None,
3755 };
3756 raxStart(&mut ri, (*cg).consumers);
3757 raxSeek(
3758 &mut ri,
3759 b"^\0" as *const u8 as *const libc::c_char,
3760 0 as *mut libc::c_uchar,
3761 0 as libc::c_int as size_t,
3762 );
3763 while raxNext(&mut ri) != 0 {
3764 let mut consumer: *mut streamConsumer = ri.data as *mut streamConsumer;
3765 n = rdbSaveRawString(rdb, ri.key, ri.key_len);
3766 if n == -(1 as libc::c_int) as libc::c_long {
3767 raxStop(&mut ri);
3768 return -(1 as libc::c_int) as size_t;
3769 }
3770 nwritten += n;
3771 n = rdbSaveMillisecondTime(rdb, (*consumer).seen_time) as ssize_t;
3772 if n == -(1 as libc::c_int) as libc::c_long {
3773 raxStop(&mut ri);
3774 return -(1 as libc::c_int) as size_t;
3775 }
3776 nwritten += n;
3777 n = rdbSaveStreamPEL(rdb, (*consumer).pel, 0 as libc::c_int);
3778 if n == -(1 as libc::c_int) as libc::c_long {
3779 raxStop(&mut ri);
3780 return -(1 as libc::c_int) as size_t;
3781 }
3782 nwritten += n;
3783 }
3784 raxStop(&mut ri);
3785 return nwritten as size_t;
3786}
3787#[no_mangle]
3788pub unsafe extern "C" fn rdbSaveObject(
3789 mut rdb: *mut rio,
3790 mut o: *mut robj,
3791 mut key: *mut robj,
3792 mut dbid: libc::c_int,
3793) -> ssize_t {
3794 let mut n: ssize_t = 0 as libc::c_int as ssize_t;
3795 let mut nwritten: ssize_t = 0 as libc::c_int as ssize_t;
3796 if (*o).type_0() as libc::c_int == 0 as libc::c_int {
3797 n = rdbSaveStringObject(rdb, o);
3798 if n == -(1 as libc::c_int) as libc::c_long {
3799 return -(1 as libc::c_int) as ssize_t;
3800 }
3801 nwritten += n;
3802 } else if (*o).type_0() as libc::c_int == 1 as libc::c_int {
3803 if (*o).encoding() as libc::c_int == 9 as libc::c_int {
3804 let mut ql: *mut quicklist = (*o).ptr as *mut quicklist;
3805 let mut node: *mut quicklistNode = (*ql).head;
3806 n = rdbSaveLen(rdb, (*ql).len) as ssize_t;
3807 if n == -(1 as libc::c_int) as libc::c_long {
3808 return -(1 as libc::c_int) as ssize_t;
3809 }
3810 nwritten += n;
3811 while !node.is_null() {
3812 n = rdbSaveLen(rdb, (*node).container() as uint64_t) as ssize_t;
3813 if n == -(1 as libc::c_int) as libc::c_long {
3814 return -(1 as libc::c_int) as ssize_t;
3815 }
3816 nwritten += n;
3817 if (*node).encoding() as libc::c_int == 2 as libc::c_int {
3818 let mut data: *mut libc::c_void = 0 as *mut libc::c_void;
3819 let mut compress_len: size_t = quicklistGetLzf(node, &mut data);
3820 n = rdbSaveLzfBlob(rdb, data, compress_len, (*node).sz);
3821 if n == -(1 as libc::c_int) as libc::c_long {
3822 return -(1 as libc::c_int) as ssize_t;
3823 }
3824 nwritten += n;
3825 } else {
3826 n = rdbSaveRawString(rdb, (*node).entry, (*node).sz);
3827 if n == -(1 as libc::c_int) as libc::c_long {
3828 return -(1 as libc::c_int) as ssize_t;
3829 }
3830 nwritten += n;
3831 }
3832 node = (*node).next;
3833 }
3834 } else {
3835 _serverPanic(
3836 b"rdb.c\0" as *const u8 as *const libc::c_char,
3837 829 as libc::c_int,
3838 b"Unknown list encoding\0" as *const u8 as *const libc::c_char,
3839 );
3840 unreachable!();
3841 }
3842 } else if (*o).type_0() as libc::c_int == 2 as libc::c_int {
3843 if (*o).encoding() as libc::c_int == 2 as libc::c_int {
3844 let mut set: *mut dict = (*o).ptr as *mut dict;
3845 let mut di: *mut dictIterator = dictGetIterator(set);
3846 let mut de: *mut dictEntry = 0 as *mut dictEntry;
3847 n = rdbSaveLen(
3848 rdb,
3849 ((*set).ht_used[0 as libc::c_int as usize])
3850 .wrapping_add((*set).ht_used[1 as libc::c_int as usize]),
3851 ) as ssize_t;
3852 if n == -(1 as libc::c_int) as libc::c_long {
3853 dictReleaseIterator(di);
3854 return -(1 as libc::c_int) as ssize_t;
3855 }
3856 nwritten += n;
3857 loop {
3858 de = dictNext(di);
3859 if de.is_null() {
3860 break;
3861 }
3862 let mut ele: sds = (*de).key as sds;
3863 n = rdbSaveRawString(rdb, ele as *mut libc::c_uchar, sdslen(ele));
3864 if n == -(1 as libc::c_int) as libc::c_long {
3865 dictReleaseIterator(di);
3866 return -(1 as libc::c_int) as ssize_t;
3867 }
3868 nwritten += n;
3869 }
3870 dictReleaseIterator(di);
3871 } else if (*o).encoding() as libc::c_int == 6 as libc::c_int {
3872 let mut l: size_t = intsetBlobLen((*o).ptr as *mut intset);
3873 n = rdbSaveRawString(rdb, (*o).ptr as *mut libc::c_uchar, l);
3874 if n == -(1 as libc::c_int) as libc::c_long {
3875 return -(1 as libc::c_int) as ssize_t;
3876 }
3877 nwritten += n;
3878 } else {
3879 _serverPanic(
3880 b"rdb.c\0" as *const u8 as *const libc::c_char,
3881 861 as libc::c_int,
3882 b"Unknown set encoding\0" as *const u8 as *const libc::c_char,
3883 );
3884 unreachable!();
3885 }
3886 } else if (*o).type_0() as libc::c_int == 3 as libc::c_int {
3887 if (*o).encoding() as libc::c_int == 11 as libc::c_int {
3888 let mut l_0: size_t = lpBytes((*o).ptr as *mut libc::c_uchar);
3889 n = rdbSaveRawString(rdb, (*o).ptr as *mut libc::c_uchar, l_0);
3890 if n == -(1 as libc::c_int) as libc::c_long {
3891 return -(1 as libc::c_int) as ssize_t;
3892 }
3893 nwritten += n;
3894 } else if (*o).encoding() as libc::c_int == 7 as libc::c_int {
3895 let mut zs: *mut zset = (*o).ptr as *mut zset;
3896 let mut zsl: *mut zskiplist = (*zs).zsl;
3897 n = rdbSaveLen(rdb, (*zsl).length) as ssize_t;
3898 if n == -(1 as libc::c_int) as libc::c_long {
3899 return -(1 as libc::c_int) as ssize_t;
3900 }
3901 nwritten += n;
3902 let mut zn: *mut zskiplistNode = (*zsl).tail;
3903 while !zn.is_null() {
3904 n = rdbSaveRawString(
3905 rdb,
3906 (*zn).ele as *mut libc::c_uchar,
3907 sdslen((*zn).ele),
3908 );
3909 if n == -(1 as libc::c_int) as libc::c_long {
3910 return -(1 as libc::c_int) as ssize_t;
3911 }
3912 nwritten += n;
3913 n = rdbSaveBinaryDoubleValue(rdb, (*zn).score) as ssize_t;
3914 if n == -(1 as libc::c_int) as libc::c_long {
3915 return -(1 as libc::c_int) as ssize_t;
3916 }
3917 nwritten += n;
3918 zn = (*zn).backward;
3919 }
3920 } else {
3921 _serverPanic(
3922 b"rdb.c\0" as *const u8 as *const libc::c_char,
3923 897 as libc::c_int,
3924 b"Unknown sorted set encoding\0" as *const u8 as *const libc::c_char,
3925 );
3926 unreachable!();
3927 }
3928 } else if (*o).type_0() as libc::c_int == 4 as libc::c_int {
3929 if (*o).encoding() as libc::c_int == 11 as libc::c_int {
3930 let mut l_1: size_t = lpBytes((*o).ptr as *mut libc::c_uchar);
3931 n = rdbSaveRawString(rdb, (*o).ptr as *mut libc::c_uchar, l_1);
3932 if n == -(1 as libc::c_int) as libc::c_long {
3933 return -(1 as libc::c_int) as ssize_t;
3934 }
3935 nwritten += n;
3936 } else if (*o).encoding() as libc::c_int == 2 as libc::c_int {
3937 let mut di_0: *mut dictIterator = dictGetIterator((*o).ptr as *mut dict);
3938 let mut de_0: *mut dictEntry = 0 as *mut dictEntry;
3939 n = rdbSaveLen(
3940 rdb,
3941 ((*((*o).ptr as *mut dict)).ht_used[0 as libc::c_int as usize])
3942 .wrapping_add(
3943 (*((*o).ptr as *mut dict)).ht_used[1 as libc::c_int as usize],
3944 ),
3945 ) as ssize_t;
3946 if n == -(1 as libc::c_int) as libc::c_long {
3947 dictReleaseIterator(di_0);
3948 return -(1 as libc::c_int) as ssize_t;
3949 }
3950 nwritten += n;
3951 loop {
3952 de_0 = dictNext(di_0);
3953 if de_0.is_null() {
3954 break;
3955 }
3956 let mut field: sds = (*de_0).key as sds;
3957 let mut value: sds = (*de_0).v.val as sds;
3958 n = rdbSaveRawString(rdb, field as *mut libc::c_uchar, sdslen(field));
3959 if n == -(1 as libc::c_int) as libc::c_long {
3960 dictReleaseIterator(di_0);
3961 return -(1 as libc::c_int) as ssize_t;
3962 }
3963 nwritten += n;
3964 n = rdbSaveRawString(rdb, value as *mut libc::c_uchar, sdslen(value));
3965 if n == -(1 as libc::c_int) as libc::c_long {
3966 dictReleaseIterator(di_0);
3967 return -(1 as libc::c_int) as ssize_t;
3968 }
3969 nwritten += n;
3970 }
3971 dictReleaseIterator(di_0);
3972 } else {
3973 _serverPanic(
3974 b"rdb.c\0" as *const u8 as *const libc::c_char,
3975 937 as libc::c_int,
3976 b"Unknown hash encoding\0" as *const u8 as *const libc::c_char,
3977 );
3978 unreachable!();
3979 }
3980 } else if (*o).type_0() as libc::c_int == 6 as libc::c_int {
3981 let mut s: *mut stream = (*o).ptr as *mut stream;
3982 let mut rax: *mut rax = (*s).rax;
3983 n = rdbSaveLen(rdb, raxSize(rax)) as ssize_t;
3984 if n == -(1 as libc::c_int) as libc::c_long {
3985 return -(1 as libc::c_int) as ssize_t;
3986 }
3987 nwritten += n;
3988 let mut ri: raxIterator = raxIterator {
3989 flags: 0,
3990 rt: 0 as *mut rax,
3991 key: 0 as *mut libc::c_uchar,
3992 data: 0 as *mut libc::c_void,
3993 key_len: 0,
3994 key_max: 0,
3995 key_static_string: [0; 128],
3996 node: 0 as *mut raxNode,
3997 stack: raxStack {
3998 stack: 0 as *mut *mut libc::c_void,
3999 items: 0,
4000 maxitems: 0,
4001 static_items: [0 as *mut libc::c_void; 32],
4002 oom: 0,
4003 },
4004 node_cb: None,
4005 };
4006 raxStart(&mut ri, rax);
4007 raxSeek(
4008 &mut ri,
4009 b"^\0" as *const u8 as *const libc::c_char,
4010 0 as *mut libc::c_uchar,
4011 0 as libc::c_int as size_t,
4012 );
4013 while raxNext(&mut ri) != 0 {
4014 let mut lp: *mut libc::c_uchar = ri.data as *mut libc::c_uchar;
4015 let mut lp_bytes: size_t = lpBytes(lp);
4016 n = rdbSaveRawString(rdb, ri.key, ri.key_len);
4017 if n == -(1 as libc::c_int) as libc::c_long {
4018 raxStop(&mut ri);
4019 return -(1 as libc::c_int) as ssize_t;
4020 }
4021 nwritten += n;
4022 n = rdbSaveRawString(rdb, lp, lp_bytes);
4023 if n == -(1 as libc::c_int) as libc::c_long {
4024 raxStop(&mut ri);
4025 return -(1 as libc::c_int) as ssize_t;
4026 }
4027 nwritten += n;
4028 }
4029 raxStop(&mut ri);
4030 n = rdbSaveLen(rdb, (*s).length) as ssize_t;
4031 if n == -(1 as libc::c_int) as libc::c_long {
4032 return -(1 as libc::c_int) as ssize_t;
4033 }
4034 nwritten += n;
4035 n = rdbSaveLen(rdb, (*s).last_id.ms) as ssize_t;
4036 if n == -(1 as libc::c_int) as libc::c_long {
4037 return -(1 as libc::c_int) as ssize_t;
4038 }
4039 nwritten += n;
4040 n = rdbSaveLen(rdb, (*s).last_id.seq) as ssize_t;
4041 if n == -(1 as libc::c_int) as libc::c_long {
4042 return -(1 as libc::c_int) as ssize_t;
4043 }
4044 nwritten += n;
4045 n = rdbSaveLen(rdb, (*s).first_id.ms) as ssize_t;
4046 if n == -(1 as libc::c_int) as libc::c_long {
4047 return -(1 as libc::c_int) as ssize_t;
4048 }
4049 nwritten += n;
4050 n = rdbSaveLen(rdb, (*s).first_id.seq) as ssize_t;
4051 if n == -(1 as libc::c_int) as libc::c_long {
4052 return -(1 as libc::c_int) as ssize_t;
4053 }
4054 nwritten += n;
4055 n = rdbSaveLen(rdb, (*s).max_deleted_entry_id.ms) as ssize_t;
4056 if n == -(1 as libc::c_int) as libc::c_long {
4057 return -(1 as libc::c_int) as ssize_t;
4058 }
4059 nwritten += n;
4060 n = rdbSaveLen(rdb, (*s).max_deleted_entry_id.seq) as ssize_t;
4061 if n == -(1 as libc::c_int) as libc::c_long {
4062 return -(1 as libc::c_int) as ssize_t;
4063 }
4064 nwritten += n;
4065 n = rdbSaveLen(rdb, (*s).entries_added) as ssize_t;
4066 if n == -(1 as libc::c_int) as libc::c_long {
4067 return -(1 as libc::c_int) as ssize_t;
4068 }
4069 nwritten += n;
4070 let mut num_cgroups: size_t = if !((*s).cgroups).is_null() {
4071 raxSize((*s).cgroups)
4072 } else {
4073 0 as libc::c_int as libc::c_ulong
4074 };
4075 n = rdbSaveLen(rdb, num_cgroups) as ssize_t;
4076 if n == -(1 as libc::c_int) as libc::c_long {
4077 return -(1 as libc::c_int) as ssize_t;
4078 }
4079 nwritten += n;
4080 if num_cgroups != 0 {
4081 raxStart(&mut ri, (*s).cgroups);
4082 raxSeek(
4083 &mut ri,
4084 b"^\0" as *const u8 as *const libc::c_char,
4085 0 as *mut libc::c_uchar,
4086 0 as libc::c_int as size_t,
4087 );
4088 while raxNext(&mut ri) != 0 {
4089 let mut cg: *mut streamCG = ri.data as *mut streamCG;
4090 n = rdbSaveRawString(rdb, ri.key, ri.key_len);
4091 if n == -(1 as libc::c_int) as libc::c_long {
4092 raxStop(&mut ri);
4093 return -(1 as libc::c_int) as ssize_t;
4094 }
4095 nwritten += n;
4096 n = rdbSaveLen(rdb, (*cg).last_id.ms) as ssize_t;
4097 if n == -(1 as libc::c_int) as libc::c_long {
4098 raxStop(&mut ri);
4099 return -(1 as libc::c_int) as ssize_t;
4100 }
4101 nwritten += n;
4102 n = rdbSaveLen(rdb, (*cg).last_id.seq) as ssize_t;
4103 if n == -(1 as libc::c_int) as libc::c_long {
4104 raxStop(&mut ri);
4105 return -(1 as libc::c_int) as ssize_t;
4106 }
4107 nwritten += n;
4108 n = rdbSaveLen(rdb, (*cg).entries_read as uint64_t) as ssize_t;
4109 if n == -(1 as libc::c_int) as libc::c_long {
4110 raxStop(&mut ri);
4111 return -(1 as libc::c_int) as ssize_t;
4112 }
4113 nwritten += n;
4114 n = rdbSaveStreamPEL(rdb, (*cg).pel, 1 as libc::c_int);
4115 if n == -(1 as libc::c_int) as libc::c_long {
4116 raxStop(&mut ri);
4117 return -(1 as libc::c_int) as ssize_t;
4118 }
4119 nwritten += n;
4120 n = rdbSaveStreamConsumers(rdb, cg) as ssize_t;
4121 if n == -(1 as libc::c_int) as libc::c_long {
4122 raxStop(&mut ri);
4123 return -(1 as libc::c_int) as ssize_t;
4124 }
4125 nwritten += n;
4126 }
4127 raxStop(&mut ri);
4128 }
4129 } else if (*o).type_0() as libc::c_int == 5 as libc::c_int {
4130 let mut io: RedisModuleIO = RedisModuleIO {
4131 bytes: 0,
4132 rio: 0 as *mut rio,
4133 type_0: 0 as *mut moduleType,
4134 error: 0,
4135 ver: 0,
4136 ctx: 0 as *mut RedisModuleCtx,
4137 key: 0 as *mut redisObject,
4138 dbid: 0,
4139 };
4140 let mut mv: *mut moduleValue = (*o).ptr as *mut moduleValue;
4141 let mut mt: *mut moduleType = (*mv).type_0;
4142 let mut retval: libc::c_int = rdbSaveLen(rdb, (*mt).id);
4143 if retval == -(1 as libc::c_int) {
4144 return -(1 as libc::c_int) as ssize_t;
4145 }
4146 io.rio = rdb;
4147 io.type_0 = mt;
4148 io.bytes = 0 as libc::c_int as size_t;
4149 io.error = 0 as libc::c_int;
4150 io.ver = 0 as libc::c_int;
4151 io.key = key;
4152 io.dbid = dbid;
4153 io.ctx = 0 as *mut RedisModuleCtx;
4154 io
4155 .bytes = (io.bytes as libc::c_ulong).wrapping_add(retval as libc::c_ulong)
4156 as size_t as size_t;
4157 ((*mt).rdb_save).expect("non-null function pointer")(&mut io, (*mv).value);
4158 retval = rdbSaveLen(rdb, 0 as libc::c_int as uint64_t);
4159 if retval == -(1 as libc::c_int) {
4160 io.error = 1 as libc::c_int;
4161 } else {
4162 io
4163 .bytes = (io.bytes as libc::c_ulong)
4164 .wrapping_add(retval as libc::c_ulong) as size_t as size_t;
4165 }
4166 if !(io.ctx).is_null() {
4167 moduleFreeContext(io.ctx);
4168 zfree(io.ctx as *mut libc::c_void);
4169 }
4170 return if io.error != 0 {
4171 -(1 as libc::c_int) as libc::c_long
4172 } else {
4173 io.bytes as ssize_t
4174 };
4175 } else {
4176 _serverPanic(
4177 b"rdb.c\0" as *const u8 as *const libc::c_char,
4178 1076 as libc::c_int,
4179 b"Unknown object type\0" as *const u8 as *const libc::c_char,
4180 );
4181 unreachable!();
4182 }
4183 return nwritten;
4184}
4185#[no_mangle]
4186pub unsafe extern "C" fn rdbSavedObjectLen(
4187 mut o: *mut robj,
4188 mut key: *mut robj,
4189 mut dbid: libc::c_int,
4190) -> size_t {
4191 let mut len: ssize_t = rdbSaveObject(0 as *mut rio, o, key, dbid);
4192 if len != -(1 as libc::c_int) as libc::c_long {} else {
4193 _serverAssertWithInfo(
4194 0 as *const client,
4195 o,
4196 b"len != -1\0" as *const u8 as *const libc::c_char,
4197 b"rdb.c\0" as *const u8 as *const libc::c_char,
4198 1087 as libc::c_int,
4199 );
4200 unreachable!();
4201 };
4202 return len as size_t;
4203}
4204#[no_mangle]
4205pub unsafe extern "C" fn rdbSaveKeyValuePair(
4206 mut rdb: *mut rio,
4207 mut key: *mut robj,
4208 mut val: *mut robj,
4209 mut expiretime: libc::c_longlong,
4210 mut dbid: libc::c_int,
4211) -> libc::c_int {
4212 let mut savelru: libc::c_int = server.maxmemory_policy
4213 & (1 as libc::c_int) << 0 as libc::c_int;
4214 let mut savelfu: libc::c_int = server.maxmemory_policy
4215 & (1 as libc::c_int) << 1 as libc::c_int;
4216 if expiretime != -(1 as libc::c_int) as libc::c_longlong {
4217 if rdbSaveType(rdb, 252 as libc::c_int as libc::c_uchar) == -(1 as libc::c_int) {
4218 return -(1 as libc::c_int);
4219 }
4220 if rdbSaveMillisecondTime(rdb, expiretime) == -(1 as libc::c_int) {
4221 return -(1 as libc::c_int);
4222 }
4223 }
4224 if savelru != 0 {
4225 let mut idletime: uint64_t = estimateObjectIdleTime(val) as uint64_t;
4226 idletime = (idletime as libc::c_ulong)
4227 .wrapping_div(1000 as libc::c_int as libc::c_ulong) as uint64_t as uint64_t;
4228 if rdbSaveType(rdb, 248 as libc::c_int as libc::c_uchar) == -(1 as libc::c_int) {
4229 return -(1 as libc::c_int);
4230 }
4231 if rdbSaveLen(rdb, idletime) == -(1 as libc::c_int) {
4232 return -(1 as libc::c_int);
4233 }
4234 }
4235 if savelfu != 0 {
4236 let mut buf: [uint8_t; 1] = [0; 1];
4237 buf[0 as libc::c_int as usize] = LFUDecrAndReturn(val) as uint8_t;
4238 if rdbSaveType(rdb, 249 as libc::c_int as libc::c_uchar) == -(1 as libc::c_int) {
4239 return -(1 as libc::c_int);
4240 }
4241 if rdbWriteRaw(
4242 rdb,
4243 buf.as_mut_ptr() as *mut libc::c_void,
4244 1 as libc::c_int as size_t,
4245 ) == -(1 as libc::c_int) as libc::c_long
4246 {
4247 return -(1 as libc::c_int);
4248 }
4249 }
4250 if rdbSaveObjectType(rdb, val) == -(1 as libc::c_int) {
4251 return -(1 as libc::c_int);
4252 }
4253 if rdbSaveStringObject(rdb, key) == -(1 as libc::c_int) as libc::c_long {
4254 return -(1 as libc::c_int);
4255 }
4256 if rdbSaveObject(rdb, val, key, dbid) == -(1 as libc::c_int) as libc::c_long {
4257 return -(1 as libc::c_int);
4258 }
4259 if server.rdb_key_save_delay != 0 {
4260 debugDelay(server.rdb_key_save_delay);
4261 }
4262 return 1 as libc::c_int;
4263}
4264#[no_mangle]
4265pub unsafe extern "C" fn rdbSaveAuxField(
4266 mut rdb: *mut rio,
4267 mut key: *mut libc::c_void,
4268 mut keylen: size_t,
4269 mut val: *mut libc::c_void,
4270 mut vallen: size_t,
4271) -> ssize_t {
4272 let mut ret: ssize_t = 0;
4273 let mut len: ssize_t = 0 as libc::c_int as ssize_t;
4274 ret = rdbSaveType(rdb, 250 as libc::c_int as libc::c_uchar) as ssize_t;
4275 if ret == -(1 as libc::c_int) as libc::c_long {
4276 return -(1 as libc::c_int) as ssize_t;
4277 }
4278 len += ret;
4279 ret = rdbSaveRawString(rdb, key as *mut libc::c_uchar, keylen);
4280 if ret == -(1 as libc::c_int) as libc::c_long {
4281 return -(1 as libc::c_int) as ssize_t;
4282 }
4283 len += ret;
4284 ret = rdbSaveRawString(rdb, val as *mut libc::c_uchar, vallen);
4285 if ret == -(1 as libc::c_int) as libc::c_long {
4286 return -(1 as libc::c_int) as ssize_t;
4287 }
4288 len += ret;
4289 return len;
4290}
4291#[no_mangle]
4292pub unsafe extern "C" fn rdbSaveAuxFieldStrStr(
4293 mut rdb: *mut rio,
4294 mut key: *mut libc::c_char,
4295 mut val: *mut libc::c_char,
4296) -> ssize_t {
4297 return rdbSaveAuxField(
4298 rdb,
4299 key as *mut libc::c_void,
4300 strlen(key),
4301 val as *mut libc::c_void,
4302 strlen(val),
4303 );
4304}
4305#[no_mangle]
4306pub unsafe extern "C" fn rdbSaveAuxFieldStrInt(
4307 mut rdb: *mut rio,
4308 mut key: *mut libc::c_char,
4309 mut val: libc::c_longlong,
4310) -> ssize_t {
4311 let mut buf: [libc::c_char; 21] = [0; 21];
4312 let mut vlen: libc::c_int = ll2string(
4313 buf.as_mut_ptr(),
4314 core::mem::size_of::<[libc::c_char; 21]>() as libc::c_ulong,
4315 val,
4316 );
4317 return rdbSaveAuxField(
4318 rdb,
4319 key as *mut libc::c_void,
4320 strlen(key),
4321 buf.as_mut_ptr() as *mut libc::c_void,
4322 vlen as size_t,
4323 );
4324}
4325#[no_mangle]
4326pub unsafe extern "C" fn rdbSaveInfoAuxFields(
4327 mut rdb: *mut rio,
4328 mut rdbflags: libc::c_int,
4329 mut rsi: *mut rdbSaveInfo,
4330) -> libc::c_int {
4331 let mut redis_bits: libc::c_int = if core::mem::size_of::<*mut libc::c_void>()
4332 as libc::c_ulong == 8 as libc::c_int as libc::c_ulong
4333 {
4334 64 as libc::c_int
4335 } else {
4336 32 as libc::c_int
4337 };
4338 let mut aof_base: libc::c_int = (rdbflags & (1 as libc::c_int) << 0 as libc::c_int
4339 != 0 as libc::c_int) as libc::c_int;
4340 if rdbSaveAuxFieldStrStr(
4341 rdb,
4342 b"redis-ver\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
4343 b"7.0.8\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
4344 ) == -(1 as libc::c_int) as libc::c_long
4345 {
4346 return -(1 as libc::c_int);
4347 }
4348 if rdbSaveAuxFieldStrInt(
4349 rdb,
4350 b"redis-bits\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
4351 redis_bits as libc::c_longlong,
4352 ) == -(1 as libc::c_int) as libc::c_long
4353 {
4354 return -(1 as libc::c_int);
4355 }
4356 if rdbSaveAuxFieldStrInt(
4357 rdb,
4358 b"ctime\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
4359 time(0 as *mut time_t) as libc::c_longlong,
4360 ) == -(1 as libc::c_int) as libc::c_long
4361 {
4362 return -(1 as libc::c_int);
4363 }
4364 if rdbSaveAuxFieldStrInt(
4365 rdb,
4366 b"used-mem\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
4367 zmalloc_used_memory() as libc::c_longlong,
4368 ) == -(1 as libc::c_int) as libc::c_long
4369 {
4370 return -(1 as libc::c_int);
4371 }
4372 if !rsi.is_null() {
4373 if rdbSaveAuxFieldStrInt(
4374 rdb,
4375 b"repl-stream-db\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
4376 (*rsi).repl_stream_db as libc::c_longlong,
4377 ) == -(1 as libc::c_int) as libc::c_long
4378 {
4379 return -(1 as libc::c_int);
4380 }
4381 if rdbSaveAuxFieldStrStr(
4382 rdb,
4383 b"repl-id\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
4384 (server.replid).as_mut_ptr(),
4385 ) == -(1 as libc::c_int) as libc::c_long
4386 {
4387 return -(1 as libc::c_int);
4388 }
4389 if rdbSaveAuxFieldStrInt(
4390 rdb,
4391 b"repl-offset\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
4392 server.master_repl_offset,
4393 ) == -(1 as libc::c_int) as libc::c_long
4394 {
4395 return -(1 as libc::c_int);
4396 }
4397 }
4398 if rdbSaveAuxFieldStrInt(
4399 rdb,
4400 b"aof-base\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
4401 aof_base as libc::c_longlong,
4402 ) == -(1 as libc::c_int) as libc::c_long
4403 {
4404 return -(1 as libc::c_int);
4405 }
4406 return 1 as libc::c_int;
4407}
4408#[no_mangle]
4409pub unsafe extern "C" fn rdbSaveSingleModuleAux(
4410 mut rdb: *mut rio,
4411 mut when: libc::c_int,
4412 mut mt: *mut moduleType,
4413) -> ssize_t {
4414 let mut io: RedisModuleIO = RedisModuleIO {
4415 bytes: 0,
4416 rio: 0 as *mut rio,
4417 type_0: 0 as *mut moduleType,
4418 error: 0,
4419 ver: 0,
4420 ctx: 0 as *mut RedisModuleCtx,
4421 key: 0 as *mut redisObject,
4422 dbid: 0,
4423 };
4424 let mut retval: libc::c_int = rdbSaveType(rdb, 247 as libc::c_int as libc::c_uchar);
4425 if retval == -(1 as libc::c_int) {
4426 return -(1 as libc::c_int) as ssize_t;
4427 }
4428 io.rio = rdb;
4429 io.type_0 = mt;
4430 io.bytes = 0 as libc::c_int as size_t;
4431 io.error = 0 as libc::c_int;
4432 io.ver = 0 as libc::c_int;
4433 io.key = 0 as *mut redisObject;
4434 io.dbid = -(1 as libc::c_int);
4435 io.ctx = 0 as *mut RedisModuleCtx;
4436 io
4437 .bytes = (io.bytes as libc::c_ulong).wrapping_add(retval as libc::c_ulong)
4438 as size_t as size_t;
4439 retval = rdbSaveLen(rdb, (*mt).id);
4440 if retval == -(1 as libc::c_int) {
4441 return -(1 as libc::c_int) as ssize_t;
4442 }
4443 io
4444 .bytes = (io.bytes as libc::c_ulong).wrapping_add(retval as libc::c_ulong)
4445 as size_t as size_t;
4446 retval = rdbSaveLen(rdb, 2 as libc::c_int as uint64_t);
4447 if retval == -(1 as libc::c_int) {
4448 return -(1 as libc::c_int) as ssize_t;
4449 }
4450 io
4451 .bytes = (io.bytes as libc::c_ulong).wrapping_add(retval as libc::c_ulong)
4452 as size_t as size_t;
4453 retval = rdbSaveLen(rdb, when as uint64_t);
4454 if retval == -(1 as libc::c_int) {
4455 return -(1 as libc::c_int) as ssize_t;
4456 }
4457 io
4458 .bytes = (io.bytes as libc::c_ulong).wrapping_add(retval as libc::c_ulong)
4459 as size_t as size_t;
4460 ((*mt).aux_save).expect("non-null function pointer")(&mut io, when);
4461 retval = rdbSaveLen(rdb, 0 as libc::c_int as uint64_t);
4462 if retval == -(1 as libc::c_int) {
4463 io.error = 1 as libc::c_int;
4464 } else {
4465 io
4466 .bytes = (io.bytes as libc::c_ulong).wrapping_add(retval as libc::c_ulong)
4467 as size_t as size_t;
4468 }
4469 if !(io.ctx).is_null() {
4470 moduleFreeContext(io.ctx);
4471 zfree(io.ctx as *mut libc::c_void);
4472 }
4473 if io.error != 0 {
4474 return -(1 as libc::c_int) as ssize_t;
4475 }
4476 return io.bytes as ssize_t;
4477}
4478#[no_mangle]
4479pub unsafe extern "C" fn rdbSaveFunctions(mut rdb: *mut rio) -> ssize_t {
4480 let mut current_block: u64;
4481 let mut functions: *mut dict = functionsLibGet();
4482 let mut iter: *mut dictIterator = dictGetIterator(functions);
4483 let mut entry: *mut dictEntry = 0 as *mut dictEntry;
4484 let mut written: ssize_t = 0 as libc::c_int as ssize_t;
4485 let mut ret: ssize_t = 0;
4486 loop {
4487 entry = dictNext(iter);
4488 if entry.is_null() {
4489 current_block = 10879442775620481940;
4490 break;
4491 }
4492 ret = rdbSaveType(rdb, 245 as libc::c_int as libc::c_uchar) as ssize_t;
4493 if ret < 0 as libc::c_int as libc::c_long {
4494 current_block = 17565661220666970011;
4495 break;
4496 }
4497 written += ret;
4498 let mut li: *mut functionLibInfo = (*entry).v.val as *mut functionLibInfo;
4499 ret = rdbSaveRawString(
4500 rdb,
4501 (*li).code as *mut libc::c_uchar,
4502 sdslen((*li).code),
4503 );
4504 if ret < 0 as libc::c_int as libc::c_long {
4505 current_block = 17565661220666970011;
4506 break;
4507 }
4508 written += ret;
4509 }
4510 match current_block {
4511 17565661220666970011 => {
4512 dictReleaseIterator(iter);
4513 return -(1 as libc::c_int) as ssize_t;
4514 }
4515 _ => {
4516 dictReleaseIterator(iter);
4517 return written;
4518 }
4519 };
4520}
4521#[no_mangle]
4522pub unsafe extern "C" fn rdbSaveDb(
4523 mut rdb: *mut rio,
4524 mut dbid: libc::c_int,
4525 mut rdbflags: libc::c_int,
4526 mut key_counter: *mut libc::c_long,
4527) -> ssize_t {
4528 let mut db_size: uint64_t = 0;
4529 let mut expires_size: uint64_t = 0;
4530 let mut current_block: u64;
4531 let mut di: *mut dictIterator = 0 as *mut dictIterator;
4532 let mut de: *mut dictEntry = 0 as *mut dictEntry;
4533 let mut written: ssize_t = 0 as libc::c_int as ssize_t;
4534 let mut res: ssize_t = 0;
4535 static mut info_updated_time: libc::c_longlong = 0 as libc::c_int
4536 as libc::c_longlong;
4537 let mut pname: *mut libc::c_char = (if rdbflags
4538 & (1 as libc::c_int) << 0 as libc::c_int != 0
4539 {
4540 b"AOF rewrite\0" as *const u8 as *const libc::c_char
4541 } else {
4542 b"RDB\0" as *const u8 as *const libc::c_char
4543 }) as *mut libc::c_char;
4544 let mut db: *mut redisDb = (server.db).offset(dbid as isize);
4545 let mut d: *mut dict = (*db).dict;
4546 if ((*d).ht_used[0 as libc::c_int as usize])
4547 .wrapping_add((*d).ht_used[1 as libc::c_int as usize])
4548 == 0 as libc::c_int as libc::c_ulong
4549 {
4550 return 0 as libc::c_int as ssize_t;
4551 }
4552 di = dictGetSafeIterator(d);
4553 res = rdbSaveType(rdb, 254 as libc::c_int as libc::c_uchar) as ssize_t;
4554 if !(res < 0 as libc::c_int as libc::c_long) {
4555 written += res;
4556 res = rdbSaveLen(rdb, dbid as uint64_t) as ssize_t;
4557 if !(res < 0 as libc::c_int as libc::c_long) {
4558 written += res;
4559 db_size = 0;
4560 expires_size = 0;
4561 db_size = ((*(*db).dict).ht_used[0 as libc::c_int as usize])
4562 .wrapping_add((*(*db).dict).ht_used[1 as libc::c_int as usize]);
4563 expires_size = ((*(*db).expires).ht_used[0 as libc::c_int as usize])
4564 .wrapping_add((*(*db).expires).ht_used[1 as libc::c_int as usize]);
4565 res = rdbSaveType(rdb, 251 as libc::c_int as libc::c_uchar) as ssize_t;
4566 if !(res < 0 as libc::c_int as libc::c_long) {
4567 written += res;
4568 res = rdbSaveLen(rdb, db_size) as ssize_t;
4569 if !(res < 0 as libc::c_int as libc::c_long) {
4570 written += res;
4571 res = rdbSaveLen(rdb, expires_size) as ssize_t;
4572 if !(res < 0 as libc::c_int as libc::c_long) {
4573 written += res;
4574 loop {
4575 de = dictNext(di);
4576 if de.is_null() {
4577 current_block = 15897653523371991391;
4578 break;
4579 }
4580 let mut keystr: sds = (*de).key as sds;
4581 let mut key: robj = robj {
4582 type_0_encoding_lru: [0; 4],
4583 refcount: 0,
4584 ptr: 0 as *mut libc::c_void,
4585 };
4586 let mut o: *mut robj = (*de).v.val as *mut robj;
4587 let mut expire: libc::c_longlong = 0;
4588 let mut rdb_bytes_before_key: size_t = (*rdb)
4589 .processed_bytes;
4590 key.refcount = 2147483647 as libc::c_int - 1 as libc::c_int;
4591 key.set_type_0(0 as libc::c_int as libc::c_uint);
4592 key.set_encoding(0 as libc::c_int as libc::c_uint);
4593 key.ptr = keystr as *mut libc::c_void;
4594 expire = getExpire(db, &mut key);
4595 res = rdbSaveKeyValuePair(rdb, &mut key, o, expire, dbid)
4596 as ssize_t;
4597 if res < 0 as libc::c_int as libc::c_long {
4598 current_block = 15205125493042018371;
4599 break;
4600 }
4601 written += res;
4602 let mut dump_size: size_t = ((*rdb).processed_bytes)
4603 .wrapping_sub(rdb_bytes_before_key);
4604 if server.in_fork_child != 0 {
4605 dismissObject(o, dump_size);
4606 }
4607 let fresh0 = *key_counter;
4608 *key_counter = *key_counter + 1;
4609 if fresh0 & 1023 as libc::c_int as libc::c_long
4610 == 0 as libc::c_int as libc::c_long
4611 {
4612 let mut now: libc::c_longlong = mstime();
4613 if now - info_updated_time
4614 >= 1000 as libc::c_int as libc::c_longlong
4615 {
4616 sendChildInfo(
4617 CHILD_INFO_TYPE_CURRENT_INFO,
4618 *key_counter as size_t,
4619 pname,
4620 );
4621 info_updated_time = now;
4622 }
4623 }
4624 }
4625 match current_block {
4626 15205125493042018371 => {}
4627 _ => {
4628 dictReleaseIterator(di);
4629 return written;
4630 }
4631 }
4632 }
4633 }
4634 }
4635 }
4636 }
4637 dictReleaseIterator(di);
4638 return -(1 as libc::c_int) as ssize_t;
4639}
4640#[no_mangle]
4641pub unsafe extern "C" fn rdbSaveRio(
4642 mut req: libc::c_int,
4643 mut rdb: *mut rio,
4644 mut error: *mut libc::c_int,
4645 mut rdbflags: libc::c_int,
4646 mut rsi: *mut rdbSaveInfo,
4647) -> libc::c_int {
4648 let mut current_block: u64;
4649 let mut magic: [libc::c_char; 10] = [0; 10];
4650 let mut cksum: uint64_t = 0;
4651 let mut key_counter: libc::c_long = 0 as libc::c_int as libc::c_long;
4652 let mut j: libc::c_int = 0;
4653 if server.rdb_checksum != 0 {
4654 (*rdb)
4655 .update_cksum = Some(
4656 rioGenericUpdateChecksum
4657 as unsafe extern "C" fn(*mut rio, *const libc::c_void, size_t) -> (),
4658 );
4659 }
4660 snprintf(
4661 magic.as_mut_ptr(),
4662 core::mem::size_of::<[libc::c_char; 10]>() as libc::c_ulong,
4663 b"REDIS%04d\0" as *const u8 as *const libc::c_char,
4664 10 as libc::c_int,
4665 );
4666 if !(rdbWriteRaw(
4667 rdb,
4668 magic.as_mut_ptr() as *mut libc::c_void,
4669 9 as libc::c_int as size_t,
4670 ) == -(1 as libc::c_int) as libc::c_long)
4671 {
4672 if !(rdbSaveInfoAuxFields(rdb, rdbflags, rsi) == -(1 as libc::c_int)) {
4673 if !(req & (1 as libc::c_int) << 0 as libc::c_int == 0
4674 && rdbSaveModulesAux(rdb, (1 as libc::c_int) << 0 as libc::c_int)
4675 == -(1 as libc::c_int) as libc::c_long)
4676 {
4677 if !(req & (1 as libc::c_int) << 1 as libc::c_int == 0
4678 && rdbSaveFunctions(rdb) == -(1 as libc::c_int) as libc::c_long)
4679 {
4680 if req & (1 as libc::c_int) << 0 as libc::c_int == 0 {
4681 j = 0 as libc::c_int;
4682 loop {
4683 if !(j < server.dbnum) {
4684 current_block = 1856101646708284338;
4685 break;
4686 }
4687 if rdbSaveDb(rdb, j, rdbflags, &mut key_counter)
4688 == -(1 as libc::c_int) as libc::c_long
4689 {
4690 current_block = 17116435445121809148;
4691 break;
4692 }
4693 j += 1;
4694 }
4695 } else {
4696 current_block = 1856101646708284338;
4697 }
4698 match current_block {
4699 17116435445121809148 => {}
4700 _ => {
4701 if !(req & (1 as libc::c_int) << 0 as libc::c_int == 0
4702 && rdbSaveModulesAux(
4703 rdb,
4704 (1 as libc::c_int) << 1 as libc::c_int,
4705 ) == -(1 as libc::c_int) as libc::c_long)
4706 {
4707 if !(rdbSaveType(rdb, 255 as libc::c_int as libc::c_uchar)
4708 == -(1 as libc::c_int))
4709 {
4710 cksum = (*rdb).cksum;
4711 if !(rioWrite(
4712 rdb,
4713 &mut cksum as *mut uint64_t as *const libc::c_void,
4714 8 as libc::c_int as size_t,
4715 ) == 0 as libc::c_int as libc::c_ulong)
4716 {
4717 return 0 as libc::c_int;
4718 }
4719 }
4720 }
4721 }
4722 }
4723 }
4724 }
4725 }
4726 }
4727 if !error.is_null() {
4728 *error = *__errno_location();
4729 }
4730 return -(1 as libc::c_int);
4731}
4732#[no_mangle]
4733pub unsafe extern "C" fn rdbSaveRioWithEOFMark(
4734 mut req: libc::c_int,
4735 mut rdb: *mut rio,
4736 mut error: *mut libc::c_int,
4737 mut rsi: *mut rdbSaveInfo,
4738) -> libc::c_int {
4739 let mut eofmark: [libc::c_char; 40] = [0; 40];
4740 startSaving((1 as libc::c_int) << 1 as libc::c_int);
4741 getRandomHexChars(eofmark.as_mut_ptr(), 40 as libc::c_int as size_t);
4742 if !error.is_null() {
4743 *error = 0 as libc::c_int;
4744 }
4745 if !(rioWrite(
4746 rdb,
4747 b"$EOF:\0" as *const u8 as *const libc::c_char as *const libc::c_void,
4748 5 as libc::c_int as size_t,
4749 ) == 0 as libc::c_int as libc::c_ulong)
4750 {
4751 if !(rioWrite(
4752 rdb,
4753 eofmark.as_mut_ptr() as *const libc::c_void,
4754 40 as libc::c_int as size_t,
4755 ) == 0 as libc::c_int as libc::c_ulong)
4756 {
4757 if !(rioWrite(
4758 rdb,
4759 b"\r\n\0" as *const u8 as *const libc::c_char as *const libc::c_void,
4760 2 as libc::c_int as size_t,
4761 ) == 0 as libc::c_int as libc::c_ulong)
4762 {
4763 if !(rdbSaveRio(req, rdb, error, 0 as libc::c_int, rsi)
4764 == -(1 as libc::c_int))
4765 {
4766 if !(rioWrite(
4767 rdb,
4768 eofmark.as_mut_ptr() as *const libc::c_void,
4769 40 as libc::c_int as size_t,
4770 ) == 0 as libc::c_int as libc::c_ulong)
4771 {
4772 stopSaving(1 as libc::c_int);
4773 return 0 as libc::c_int;
4774 }
4775 }
4776 }
4777 }
4778 }
4779 if !error.is_null() && *error == 0 as libc::c_int {
4780 *error = *__errno_location();
4781 }
4782 stopSaving(0 as libc::c_int);
4783 return -(1 as libc::c_int);
4784}
4785#[no_mangle]
4786pub unsafe extern "C" fn rdbSave(
4787 mut req: libc::c_int,
4788 mut filename: *mut libc::c_char,
4789 mut rsi: *mut rdbSaveInfo,
4790) -> libc::c_int {
4791 let mut tmpfile: [libc::c_char; 256] = [0; 256];
4792 let mut cwd: [libc::c_char; 4096] = [0; 4096];
4793 let mut fp: *mut FILE = 0 as *mut FILE;
4794 let mut rdb: rio = rio {
4795 read: None,
4796 write: None,
4797 tell: None,
4798 flush: None,
4799 update_cksum: None,
4800 cksum: 0,
4801 flags: 0,
4802 processed_bytes: 0,
4803 max_processing_chunk: 0,
4804 io: C2RustUnnamed {
4805 buffer: C2RustUnnamed_3 {
4806 ptr: 0 as *mut libc::c_char,
4807 pos: 0,
4808 },
4809 },
4810 };
4811 let mut error: libc::c_int = 0 as libc::c_int;
4812 let mut err_op: *mut libc::c_char = 0 as *mut libc::c_char;
4813 snprintf(
4814 tmpfile.as_mut_ptr(),
4815 256 as libc::c_int as libc::c_ulong,
4816 b"temp-%d.rdb\0" as *const u8 as *const libc::c_char,
4817 getpid(),
4818 );
4819 fp = fopen(tmpfile.as_mut_ptr(), b"w\0" as *const u8 as *const libc::c_char);
4820 if fp.is_null() {
4821 let mut str_err: *mut libc::c_char = strerror(*__errno_location());
4822 let mut cwdp: *mut libc::c_char = getcwd(
4823 cwd.as_mut_ptr(),
4824 4096 as libc::c_int as size_t,
4825 );
4826 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
4827 _serverLog(
4828 3 as libc::c_int,
4829 b"Failed opening the temp RDB file %s (in server root dir %s) for saving: %s\0"
4830 as *const u8 as *const libc::c_char,
4831 tmpfile.as_mut_ptr(),
4832 if !cwdp.is_null() {
4833 cwdp as *const libc::c_char
4834 } else {
4835 b"unknown\0" as *const u8 as *const libc::c_char
4836 },
4837 str_err,
4838 );
4839 }
4840 return -(1 as libc::c_int);
4841 }
4842 rioInitWithFile(&mut rdb, fp);
4843 startSaving(0 as libc::c_int);
4844 if server.rdb_save_incremental_fsync != 0 {
4845 rioSetAutoSync(
4846 &mut rdb,
4847 (1024 as libc::c_int * 1024 as libc::c_int * 4 as libc::c_int) as off_t,
4848 );
4849 }
4850 if rdbSaveRio(req, &mut rdb, &mut error, 0 as libc::c_int, rsi)
4851 == -(1 as libc::c_int)
4852 {
4853 *__errno_location() = error;
4854 err_op = b"rdbSaveRio\0" as *const u8 as *const libc::c_char
4855 as *mut libc::c_char;
4856 } else if fflush(fp) != 0 {
4857 err_op = b"fflush\0" as *const u8 as *const libc::c_char as *mut libc::c_char;
4858 } else if fsync(fileno(fp)) != 0 {
4859 err_op = b"fsync\0" as *const u8 as *const libc::c_char as *mut libc::c_char;
4860 } else if fclose(fp) != 0 {
4861 fp = 0 as *mut FILE;
4862 err_op = b"fclose\0" as *const u8 as *const libc::c_char as *mut libc::c_char;
4863 } else {
4864 fp = 0 as *mut FILE;
4865 if rename(tmpfile.as_mut_ptr(), filename) == -(1 as libc::c_int) {
4866 let mut str_err_0: *mut libc::c_char = strerror(*__errno_location());
4867 let mut cwdp_0: *mut libc::c_char = getcwd(
4868 cwd.as_mut_ptr(),
4869 4096 as libc::c_int as size_t,
4870 );
4871 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
4872 _serverLog(
4873 3 as libc::c_int,
4874 b"Error moving temp DB file %s on the final destination %s (in server root dir %s): %s\0"
4875 as *const u8 as *const libc::c_char,
4876 tmpfile.as_mut_ptr(),
4877 filename,
4878 if !cwdp_0.is_null() {
4879 cwdp_0 as *const libc::c_char
4880 } else {
4881 b"unknown\0" as *const u8 as *const libc::c_char
4882 },
4883 str_err_0,
4884 );
4885 }
4886 unlink(tmpfile.as_mut_ptr());
4887 stopSaving(0 as libc::c_int);
4888 return -(1 as libc::c_int);
4889 }
4890 if fsyncFileDir(filename) == -(1 as libc::c_int) {
4891 err_op = b"fsyncFileDir\0" as *const u8 as *const libc::c_char
4892 as *mut libc::c_char;
4893 } else {
4894 if !((2 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
4895 _serverLog(
4896 2 as libc::c_int,
4897 b"DB saved on disk\0" as *const u8 as *const libc::c_char,
4898 );
4899 }
4900 server.dirty = 0 as libc::c_int as libc::c_longlong;
4901 server.lastsave = time(0 as *mut time_t);
4902 server.lastbgsave_status = 0 as libc::c_int;
4903 stopSaving(1 as libc::c_int);
4904 return 0 as libc::c_int;
4905 }
4906 }
4907 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
4908 _serverLog(
4909 3 as libc::c_int,
4910 b"Write error saving DB on disk(%s): %s\0" as *const u8
4911 as *const libc::c_char,
4912 err_op,
4913 strerror(*__errno_location()),
4914 );
4915 }
4916 if !fp.is_null() {
4917 fclose(fp);
4918 }
4919 unlink(tmpfile.as_mut_ptr());
4920 stopSaving(0 as libc::c_int);
4921 return -(1 as libc::c_int);
4922}
4923#[no_mangle]
4924pub unsafe extern "C" fn rdbSaveBackground(
4925 mut req: libc::c_int,
4926 mut filename: *mut libc::c_char,
4927 mut rsi: *mut rdbSaveInfo,
4928) -> libc::c_int {
4929 let mut childpid: pid_t = 0;
4930 if hasActiveChildProcess() != 0 {
4931 return -(1 as libc::c_int);
4932 }
4933 server.stat_rdb_saves += 1;
4934 server.dirty_before_bgsave = server.dirty;
4935 server.lastbgsave_try = time(0 as *mut time_t);
4936 childpid = redisFork(1 as libc::c_int);
4937 if childpid == 0 as libc::c_int {
4938 let mut retval: libc::c_int = 0;
4939 redisSetProcTitle(
4940 b"redis-rdb-bgsave\0" as *const u8 as *const libc::c_char
4941 as *mut libc::c_char,
4942 );
4943 redisSetCpuAffinity(server.bgsave_cpulist);
4944 retval = rdbSave(req, filename, rsi);
4945 if retval == 0 as libc::c_int {
4946 sendChildCowInfo(
4947 CHILD_INFO_TYPE_RDB_COW_SIZE,
4948 b"RDB\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
4949 );
4950 }
4951 exitFromChild(
4952 if retval == 0 as libc::c_int { 0 as libc::c_int } else { 1 as libc::c_int },
4953 );
4954 } else {
4955 if childpid == -(1 as libc::c_int) {
4956 server.lastbgsave_status = -(1 as libc::c_int);
4957 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
4958 _serverLog(
4959 3 as libc::c_int,
4960 b"Can't save in background: fork: %s\0" as *const u8
4961 as *const libc::c_char,
4962 strerror(*__errno_location()),
4963 );
4964 }
4965 return -(1 as libc::c_int);
4966 }
4967 if !((2 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
4968 _serverLog(
4969 2 as libc::c_int,
4970 b"Background saving started by pid %ld\0" as *const u8
4971 as *const libc::c_char,
4972 childpid as libc::c_long,
4973 );
4974 }
4975 server.rdb_save_time_start = time(0 as *mut time_t);
4976 server.rdb_child_type = 1 as libc::c_int;
4977 return 0 as libc::c_int;
4978 }
4979 return 0 as libc::c_int;
4980}
4981#[no_mangle]
4982pub unsafe extern "C" fn rdbRemoveTempFile(
4983 mut childpid: pid_t,
4984 mut from_signal: libc::c_int,
4985) {
4986 let mut tmpfile: [libc::c_char; 256] = [0; 256];
4987 let mut pid: [libc::c_char; 32] = [0; 32];
4988 let mut pid_len: libc::c_int = ll2string(
4989 pid.as_mut_ptr(),
4990 core::mem::size_of::<[libc::c_char; 32]>() as libc::c_ulong,
4991 childpid as libc::c_longlong,
4992 );
4993 strcpy(tmpfile.as_mut_ptr(), b"temp-\0" as *const u8 as *const libc::c_char);
4994 strncpy(
4995 tmpfile.as_mut_ptr().offset(5 as libc::c_int as isize),
4996 pid.as_mut_ptr(),
4997 pid_len as libc::c_ulong,
4998 );
4999 strcpy(
5000 tmpfile.as_mut_ptr().offset(5 as libc::c_int as isize).offset(pid_len as isize),
5001 b".rdb\0" as *const u8 as *const libc::c_char,
5002 );
5003 if from_signal != 0 {
5004 let mut fd: libc::c_int = open(
5005 tmpfile.as_mut_ptr(),
5006 0 as libc::c_int | 0o4000 as libc::c_int,
5007 );
5008 unlink(tmpfile.as_mut_ptr());
5009 } else {
5010 bg_unlink(tmpfile.as_mut_ptr());
5011 };
5012}
5013#[no_mangle]
5014pub unsafe extern "C" fn rdbLoadCheckModuleValue(
5015 mut rdb: *mut rio,
5016 mut modulename: *mut libc::c_char,
5017) -> *mut robj {
5018 let mut opcode: uint64_t = 0;
5019 loop {
5020 opcode = rdbLoadLen(rdb, 0 as *mut libc::c_int);
5021 if !(opcode != 0 as libc::c_int as libc::c_ulong) {
5022 break;
5023 }
5024 if opcode == 1 as libc::c_int as libc::c_ulong
5025 || opcode == 2 as libc::c_int as libc::c_ulong
5026 {
5027 let mut len: uint64_t = 0;
5028 if rdbLoadLenByRef(rdb, 0 as *mut libc::c_int, &mut len)
5029 == -(1 as libc::c_int)
5030 {
5031 rdbReportError(
5032 1 as libc::c_int,
5033 1540 as libc::c_int,
5034 b"Error reading integer from module %s value\0" as *const u8
5035 as *const libc::c_char as *mut libc::c_char,
5036 modulename,
5037 );
5038 }
5039 } else if opcode == 5 as libc::c_int as libc::c_ulong {
5040 let mut o: *mut robj = rdbGenericLoadStringObject(
5041 rdb,
5042 0 as libc::c_int,
5043 0 as *mut size_t,
5044 ) as *mut robj;
5045 if o.is_null() {
5046 rdbReportError(
5047 1 as libc::c_int,
5048 1546 as libc::c_int,
5049 b"Error reading string from module %s value\0" as *const u8
5050 as *const libc::c_char as *mut libc::c_char,
5051 modulename,
5052 );
5053 }
5054 decrRefCount(o);
5055 } else if opcode == 3 as libc::c_int as libc::c_ulong {
5056 let mut val: libc::c_float = 0.;
5057 if rdbLoadBinaryFloatValue(rdb, &mut val) == -(1 as libc::c_int) {
5058 rdbReportError(
5059 1 as libc::c_int,
5060 1553 as libc::c_int,
5061 b"Error reading float from module %s value\0" as *const u8
5062 as *const libc::c_char as *mut libc::c_char,
5063 modulename,
5064 );
5065 }
5066 } else if opcode == 4 as libc::c_int as libc::c_ulong {
5067 let mut val_0: libc::c_double = 0.;
5068 if rdbLoadBinaryDoubleValue(rdb, &mut val_0) == -(1 as libc::c_int) {
5069 rdbReportError(
5070 1 as libc::c_int,
5071 1559 as libc::c_int,
5072 b"Error reading double from module %s value\0" as *const u8
5073 as *const libc::c_char as *mut libc::c_char,
5074 modulename,
5075 );
5076 }
5077 }
5078 }
5079 return createStringObject(
5080 b"module-dummy-value\0" as *const u8 as *const libc::c_char,
5081 18 as libc::c_int as size_t,
5082 );
5083}
5084unsafe extern "C" fn _ziplistPairsEntryConvertAndValidate(
5085 mut p: *mut libc::c_uchar,
5086 mut head_count: libc::c_uint,
5087 mut userdata: *mut libc::c_void,
5088) -> libc::c_int {
5089 let mut str: *mut libc::c_uchar = 0 as *mut libc::c_uchar;
5090 let mut slen: libc::c_uint = 0;
5091 let mut vll: libc::c_longlong = 0;
5092 let mut data: *mut C2RustUnnamed_16 = userdata as *mut C2RustUnnamed_16;
5093 if ((*data).fields).is_null() {
5094 (*data).fields = dictCreate(&mut hashDictType);
5095 dictExpand(
5096 (*data).fields,
5097 head_count.wrapping_div(2 as libc::c_int as libc::c_uint) as libc::c_ulong,
5098 );
5099 }
5100 if ziplistGet(p, &mut str, &mut slen, &mut vll) == 0 {
5101 return 0 as libc::c_int;
5102 }
5103 if (*data).count & 1 as libc::c_int as libc::c_long
5104 == 0 as libc::c_int as libc::c_long
5105 {
5106 let mut field: sds = if !str.is_null() {
5107 sdsnewlen(str as *const libc::c_void, slen as size_t)
5108 } else {
5109 sdsfromlonglong(vll)
5110 };
5111 if dictAdd((*data).fields, field as *mut libc::c_void, 0 as *mut libc::c_void)
5112 != 0 as libc::c_int
5113 {
5114 sdsfree(field);
5115 return 0 as libc::c_int;
5116 }
5117 }
5118 if !str.is_null() {
5119 *(*data).lp = lpAppend(*(*data).lp, str, slen);
5120 } else {
5121 *(*data).lp = lpAppendInteger(*(*data).lp, vll);
5122 }
5123 (*data).count += 1;
5124 return 1 as libc::c_int;
5125}
5126#[no_mangle]
5127pub unsafe extern "C" fn ziplistPairsConvertAndValidateIntegrity(
5128 mut zl: *mut libc::c_uchar,
5129 mut size: size_t,
5130 mut lp: *mut *mut libc::c_uchar,
5131) -> libc::c_int {
5132 let mut data: C2RustUnnamed_15 = {
5133 let mut init = C2RustUnnamed_15 {
5134 count: 0 as libc::c_int as libc::c_long,
5135 fields: 0 as *mut dict,
5136 lp: lp,
5137 };
5138 init
5139 };
5140 let mut ret: libc::c_int = ziplistValidateIntegrity(
5141 zl,
5142 size,
5143 1 as libc::c_int,
5144 Some(
5145 _ziplistPairsEntryConvertAndValidate
5146 as unsafe extern "C" fn(
5147 *mut libc::c_uchar,
5148 libc::c_uint,
5149 *mut libc::c_void,
5150 ) -> libc::c_int,
5151 ),
5152 &mut data as *mut C2RustUnnamed_15 as *mut libc::c_void,
5153 );
5154 if data.count & 1 as libc::c_int as libc::c_long != 0 {
5155 ret = 0 as libc::c_int;
5156 }
5157 if !(data.fields).is_null() {
5158 dictRelease(data.fields);
5159 }
5160 return ret;
5161}
5162unsafe extern "C" fn _ziplistEntryConvertAndValidate(
5163 mut p: *mut libc::c_uchar,
5164 mut head_count: libc::c_uint,
5165 mut userdata: *mut libc::c_void,
5166) -> libc::c_int {
5167 let mut str: *mut libc::c_uchar = 0 as *mut libc::c_uchar;
5168 let mut slen: libc::c_uint = 0;
5169 let mut vll: libc::c_longlong = 0;
5170 let mut lp: *mut *mut libc::c_uchar = userdata as *mut *mut libc::c_uchar;
5171 if ziplistGet(p, &mut str, &mut slen, &mut vll) == 0 {
5172 return 0 as libc::c_int;
5173 }
5174 if !str.is_null() {
5175 *lp = lpAppend(*lp, str, slen);
5176 } else {
5177 *lp = lpAppendInteger(*lp, vll);
5178 }
5179 return 1 as libc::c_int;
5180}
5181unsafe extern "C" fn _listZiplistEntryConvertAndValidate(
5182 mut p: *mut libc::c_uchar,
5183 mut head_count: libc::c_uint,
5184 mut userdata: *mut libc::c_void,
5185) -> libc::c_int {
5186 let mut str: *mut libc::c_uchar = 0 as *mut libc::c_uchar;
5187 let mut slen: libc::c_uint = 0;
5188 let mut vll: libc::c_longlong = 0;
5189 let mut longstr: [libc::c_char; 32] = [
5190 0 as libc::c_int as libc::c_char,
5191 0,
5192 0,
5193 0,
5194 0,
5195 0,
5196 0,
5197 0,
5198 0,
5199 0,
5200 0,
5201 0,
5202 0,
5203 0,
5204 0,
5205 0,
5206 0,
5207 0,
5208 0,
5209 0,
5210 0,
5211 0,
5212 0,
5213 0,
5214 0,
5215 0,
5216 0,
5217 0,
5218 0,
5219 0,
5220 0,
5221 0,
5222 ];
5223 let mut ql: *mut quicklist = userdata as *mut quicklist;
5224 if ziplistGet(p, &mut str, &mut slen, &mut vll) == 0 {
5225 return 0 as libc::c_int;
5226 }
5227 if str.is_null() {
5228 slen = ll2string(
5229 longstr.as_mut_ptr(),
5230 core::mem::size_of::<[libc::c_char; 32]>() as libc::c_ulong,
5231 vll,
5232 ) as libc::c_uint;
5233 str = longstr.as_mut_ptr() as *mut libc::c_uchar;
5234 }
5235 quicklistPushTail(ql, str as *mut libc::c_void, slen as size_t);
5236 return 1 as libc::c_int;
5237}
5238unsafe extern "C" fn _lpPairsEntryValidation(
5239 mut p: *mut libc::c_uchar,
5240 mut head_count: libc::c_uint,
5241 mut userdata: *mut libc::c_void,
5242) -> libc::c_int {
5243 let mut data: *mut C2RustUnnamed_14 = userdata as *mut C2RustUnnamed_14;
5244 if ((*data).fields).is_null() {
5245 (*data).fields = dictCreate(&mut hashDictType);
5246 dictExpand(
5247 (*data).fields,
5248 head_count.wrapping_div(2 as libc::c_int as libc::c_uint) as libc::c_ulong,
5249 );
5250 }
5251 if (*data).count & 1 as libc::c_int as libc::c_long
5252 == 0 as libc::c_int as libc::c_long
5253 {
5254 let mut str: *mut libc::c_uchar = 0 as *mut libc::c_uchar;
5255 let mut slen: int64_t = 0;
5256 let mut buf: [libc::c_uchar; 21] = [0; 21];
5257 str = lpGet(p, &mut slen, buf.as_mut_ptr());
5258 let mut field: sds = sdsnewlen(str as *const libc::c_void, slen as size_t);
5259 if dictAdd((*data).fields, field as *mut libc::c_void, 0 as *mut libc::c_void)
5260 != 0 as libc::c_int
5261 {
5262 sdsfree(field);
5263 return 0 as libc::c_int;
5264 }
5265 }
5266 (*data).count += 1;
5267 return 1 as libc::c_int;
5268}
5269#[no_mangle]
5270pub unsafe extern "C" fn lpPairsValidateIntegrityAndDups(
5271 mut lp: *mut libc::c_uchar,
5272 mut size: size_t,
5273 mut deep: libc::c_int,
5274) -> libc::c_int {
5275 if deep == 0 {
5276 return lpValidateIntegrity(
5277 lp,
5278 size,
5279 0 as libc::c_int,
5280 None,
5281 0 as *mut libc::c_void,
5282 );
5283 }
5284 let mut data: C2RustUnnamed_13 = {
5285 let mut init = C2RustUnnamed_13 {
5286 count: 0 as libc::c_int as libc::c_long,
5287 fields: 0 as *mut dict,
5288 };
5289 init
5290 };
5291 let mut ret: libc::c_int = lpValidateIntegrity(
5292 lp,
5293 size,
5294 1 as libc::c_int,
5295 Some(
5296 _lpPairsEntryValidation
5297 as unsafe extern "C" fn(
5298 *mut libc::c_uchar,
5299 libc::c_uint,
5300 *mut libc::c_void,
5301 ) -> libc::c_int,
5302 ),
5303 &mut data as *mut C2RustUnnamed_13 as *mut libc::c_void,
5304 );
5305 if data.count & 1 as libc::c_int as libc::c_long != 0 {
5306 ret = 0 as libc::c_int;
5307 }
5308 if !(data.fields).is_null() {
5309 dictRelease(data.fields);
5310 }
5311 return ret;
5312}
5313#[no_mangle]
5314pub unsafe extern "C" fn rdbLoadObject(
5315 mut rdbtype: libc::c_int,
5316 mut rdb: *mut rio,
5317 mut key: sds,
5318 mut dbid: libc::c_int,
5319 mut error: *mut libc::c_int,
5320) -> *mut robj {
5321 let mut current_block: u64;
5322 let mut o: *mut robj = 0 as *mut robj;
5323 let mut ele: *mut robj = 0 as *mut robj;
5324 let mut dec: *mut robj = 0 as *mut robj;
5325 let mut len: uint64_t = 0;
5326 let mut i: libc::c_uint = 0;
5327 if !error.is_null() {
5328 *error = 2 as libc::c_int;
5329 }
5330 let mut deep_integrity_validation: libc::c_int = (server.sanitize_dump_payload
5331 == 1 as libc::c_int) as libc::c_int;
5332 if server.sanitize_dump_payload == 2 as libc::c_int {
5333 let mut skip: libc::c_int = (server.loading != 0
5334 || !(server.current_client).is_null()
5335 && (*server.current_client).flags
5336 & ((1 as libc::c_int) << 1 as libc::c_int) as libc::c_ulong != 0)
5337 as libc::c_int;
5338 if skip == 0 && !(server.current_client).is_null()
5339 && !((*server.current_client).user).is_null()
5340 {
5341 skip = ((*(*server.current_client).user).flags
5342 & ((1 as libc::c_int) << 4 as libc::c_int) as libc::c_uint != 0)
5343 as libc::c_int;
5344 }
5345 deep_integrity_validation = (skip == 0) as libc::c_int;
5346 }
5347 if rdbtype == 0 as libc::c_int {
5348 o = rdbLoadEncodedStringObject(rdb);
5349 if o.is_null() {
5350 return 0 as *mut robj;
5351 }
5352 o = tryObjectEncoding(o);
5353 } else {
5354 if rdbtype == 1 as libc::c_int {
5355 len = rdbLoadLen(rdb, 0 as *mut libc::c_int);
5356 if len == 18446744073709551615 as libc::c_ulong {
5357 return 0 as *mut robj;
5358 }
5359 if len == 0 as libc::c_int as libc::c_ulong {
5360 current_block = 11297075595689639996;
5361 } else {
5362 o = createQuicklistObject();
5363 quicklistSetOptions(
5364 (*o).ptr as *mut quicklist,
5365 server.list_max_listpack_size,
5366 server.list_compress_depth,
5367 );
5368 loop {
5369 let fresh1 = len;
5370 len = len.wrapping_sub(1);
5371 if !(fresh1 != 0) {
5372 break;
5373 }
5374 ele = rdbLoadEncodedStringObject(rdb);
5375 if ele.is_null() {
5376 decrRefCount(o);
5377 return 0 as *mut robj;
5378 }
5379 dec = getDecodedObject(ele);
5380 let mut len_0: size_t = sdslen((*dec).ptr as sds);
5381 quicklistPushTail((*o).ptr as *mut quicklist, (*dec).ptr, len_0);
5382 decrRefCount(dec);
5383 decrRefCount(ele);
5384 }
5385 current_block = 10856689599696957676;
5386 }
5387 } else if rdbtype == 2 as libc::c_int {
5388 len = rdbLoadLen(rdb, 0 as *mut libc::c_int);
5389 if len == 18446744073709551615 as libc::c_ulong {
5390 return 0 as *mut robj;
5391 }
5392 if len == 0 as libc::c_int as libc::c_ulong {
5393 current_block = 11297075595689639996;
5394 } else {
5395 let mut max_entries: size_t = server.set_max_intset_entries;
5396 if max_entries
5397 >= ((1 as libc::c_int) << 30 as libc::c_int) as libc::c_ulong
5398 {
5399 max_entries = ((1 as libc::c_int) << 30 as libc::c_int) as size_t;
5400 }
5401 if len > max_entries {
5402 o = createSetObject();
5403 if len > ((1 as libc::c_int) << 2 as libc::c_int) as libc::c_ulong
5404 && dictTryExpand((*o).ptr as *mut dict, len) != 0 as libc::c_int
5405 {
5406 rdbReportError(
5407 1 as libc::c_int,
5408 1784 as libc::c_int,
5409 b"OOM in dictTryExpand %llu\0" as *const u8
5410 as *const libc::c_char as *mut libc::c_char,
5411 len as libc::c_ulonglong,
5412 );
5413 decrRefCount(o);
5414 return 0 as *mut robj;
5415 }
5416 } else {
5417 o = createIntsetObject();
5418 }
5419 i = 0 as libc::c_int as libc::c_uint;
5420 while (i as libc::c_ulong) < len {
5421 let mut llval: libc::c_longlong = 0;
5422 let mut sdsele: sds = 0 as *mut libc::c_char;
5423 sdsele = rdbGenericLoadStringObject(
5424 rdb,
5425 (1 as libc::c_int) << 2 as libc::c_int,
5426 0 as *mut size_t,
5427 ) as sds;
5428 if sdsele.is_null() {
5429 decrRefCount(o);
5430 return 0 as *mut robj;
5431 }
5432 if (*o).encoding() as libc::c_int == 6 as libc::c_int {
5433 if isSdsRepresentableAsLongLong(sdsele, &mut llval)
5434 == 0 as libc::c_int
5435 {
5436 let mut success: uint8_t = 0;
5437 (*o)
5438 .ptr = intsetAdd(
5439 (*o).ptr as *mut intset,
5440 llval as int64_t,
5441 &mut success,
5442 ) as *mut libc::c_void;
5443 if success == 0 {
5444 rdbReportError(
5445 1 as libc::c_int,
5446 1808 as libc::c_int,
5447 b"Duplicate set members detected\0" as *const u8
5448 as *const libc::c_char as *mut libc::c_char,
5449 );
5450 decrRefCount(o);
5451 sdsfree(sdsele);
5452 return 0 as *mut robj;
5453 }
5454 } else {
5455 setTypeConvert(o, 2 as libc::c_int);
5456 if dictTryExpand((*o).ptr as *mut dict, len)
5457 != 0 as libc::c_int
5458 {
5459 rdbReportError(
5460 1 as libc::c_int,
5461 1816 as libc::c_int,
5462 b"OOM in dictTryExpand %llu\0" as *const u8
5463 as *const libc::c_char as *mut libc::c_char,
5464 len as libc::c_ulonglong,
5465 );
5466 sdsfree(sdsele);
5467 decrRefCount(o);
5468 return 0 as *mut robj;
5469 }
5470 }
5471 }
5472 if (*o).encoding() as libc::c_int == 2 as libc::c_int {
5473 if dictAdd(
5474 (*o).ptr as *mut dict,
5475 sdsele as *mut libc::c_void,
5476 0 as *mut libc::c_void,
5477 ) != 0 as libc::c_int
5478 {
5479 rdbReportError(
5480 1 as libc::c_int,
5481 1828 as libc::c_int,
5482 b"Duplicate set members detected\0" as *const u8
5483 as *const libc::c_char as *mut libc::c_char,
5484 );
5485 decrRefCount(o);
5486 sdsfree(sdsele);
5487 return 0 as *mut robj;
5488 }
5489 } else {
5490 sdsfree(sdsele);
5491 }
5492 i = i.wrapping_add(1);
5493 }
5494 current_block = 10856689599696957676;
5495 }
5496 } else if rdbtype == 5 as libc::c_int || rdbtype == 3 as libc::c_int {
5497 let mut zsetlen: uint64_t = 0;
5498 let mut maxelelen: size_t = 0 as libc::c_int as size_t;
5499 let mut totelelen: size_t = 0 as libc::c_int as size_t;
5500 let mut zs: *mut zset = 0 as *mut zset;
5501 zsetlen = rdbLoadLen(rdb, 0 as *mut libc::c_int);
5502 if zsetlen == 18446744073709551615 as libc::c_ulong {
5503 return 0 as *mut robj;
5504 }
5505 if zsetlen == 0 as libc::c_int as libc::c_ulong {
5506 current_block = 11297075595689639996;
5507 } else {
5508 o = createZsetObject();
5509 zs = (*o).ptr as *mut zset;
5510 if zsetlen > ((1 as libc::c_int) << 2 as libc::c_int) as libc::c_ulong
5511 && dictTryExpand((*zs).dict, zsetlen) != 0 as libc::c_int
5512 {
5513 rdbReportError(
5514 1 as libc::c_int,
5515 1850 as libc::c_int,
5516 b"OOM in dictTryExpand %llu\0" as *const u8
5517 as *const libc::c_char as *mut libc::c_char,
5518 zsetlen as libc::c_ulonglong,
5519 );
5520 decrRefCount(o);
5521 return 0 as *mut robj;
5522 }
5523 loop {
5524 let fresh2 = zsetlen;
5525 zsetlen = zsetlen.wrapping_sub(1);
5526 if !(fresh2 != 0) {
5527 break;
5528 }
5529 let mut sdsele_0: sds = 0 as *mut libc::c_char;
5530 let mut score: libc::c_double = 0.;
5531 let mut znode: *mut zskiplistNode = 0 as *mut zskiplistNode;
5532 sdsele_0 = rdbGenericLoadStringObject(
5533 rdb,
5534 (1 as libc::c_int) << 2 as libc::c_int,
5535 0 as *mut size_t,
5536 ) as sds;
5537 if sdsele_0.is_null() {
5538 decrRefCount(o);
5539 return 0 as *mut robj;
5540 }
5541 if rdbtype == 5 as libc::c_int {
5542 if rdbLoadBinaryDoubleValue(rdb, &mut score)
5543 == -(1 as libc::c_int)
5544 {
5545 decrRefCount(o);
5546 sdsfree(sdsele_0);
5547 return 0 as *mut robj;
5548 }
5549 } else if rdbLoadDoubleValue(rdb, &mut score) == -(1 as libc::c_int)
5550 {
5551 decrRefCount(o);
5552 sdsfree(sdsele_0);
5553 return 0 as *mut robj;
5554 }
5555 if score.is_nan() as i32 != 0 {
5556 rdbReportError(
5557 1 as libc::c_int,
5558 1881 as libc::c_int,
5559 b"Zset with NAN score detected\0" as *const u8
5560 as *const libc::c_char as *mut libc::c_char,
5561 );
5562 decrRefCount(o);
5563 sdsfree(sdsele_0);
5564 return 0 as *mut robj;
5565 }
5566 if sdslen(sdsele_0) > maxelelen {
5567 maxelelen = sdslen(sdsele_0);
5568 }
5569 totelelen = (totelelen as libc::c_ulong)
5570 .wrapping_add(sdslen(sdsele_0)) as size_t as size_t;
5571 znode = zslInsert((*zs).zsl, score, sdsele_0);
5572 if dictAdd(
5573 (*zs).dict,
5574 sdsele_0 as *mut libc::c_void,
5575 &mut (*znode).score as *mut libc::c_double as *mut libc::c_void,
5576 ) != 0 as libc::c_int
5577 {
5578 rdbReportError(
5579 1 as libc::c_int,
5580 1893 as libc::c_int,
5581 b"Duplicate zset fields detected\0" as *const u8
5582 as *const libc::c_char as *mut libc::c_char,
5583 );
5584 decrRefCount(o);
5585 return 0 as *mut robj;
5586 }
5587 }
5588 if zsetLength(o) <= server.zset_max_listpack_entries
5589 && maxelelen <= server.zset_max_listpack_value
5590 && lpSafeToAdd(0 as *mut libc::c_uchar, totelelen) != 0
5591 {
5592 zsetConvert(o, 11 as libc::c_int);
5593 }
5594 current_block = 10856689599696957676;
5595 }
5596 } else if rdbtype == 4 as libc::c_int {
5597 let mut len_1: uint64_t = 0;
5598 let mut ret: libc::c_int = 0;
5599 let mut field: sds = 0 as *mut libc::c_char;
5600 let mut value: sds = 0 as *mut libc::c_char;
5601 let mut dupSearchDict: *mut dict = 0 as *mut dict;
5602 len_1 = rdbLoadLen(rdb, 0 as *mut libc::c_int);
5603 if len_1 == 18446744073709551615 as libc::c_ulong {
5604 return 0 as *mut robj;
5605 }
5606 if len_1 == 0 as libc::c_int as libc::c_ulong {
5607 current_block = 11297075595689639996;
5608 } else {
5609 o = createHashObject();
5610 if len_1 > server.hash_max_listpack_entries {
5611 hashTypeConvert(o, 2 as libc::c_int);
5612 } else if deep_integrity_validation != 0 {
5613 dupSearchDict = dictCreate(&mut hashDictType);
5614 }
5615 while (*o).encoding() as libc::c_int == 11 as libc::c_int
5616 && len_1 > 0 as libc::c_int as libc::c_ulong
5617 {
5618 len_1 = len_1.wrapping_sub(1);
5619 field = rdbGenericLoadStringObject(
5620 rdb,
5621 (1 as libc::c_int) << 2 as libc::c_int,
5622 0 as *mut size_t,
5623 ) as sds;
5624 if field.is_null() {
5625 decrRefCount(o);
5626 if !dupSearchDict.is_null() {
5627 dictRelease(dupSearchDict);
5628 }
5629 return 0 as *mut robj;
5630 }
5631 value = rdbGenericLoadStringObject(
5632 rdb,
5633 (1 as libc::c_int) << 2 as libc::c_int,
5634 0 as *mut size_t,
5635 ) as sds;
5636 if value.is_null() {
5637 sdsfree(field);
5638 decrRefCount(o);
5639 if !dupSearchDict.is_null() {
5640 dictRelease(dupSearchDict);
5641 }
5642 return 0 as *mut robj;
5643 }
5644 if !dupSearchDict.is_null() {
5645 let mut field_dup: sds = sdsdup(field);
5646 if dictAdd(
5647 dupSearchDict,
5648 field_dup as *mut libc::c_void,
5649 0 as *mut libc::c_void,
5650 ) != 0 as libc::c_int
5651 {
5652 rdbReportError(
5653 1 as libc::c_int,
5654 1950 as libc::c_int,
5655 b"Hash with dup elements\0" as *const u8
5656 as *const libc::c_char as *mut libc::c_char,
5657 );
5658 dictRelease(dupSearchDict);
5659 decrRefCount(o);
5660 sdsfree(field_dup);
5661 sdsfree(field);
5662 sdsfree(value);
5663 return 0 as *mut robj;
5664 }
5665 }
5666 if sdslen(field) > server.hash_max_listpack_value
5667 || sdslen(value) > server.hash_max_listpack_value
5668 || lpSafeToAdd(
5669 (*o).ptr as *mut libc::c_uchar,
5670 (sdslen(field)).wrapping_add(sdslen(value)),
5671 ) == 0
5672 {
5673 hashTypeConvert(o, 2 as libc::c_int);
5674 ret = dictAdd(
5675 (*o).ptr as *mut dict,
5676 field as *mut libc::c_void,
5677 value as *mut libc::c_void,
5678 );
5679 if ret == 1 as libc::c_int {
5680 rdbReportError(
5681 1 as libc::c_int,
5682 1968 as libc::c_int,
5683 b"Duplicate hash fields detected\0" as *const u8
5684 as *const libc::c_char as *mut libc::c_char,
5685 );
5686 if !dupSearchDict.is_null() {
5687 dictRelease(dupSearchDict);
5688 }
5689 sdsfree(value);
5690 sdsfree(field);
5691 decrRefCount(o);
5692 return 0 as *mut robj;
5693 }
5694 break;
5695 } else {
5696 (*o)
5697 .ptr = lpAppend(
5698 (*o).ptr as *mut libc::c_uchar,
5699 field as *mut libc::c_uchar,
5700 sdslen(field) as uint32_t,
5701 ) as *mut libc::c_void;
5702 (*o)
5703 .ptr = lpAppend(
5704 (*o).ptr as *mut libc::c_uchar,
5705 value as *mut libc::c_uchar,
5706 sdslen(value) as uint32_t,
5707 ) as *mut libc::c_void;
5708 sdsfree(field);
5709 sdsfree(value);
5710 }
5711 }
5712 if !dupSearchDict.is_null() {
5713 dictRelease(dupSearchDict);
5714 dupSearchDict = 0 as *mut dict;
5715 }
5716 if (*o).encoding() as libc::c_int == 2 as libc::c_int
5717 && len_1 > ((1 as libc::c_int) << 2 as libc::c_int) as libc::c_ulong
5718 {
5719 if dictTryExpand((*o).ptr as *mut dict, len_1) != 0 as libc::c_int {
5720 rdbReportError(
5721 1 as libc::c_int,
5722 1995 as libc::c_int,
5723 b"OOM in dictTryExpand %llu\0" as *const u8
5724 as *const libc::c_char as *mut libc::c_char,
5725 len_1 as libc::c_ulonglong,
5726 );
5727 decrRefCount(o);
5728 return 0 as *mut robj;
5729 }
5730 }
5731 while (*o).encoding() as libc::c_int == 2 as libc::c_int
5732 && len_1 > 0 as libc::c_int as libc::c_ulong
5733 {
5734 len_1 = len_1.wrapping_sub(1);
5735 field = rdbGenericLoadStringObject(
5736 rdb,
5737 (1 as libc::c_int) << 2 as libc::c_int,
5738 0 as *mut size_t,
5739 ) as sds;
5740 if field.is_null() {
5741 decrRefCount(o);
5742 return 0 as *mut robj;
5743 }
5744 value = rdbGenericLoadStringObject(
5745 rdb,
5746 (1 as libc::c_int) << 2 as libc::c_int,
5747 0 as *mut size_t,
5748 ) as sds;
5749 if value.is_null() {
5750 sdsfree(field);
5751 decrRefCount(o);
5752 return 0 as *mut robj;
5753 }
5754 ret = dictAdd(
5755 (*o).ptr as *mut dict,
5756 field as *mut libc::c_void,
5757 value as *mut libc::c_void,
5758 );
5759 if ret == 1 as libc::c_int {
5760 rdbReportError(
5761 1 as libc::c_int,
5762 2018 as libc::c_int,
5763 b"Duplicate hash fields detected\0" as *const u8
5764 as *const libc::c_char as *mut libc::c_char,
5765 );
5766 sdsfree(value);
5767 sdsfree(field);
5768 decrRefCount(o);
5769 return 0 as *mut robj;
5770 }
5771 }
5772 if len_1 == 0 as libc::c_int as libc::c_ulong {} else {
5773 _serverAssert(
5774 b"len == 0\0" as *const u8 as *const libc::c_char,
5775 b"rdb.c\0" as *const u8 as *const libc::c_char,
5776 2027 as libc::c_int,
5777 );
5778 unreachable!();
5779 };
5780 current_block = 10856689599696957676;
5781 }
5782 } else if rdbtype == 14 as libc::c_int || rdbtype == 18 as libc::c_int {
5783 len = rdbLoadLen(rdb, 0 as *mut libc::c_int);
5784 if len == 18446744073709551615 as libc::c_ulong {
5785 return 0 as *mut robj;
5786 }
5787 if len == 0 as libc::c_int as libc::c_ulong {
5788 current_block = 11297075595689639996;
5789 } else {
5790 o = createQuicklistObject();
5791 quicklistSetOptions(
5792 (*o).ptr as *mut quicklist,
5793 server.list_max_listpack_size,
5794 server.list_compress_depth,
5795 );
5796 let mut container: uint64_t = 2 as libc::c_int as uint64_t;
5797 loop {
5798 let fresh3 = len;
5799 len = len.wrapping_sub(1);
5800 if !(fresh3 != 0) {
5801 break;
5802 }
5803 let mut lp: *mut libc::c_uchar = 0 as *mut libc::c_uchar;
5804 let mut encoded_len: size_t = 0;
5805 if rdbtype == 18 as libc::c_int {
5806 container = rdbLoadLen(rdb, 0 as *mut libc::c_int);
5807 if container == 18446744073709551615 as libc::c_ulong {
5808 decrRefCount(o);
5809 return 0 as *mut robj;
5810 }
5811 if container != 2 as libc::c_int as libc::c_ulong
5812 && container != 1 as libc::c_int as libc::c_ulong
5813 {
5814 rdbReportError(
5815 1 as libc::c_int,
5816 2047 as libc::c_int,
5817 b"Quicklist integrity check failed.\0" as *const u8
5818 as *const libc::c_char as *mut libc::c_char,
5819 );
5820 decrRefCount(o);
5821 return 0 as *mut robj;
5822 }
5823 }
5824 let mut data: *mut libc::c_uchar = rdbGenericLoadStringObject(
5825 rdb,
5826 (1 as libc::c_int) << 1 as libc::c_int,
5827 &mut encoded_len,
5828 ) as *mut libc::c_uchar;
5829 if data.is_null() || encoded_len == 0 as libc::c_int as libc::c_ulong
5830 {
5831 zfree(data as *mut libc::c_void);
5832 decrRefCount(o);
5833 return 0 as *mut robj;
5834 }
5835 if container == 1 as libc::c_int as libc::c_ulong {
5836 quicklistAppendPlainNode(
5837 (*o).ptr as *mut quicklist,
5838 data,
5839 encoded_len,
5840 );
5841 } else {
5842 if rdbtype == 18 as libc::c_int {
5843 lp = data;
5844 if deep_integrity_validation != 0 {
5845 server.stat_dump_payload_sanitizations += 1;
5846 }
5847 if lpValidateIntegrity(
5848 lp,
5849 encoded_len,
5850 deep_integrity_validation,
5851 None,
5852 0 as *mut libc::c_void,
5853 ) == 0
5854 {
5855 rdbReportError(
5856 1 as libc::c_int,
5857 2070 as libc::c_int,
5858 b"Listpack integrity check failed.\0" as *const u8
5859 as *const libc::c_char as *mut libc::c_char,
5860 );
5861 decrRefCount(o);
5862 zfree(lp as *mut libc::c_void);
5863 return 0 as *mut robj;
5864 }
5865 } else {
5866 lp = lpNew(encoded_len);
5867 if ziplistValidateIntegrity(
5868 data,
5869 encoded_len,
5870 1 as libc::c_int,
5871 Some(
5872 _ziplistEntryConvertAndValidate
5873 as unsafe extern "C" fn(
5874 *mut libc::c_uchar,
5875 libc::c_uint,
5876 *mut libc::c_void,
5877 ) -> libc::c_int,
5878 ),
5879 &mut lp as *mut *mut libc::c_uchar as *mut libc::c_void,
5880 ) == 0
5881 {
5882 rdbReportError(
5883 1 as libc::c_int,
5884 2080 as libc::c_int,
5885 b"Ziplist integrity check failed.\0" as *const u8
5886 as *const libc::c_char as *mut libc::c_char,
5887 );
5888 decrRefCount(o);
5889 zfree(data as *mut libc::c_void);
5890 zfree(lp as *mut libc::c_void);
5891 return 0 as *mut robj;
5892 }
5893 zfree(data as *mut libc::c_void);
5894 lp = lpShrinkToFit(lp);
5895 }
5896 if lpLength(lp) == 0 as libc::c_int as libc::c_ulong {
5897 zfree(lp as *mut libc::c_void);
5898 } else {
5899 quicklistAppendListpack((*o).ptr as *mut quicklist, lp);
5900 }
5901 }
5902 }
5903 if quicklistCount((*o).ptr as *const quicklist)
5904 == 0 as libc::c_int as libc::c_ulong
5905 {
5906 decrRefCount(o);
5907 current_block = 11297075595689639996;
5908 } else {
5909 current_block = 10856689599696957676;
5910 }
5911 }
5912 } else if rdbtype == 9 as libc::c_int || rdbtype == 10 as libc::c_int
5913 || rdbtype == 11 as libc::c_int || rdbtype == 12 as libc::c_int
5914 || rdbtype == 17 as libc::c_int || rdbtype == 13 as libc::c_int
5915 || rdbtype == 16 as libc::c_int
5916 {
5917 let mut encoded_len_0: size_t = 0;
5918 let mut encoded: *mut libc::c_uchar = rdbGenericLoadStringObject(
5919 rdb,
5920 (1 as libc::c_int) << 1 as libc::c_int,
5921 &mut encoded_len_0,
5922 ) as *mut libc::c_uchar;
5923 if encoded.is_null() {
5924 return 0 as *mut robj;
5925 }
5926 o = createObject(0 as libc::c_int, encoded as *mut libc::c_void);
5927 match rdbtype {
5928 9 => {
5929 if zipmapValidateIntegrity(encoded, encoded_len_0, 1 as libc::c_int)
5930 == 0
5931 {
5932 rdbReportError(
5933 1 as libc::c_int,
5934 2129 as libc::c_int,
5935 b"Zipmap integrity check failed.\0" as *const u8
5936 as *const libc::c_char as *mut libc::c_char,
5937 );
5938 zfree(encoded as *mut libc::c_void);
5939 (*o).ptr = 0 as *mut libc::c_void;
5940 decrRefCount(o);
5941 return 0 as *mut robj;
5942 }
5943 let mut lp_0: *mut libc::c_uchar = lpNew(0 as libc::c_int as size_t);
5944 let mut zi: *mut libc::c_uchar = zipmapRewind(
5945 (*o).ptr as *mut libc::c_uchar,
5946 );
5947 let mut fstr: *mut libc::c_uchar = 0 as *mut libc::c_uchar;
5948 let mut vstr: *mut libc::c_uchar = 0 as *mut libc::c_uchar;
5949 let mut flen: libc::c_uint = 0;
5950 let mut vlen: libc::c_uint = 0;
5951 let mut maxlen: libc::c_uint = 0 as libc::c_int as libc::c_uint;
5952 let mut dupSearchDict_0: *mut dict = dictCreate(&mut hashDictType);
5953 loop {
5954 zi = zipmapNext(zi, &mut fstr, &mut flen, &mut vstr, &mut vlen);
5955 if zi.is_null() {
5956 break;
5957 }
5958 if flen > maxlen {
5959 maxlen = flen;
5960 }
5961 if vlen > maxlen {
5962 maxlen = vlen;
5963 }
5964 let mut field_0: sds = sdstrynewlen(
5965 fstr as *const libc::c_void,
5966 flen as size_t,
5967 );
5968 if field_0.is_null()
5969 || dictAdd(
5970 dupSearchDict_0,
5971 field_0 as *mut libc::c_void,
5972 0 as *mut libc::c_void,
5973 ) != 0 as libc::c_int
5974 || lpSafeToAdd(
5975 lp_0,
5976 (flen as size_t).wrapping_add(vlen as libc::c_ulong),
5977 ) == 0
5978 {
5979 rdbReportError(
5980 1 as libc::c_int,
5981 2153 as libc::c_int,
5982 b"Hash zipmap with dup elements, or big length (%u)\0"
5983 as *const u8 as *const libc::c_char as *mut libc::c_char,
5984 flen,
5985 );
5986 dictRelease(dupSearchDict_0);
5987 sdsfree(field_0);
5988 zfree(encoded as *mut libc::c_void);
5989 (*o).ptr = 0 as *mut libc::c_void;
5990 decrRefCount(o);
5991 return 0 as *mut robj;
5992 }
5993 lp_0 = lpAppend(lp_0, fstr, flen);
5994 lp_0 = lpAppend(lp_0, vstr, vlen);
5995 }
5996 dictRelease(dupSearchDict_0);
5997 zfree((*o).ptr);
5998 (*o).ptr = lp_0 as *mut libc::c_void;
5999 (*o).set_type_0(4 as libc::c_int as libc::c_uint);
6000 (*o).set_encoding(11 as libc::c_int as libc::c_uint);
6001 if hashTypeLength(o) > server.hash_max_listpack_entries
6002 || maxlen as libc::c_ulong > server.hash_max_listpack_value
6003 {
6004 hashTypeConvert(o, 2 as libc::c_int);
6005 }
6006 current_block = 10856689599696957676;
6007 }
6008 10 => {
6009 let mut ql: *mut quicklist = quicklistNew(
6010 server.list_max_listpack_size,
6011 server.list_compress_depth,
6012 );
6013 if ziplistValidateIntegrity(
6014 encoded,
6015 encoded_len_0,
6016 1 as libc::c_int,
6017 Some(
6018 _listZiplistEntryConvertAndValidate
6019 as unsafe extern "C" fn(
6020 *mut libc::c_uchar,
6021 libc::c_uint,
6022 *mut libc::c_void,
6023 ) -> libc::c_int,
6024 ),
6025 ql as *mut libc::c_void,
6026 ) == 0
6027 {
6028 rdbReportError(
6029 1 as libc::c_int,
6030 2187 as libc::c_int,
6031 b"List ziplist integrity check failed.\0" as *const u8
6032 as *const libc::c_char as *mut libc::c_char,
6033 );
6034 zfree(encoded as *mut libc::c_void);
6035 (*o).ptr = 0 as *mut libc::c_void;
6036 decrRefCount(o);
6037 quicklistRelease(ql);
6038 return 0 as *mut robj;
6039 }
6040 if (*ql).len == 0 as libc::c_int as libc::c_ulong {
6041 zfree(encoded as *mut libc::c_void);
6042 (*o).ptr = 0 as *mut libc::c_void;
6043 decrRefCount(o);
6044 quicklistRelease(ql);
6045 current_block = 11297075595689639996;
6046 } else {
6047 zfree(encoded as *mut libc::c_void);
6048 (*o).set_type_0(1 as libc::c_int as libc::c_uint);
6049 (*o).ptr = ql as *mut libc::c_void;
6050 (*o).set_encoding(9 as libc::c_int as libc::c_uint);
6051 current_block = 10856689599696957676;
6052 }
6053 }
6054 11 => {
6055 if deep_integrity_validation != 0 {
6056 server.stat_dump_payload_sanitizations += 1;
6057 }
6058 if intsetValidateIntegrity(
6059 encoded,
6060 encoded_len_0,
6061 deep_integrity_validation,
6062 ) == 0
6063 {
6064 rdbReportError(
6065 1 as libc::c_int,
6066 2212 as libc::c_int,
6067 b"Intset integrity check failed.\0" as *const u8
6068 as *const libc::c_char as *mut libc::c_char,
6069 );
6070 zfree(encoded as *mut libc::c_void);
6071 (*o).ptr = 0 as *mut libc::c_void;
6072 decrRefCount(o);
6073 return 0 as *mut robj;
6074 }
6075 (*o).set_type_0(2 as libc::c_int as libc::c_uint);
6076 (*o).set_encoding(6 as libc::c_int as libc::c_uint);
6077 if intsetLen((*o).ptr as *const intset) as libc::c_ulong
6078 > server.set_max_intset_entries
6079 {
6080 setTypeConvert(o, 2 as libc::c_int);
6081 }
6082 current_block = 10856689599696957676;
6083 }
6084 12 => {
6085 let mut lp_1: *mut libc::c_uchar = lpNew(encoded_len_0);
6086 if ziplistPairsConvertAndValidateIntegrity(
6087 encoded,
6088 encoded_len_0,
6089 &mut lp_1,
6090 ) == 0
6091 {
6092 rdbReportError(
6093 1 as libc::c_int,
6094 2227 as libc::c_int,
6095 b"Zset ziplist integrity check failed.\0" as *const u8
6096 as *const libc::c_char as *mut libc::c_char,
6097 );
6098 zfree(lp_1 as *mut libc::c_void);
6099 zfree(encoded as *mut libc::c_void);
6100 (*o).ptr = 0 as *mut libc::c_void;
6101 decrRefCount(o);
6102 return 0 as *mut robj;
6103 }
6104 zfree((*o).ptr);
6105 (*o).set_type_0(3 as libc::c_int as libc::c_uint);
6106 (*o).ptr = lp_1 as *mut libc::c_void;
6107 (*o).set_encoding(11 as libc::c_int as libc::c_uint);
6108 if zsetLength(o) == 0 as libc::c_int as libc::c_ulong {
6109 decrRefCount(o);
6110 current_block = 11297075595689639996;
6111 } else {
6112 if zsetLength(o) > server.zset_max_listpack_entries {
6113 zsetConvert(o, 7 as libc::c_int);
6114 } else {
6115 (*o)
6116 .ptr = lpShrinkToFit((*o).ptr as *mut libc::c_uchar)
6117 as *mut libc::c_void;
6118 }
6119 current_block = 10856689599696957676;
6120 }
6121 }
6122 17 => {
6123 if deep_integrity_validation != 0 {
6124 server.stat_dump_payload_sanitizations += 1;
6125 }
6126 if lpPairsValidateIntegrityAndDups(
6127 encoded,
6128 encoded_len_0,
6129 deep_integrity_validation,
6130 ) == 0
6131 {
6132 rdbReportError(
6133 1 as libc::c_int,
6134 2253 as libc::c_int,
6135 b"Zset listpack integrity check failed.\0" as *const u8
6136 as *const libc::c_char as *mut libc::c_char,
6137 );
6138 zfree(encoded as *mut libc::c_void);
6139 (*o).ptr = 0 as *mut libc::c_void;
6140 decrRefCount(o);
6141 return 0 as *mut robj;
6142 }
6143 (*o).set_type_0(3 as libc::c_int as libc::c_uint);
6144 (*o).set_encoding(11 as libc::c_int as libc::c_uint);
6145 if zsetLength(o) == 0 as libc::c_int as libc::c_ulong {
6146 decrRefCount(o);
6147 current_block = 11297075595689639996;
6148 } else {
6149 if zsetLength(o) > server.zset_max_listpack_entries {
6150 zsetConvert(o, 7 as libc::c_int);
6151 }
6152 current_block = 10856689599696957676;
6153 }
6154 }
6155 13 => {
6156 let mut lp_2: *mut libc::c_uchar = lpNew(encoded_len_0);
6157 if ziplistPairsConvertAndValidateIntegrity(
6158 encoded,
6159 encoded_len_0,
6160 &mut lp_2,
6161 ) == 0
6162 {
6163 rdbReportError(
6164 1 as libc::c_int,
6165 2273 as libc::c_int,
6166 b"Hash ziplist integrity check failed.\0" as *const u8
6167 as *const libc::c_char as *mut libc::c_char,
6168 );
6169 zfree(lp_2 as *mut libc::c_void);
6170 zfree(encoded as *mut libc::c_void);
6171 (*o).ptr = 0 as *mut libc::c_void;
6172 decrRefCount(o);
6173 return 0 as *mut robj;
6174 }
6175 zfree((*o).ptr);
6176 (*o).ptr = lp_2 as *mut libc::c_void;
6177 (*o).set_type_0(4 as libc::c_int as libc::c_uint);
6178 (*o).set_encoding(11 as libc::c_int as libc::c_uint);
6179 if hashTypeLength(o) == 0 as libc::c_int as libc::c_ulong {
6180 decrRefCount(o);
6181 current_block = 11297075595689639996;
6182 } else {
6183 if hashTypeLength(o) > server.hash_max_listpack_entries {
6184 hashTypeConvert(o, 2 as libc::c_int);
6185 } else {
6186 (*o)
6187 .ptr = lpShrinkToFit((*o).ptr as *mut libc::c_uchar)
6188 as *mut libc::c_void;
6189 }
6190 current_block = 10856689599696957676;
6191 }
6192 }
6193 16 => {
6194 if deep_integrity_validation != 0 {
6195 server.stat_dump_payload_sanitizations += 1;
6196 }
6197 if lpPairsValidateIntegrityAndDups(
6198 encoded,
6199 encoded_len_0,
6200 deep_integrity_validation,
6201 ) == 0
6202 {
6203 rdbReportError(
6204 1 as libc::c_int,
6205 2299 as libc::c_int,
6206 b"Hash listpack integrity check failed.\0" as *const u8
6207 as *const libc::c_char as *mut libc::c_char,
6208 );
6209 zfree(encoded as *mut libc::c_void);
6210 (*o).ptr = 0 as *mut libc::c_void;
6211 decrRefCount(o);
6212 return 0 as *mut robj;
6213 }
6214 (*o).set_type_0(4 as libc::c_int as libc::c_uint);
6215 (*o).set_encoding(11 as libc::c_int as libc::c_uint);
6216 if hashTypeLength(o) == 0 as libc::c_int as libc::c_ulong {
6217 decrRefCount(o);
6218 current_block = 11297075595689639996;
6219 } else {
6220 if hashTypeLength(o) > server.hash_max_listpack_entries {
6221 hashTypeConvert(o, 2 as libc::c_int);
6222 }
6223 current_block = 10856689599696957676;
6224 }
6225 }
6226 _ => {
6227 rdbReportError(
6228 1 as libc::c_int,
6229 2317 as libc::c_int,
6230 b"Unknown RDB encoding type %d\0" as *const u8
6231 as *const libc::c_char as *mut libc::c_char,
6232 rdbtype,
6233 );
6234 current_block = 10856689599696957676;
6235 }
6236 }
6237 } else {
6238 if rdbtype == 15 as libc::c_int || rdbtype == 19 as libc::c_int {
6239 o = createStreamObject();
6240 let mut s: *mut stream = (*o).ptr as *mut stream;
6241 let mut listpacks: uint64_t = rdbLoadLen(rdb, 0 as *mut libc::c_int);
6242 if listpacks == 18446744073709551615 as libc::c_ulong {
6243 rdbReportError(
6244 0 as libc::c_int,
6245 2325 as libc::c_int,
6246 b"Stream listpacks len loading failed.\0" as *const u8
6247 as *const libc::c_char as *mut libc::c_char,
6248 );
6249 decrRefCount(o);
6250 return 0 as *mut robj;
6251 }
6252 loop {
6253 let fresh4 = listpacks;
6254 listpacks = listpacks.wrapping_sub(1);
6255 if !(fresh4 != 0) {
6256 break;
6257 }
6258 let mut nodekey: sds = rdbGenericLoadStringObject(
6259 rdb,
6260 (1 as libc::c_int) << 2 as libc::c_int,
6261 0 as *mut size_t,
6262 ) as sds;
6263 if nodekey.is_null() {
6264 rdbReportError(
6265 0 as libc::c_int,
6266 2336 as libc::c_int,
6267 b"Stream master ID loading failed: invalid encoding or I/O error.\0"
6268 as *const u8 as *const libc::c_char as *mut libc::c_char,
6269 );
6270 decrRefCount(o);
6271 return 0 as *mut robj;
6272 }
6273 if sdslen(nodekey)
6274 != core::mem::size_of::<streamID>() as libc::c_ulong
6275 {
6276 rdbReportError(
6277 1 as libc::c_int,
6278 2342 as libc::c_int,
6279 b"Stream node key entry is not the size of a stream ID\0"
6280 as *const u8 as *const libc::c_char as *mut libc::c_char,
6281 );
6282 sdsfree(nodekey);
6283 decrRefCount(o);
6284 return 0 as *mut robj;
6285 }
6286 let mut lp_size: size_t = 0;
6287 let mut lp_3: *mut libc::c_uchar = rdbGenericLoadStringObject(
6288 rdb,
6289 (1 as libc::c_int) << 1 as libc::c_int,
6290 &mut lp_size,
6291 ) as *mut libc::c_uchar;
6292 if lp_3.is_null() {
6293 rdbReportError(
6294 0 as libc::c_int,
6295 2353 as libc::c_int,
6296 b"Stream listpacks loading failed.\0" as *const u8
6297 as *const libc::c_char as *mut libc::c_char,
6298 );
6299 sdsfree(nodekey);
6300 decrRefCount(o);
6301 return 0 as *mut robj;
6302 }
6303 if deep_integrity_validation != 0 {
6304 server.stat_dump_payload_sanitizations += 1;
6305 }
6306 if streamValidateListpackIntegrity(
6307 lp_3,
6308 lp_size,
6309 deep_integrity_validation,
6310 ) == 0
6311 {
6312 rdbReportError(
6313 1 as libc::c_int,
6314 2360 as libc::c_int,
6315 b"Stream listpack integrity check failed.\0" as *const u8
6316 as *const libc::c_char as *mut libc::c_char,
6317 );
6318 sdsfree(nodekey);
6319 decrRefCount(o);
6320 zfree(lp_3 as *mut libc::c_void);
6321 return 0 as *mut robj;
6322 }
6323 let mut first: *mut libc::c_uchar = lpFirst(lp_3);
6324 if first.is_null() {
6325 rdbReportError(
6326 1 as libc::c_int,
6327 2372 as libc::c_int,
6328 b"Empty listpack inside stream\0" as *const u8
6329 as *const libc::c_char as *mut libc::c_char,
6330 );
6331 sdsfree(nodekey);
6332 decrRefCount(o);
6333 zfree(lp_3 as *mut libc::c_void);
6334 return 0 as *mut robj;
6335 }
6336 let mut retval: libc::c_int = raxTryInsert(
6337 (*s).rax,
6338 nodekey as *mut libc::c_uchar,
6339 core::mem::size_of::<streamID>() as libc::c_ulong,
6340 lp_3 as *mut libc::c_void,
6341 0 as *mut *mut libc::c_void,
6342 );
6343 sdsfree(nodekey);
6344 if retval == 0 {
6345 rdbReportError(
6346 1 as libc::c_int,
6347 2384 as libc::c_int,
6348 b"Listpack re-added with existing key\0" as *const u8
6349 as *const libc::c_char as *mut libc::c_char,
6350 );
6351 decrRefCount(o);
6352 zfree(lp_3 as *mut libc::c_void);
6353 return 0 as *mut robj;
6354 }
6355 }
6356 (*s).length = rdbLoadLen(rdb, 0 as *mut libc::c_int);
6357 (*s).last_id.ms = rdbLoadLen(rdb, 0 as *mut libc::c_int);
6358 (*s).last_id.seq = rdbLoadLen(rdb, 0 as *mut libc::c_int);
6359 if rdbtype == 19 as libc::c_int {
6360 (*s).first_id.ms = rdbLoadLen(rdb, 0 as *mut libc::c_int);
6361 (*s).first_id.seq = rdbLoadLen(rdb, 0 as *mut libc::c_int);
6362 (*s)
6363 .max_deleted_entry_id
6364 .ms = rdbLoadLen(rdb, 0 as *mut libc::c_int);
6365 (*s)
6366 .max_deleted_entry_id
6367 .seq = rdbLoadLen(rdb, 0 as *mut libc::c_int);
6368 (*s).entries_added = rdbLoadLen(rdb, 0 as *mut libc::c_int);
6369 } else {
6370 (*s).max_deleted_entry_id.ms = 0 as libc::c_int as uint64_t;
6371 (*s).max_deleted_entry_id.seq = 0 as libc::c_int as uint64_t;
6372 (*s).entries_added = (*s).length;
6373 streamGetEdgeID(
6374 s,
6375 1 as libc::c_int,
6376 1 as libc::c_int,
6377 &mut (*s).first_id,
6378 );
6379 }
6380 if rioGetReadError(rdb) != 0 {
6381 rdbReportError(
6382 0 as libc::c_int,
6383 2422 as libc::c_int,
6384 b"Stream object metadata loading failed.\0" as *const u8
6385 as *const libc::c_char as *mut libc::c_char,
6386 );
6387 decrRefCount(o);
6388 return 0 as *mut robj;
6389 }
6390 if (*s).length != 0 && raxSize((*s).rax) == 0 {
6391 rdbReportError(
6392 1 as libc::c_int,
6393 2428 as libc::c_int,
6394 b"Stream length inconsistent with rax entries\0" as *const u8
6395 as *const libc::c_char as *mut libc::c_char,
6396 );
6397 decrRefCount(o);
6398 return 0 as *mut robj;
6399 }
6400 let mut cgroups_count: uint64_t = rdbLoadLen(rdb, 0 as *mut libc::c_int);
6401 if cgroups_count == 18446744073709551615 as libc::c_ulong {
6402 rdbReportError(
6403 0 as libc::c_int,
6404 2436 as libc::c_int,
6405 b"Stream cgroup count loading failed.\0" as *const u8
6406 as *const libc::c_char as *mut libc::c_char,
6407 );
6408 decrRefCount(o);
6409 return 0 as *mut robj;
6410 }
6411 loop {
6412 let fresh5 = cgroups_count;
6413 cgroups_count = cgroups_count.wrapping_sub(1);
6414 if !(fresh5 != 0) {
6415 break;
6416 }
6417 let mut cg_id: streamID = streamID { ms: 0, seq: 0 };
6418 let mut cgname: sds = rdbGenericLoadStringObject(
6419 rdb,
6420 (1 as libc::c_int) << 2 as libc::c_int,
6421 0 as *mut size_t,
6422 ) as sds;
6423 if cgname.is_null() {
6424 rdbReportError(
6425 0 as libc::c_int,
6426 2448 as libc::c_int,
6427 b"Error reading the consumer group name from Stream\0"
6428 as *const u8 as *const libc::c_char as *mut libc::c_char,
6429 );
6430 decrRefCount(o);
6431 return 0 as *mut robj;
6432 }
6433 cg_id.ms = rdbLoadLen(rdb, 0 as *mut libc::c_int);
6434 cg_id.seq = rdbLoadLen(rdb, 0 as *mut libc::c_int);
6435 if rioGetReadError(rdb) != 0 {
6436 rdbReportError(
6437 0 as libc::c_int,
6438 2456 as libc::c_int,
6439 b"Stream cgroup ID loading failed.\0" as *const u8
6440 as *const libc::c_char as *mut libc::c_char,
6441 );
6442 sdsfree(cgname);
6443 decrRefCount(o);
6444 return 0 as *mut robj;
6445 }
6446 let mut cg_offset: uint64_t = 0;
6447 if rdbtype == 19 as libc::c_int {
6448 cg_offset = rdbLoadLen(rdb, 0 as *mut libc::c_int);
6449 if rioGetReadError(rdb) != 0 {
6450 rdbReportError(
6451 0 as libc::c_int,
6452 2467 as libc::c_int,
6453 b"Stream cgroup offset loading failed.\0" as *const u8
6454 as *const libc::c_char as *mut libc::c_char,
6455 );
6456 sdsfree(cgname);
6457 decrRefCount(o);
6458 return 0 as *mut robj;
6459 }
6460 } else {
6461 cg_offset = streamEstimateDistanceFromFirstEverEntry(
6462 s,
6463 &mut cg_id,
6464 ) as uint64_t;
6465 }
6466 let mut cgroup: *mut streamCG = streamCreateCG(
6467 s,
6468 cgname,
6469 sdslen(cgname),
6470 &mut cg_id,
6471 cg_offset as libc::c_longlong,
6472 );
6473 if cgroup.is_null() {
6474 rdbReportError(
6475 1 as libc::c_int,
6476 2479 as libc::c_int,
6477 b"Duplicated consumer group name %s\0" as *const u8
6478 as *const libc::c_char as *mut libc::c_char,
6479 cgname,
6480 );
6481 decrRefCount(o);
6482 sdsfree(cgname);
6483 return 0 as *mut robj;
6484 }
6485 sdsfree(cgname);
6486 let mut pel_size: uint64_t = rdbLoadLen(rdb, 0 as *mut libc::c_int);
6487 if pel_size == 18446744073709551615 as libc::c_ulong {
6488 rdbReportError(
6489 0 as libc::c_int,
6490 2493 as libc::c_int,
6491 b"Stream PEL size loading failed.\0" as *const u8
6492 as *const libc::c_char as *mut libc::c_char,
6493 );
6494 decrRefCount(o);
6495 return 0 as *mut robj;
6496 }
6497 loop {
6498 let fresh6 = pel_size;
6499 pel_size = pel_size.wrapping_sub(1);
6500 if !(fresh6 != 0) {
6501 break;
6502 }
6503 let mut rawid: [libc::c_uchar; 16] = [0; 16];
6504 if rioRead(
6505 rdb,
6506 rawid.as_mut_ptr() as *mut libc::c_void,
6507 core::mem::size_of::<[libc::c_uchar; 16]>()
6508 as libc::c_ulong,
6509 ) == 0 as libc::c_int as libc::c_ulong
6510 {
6511 rdbReportError(
6512 0 as libc::c_int,
6513 2500 as libc::c_int,
6514 b"Stream PEL ID loading failed.\0" as *const u8
6515 as *const libc::c_char as *mut libc::c_char,
6516 );
6517 decrRefCount(o);
6518 return 0 as *mut robj;
6519 }
6520 let mut nack: *mut streamNACK = streamCreateNACK(
6521 0 as *mut streamConsumer,
6522 );
6523 (*nack)
6524 .delivery_time = rdbLoadMillisecondTime(
6525 rdb,
6526 10 as libc::c_int,
6527 );
6528 (*nack).delivery_count = rdbLoadLen(rdb, 0 as *mut libc::c_int);
6529 if rioGetReadError(rdb) != 0 {
6530 rdbReportError(
6531 0 as libc::c_int,
6532 2508 as libc::c_int,
6533 b"Stream PEL NACK loading failed.\0" as *const u8
6534 as *const libc::c_char as *mut libc::c_char,
6535 );
6536 decrRefCount(o);
6537 streamFreeNACK(nack);
6538 return 0 as *mut robj;
6539 }
6540 if raxTryInsert(
6541 (*cgroup).pel,
6542 rawid.as_mut_ptr(),
6543 core::mem::size_of::<[libc::c_uchar; 16]>()
6544 as libc::c_ulong,
6545 nack as *mut libc::c_void,
6546 0 as *mut *mut libc::c_void,
6547 ) == 0
6548 {
6549 rdbReportError(
6550 1 as libc::c_int,
6551 2515 as libc::c_int,
6552 b"Duplicated global PEL entry loading stream consumer group\0"
6553 as *const u8 as *const libc::c_char as *mut libc::c_char,
6554 );
6555 decrRefCount(o);
6556 streamFreeNACK(nack);
6557 return 0 as *mut robj;
6558 }
6559 }
6560 let mut consumers_num: uint64_t = rdbLoadLen(
6561 rdb,
6562 0 as *mut libc::c_int,
6563 );
6564 if consumers_num == 18446744073709551615 as libc::c_ulong {
6565 rdbReportError(
6566 0 as libc::c_int,
6567 2526 as libc::c_int,
6568 b"Stream consumers num loading failed.\0" as *const u8
6569 as *const libc::c_char as *mut libc::c_char,
6570 );
6571 decrRefCount(o);
6572 return 0 as *mut robj;
6573 }
6574 loop {
6575 let fresh7 = consumers_num;
6576 consumers_num = consumers_num.wrapping_sub(1);
6577 if !(fresh7 != 0) {
6578 break;
6579 }
6580 let mut cname: sds = rdbGenericLoadStringObject(
6581 rdb,
6582 (1 as libc::c_int) << 2 as libc::c_int,
6583 0 as *mut size_t,
6584 ) as sds;
6585 if cname.is_null() {
6586 rdbReportError(
6587 0 as libc::c_int,
6588 2534 as libc::c_int,
6589 b"Error reading the consumer name from Stream group.\0"
6590 as *const u8 as *const libc::c_char as *mut libc::c_char,
6591 );
6592 decrRefCount(o);
6593 return 0 as *mut robj;
6594 }
6595 let mut consumer: *mut streamConsumer = streamCreateConsumer(
6596 cgroup,
6597 cname,
6598 0 as *mut robj,
6599 0 as libc::c_int,
6600 (1 as libc::c_int) << 0 as libc::c_int
6601 | (1 as libc::c_int) << 1 as libc::c_int,
6602 );
6603 sdsfree(cname);
6604 if consumer.is_null() {
6605 rdbReportError(
6606 1 as libc::c_int,
6607 2542 as libc::c_int,
6608 b"Duplicate stream consumer detected.\0" as *const u8
6609 as *const libc::c_char as *mut libc::c_char,
6610 );
6611 decrRefCount(o);
6612 return 0 as *mut robj;
6613 }
6614 (*consumer)
6615 .seen_time = rdbLoadMillisecondTime(rdb, 10 as libc::c_int);
6616 if rioGetReadError(rdb) != 0 {
6617 rdbReportError(
6618 0 as libc::c_int,
6619 2548 as libc::c_int,
6620 b"Stream short read reading seen time.\0" as *const u8
6621 as *const libc::c_char as *mut libc::c_char,
6622 );
6623 decrRefCount(o);
6624 return 0 as *mut robj;
6625 }
6626 pel_size = rdbLoadLen(rdb, 0 as *mut libc::c_int);
6627 if pel_size == 18446744073709551615 as libc::c_ulong {
6628 rdbReportError(
6629 0 as libc::c_int,
6630 2558 as libc::c_int,
6631 b"Stream consumer PEL num loading failed.\0" as *const u8
6632 as *const libc::c_char as *mut libc::c_char,
6633 );
6634 decrRefCount(o);
6635 return 0 as *mut robj;
6636 }
6637 loop {
6638 let fresh8 = pel_size;
6639 pel_size = pel_size.wrapping_sub(1);
6640 if !(fresh8 != 0) {
6641 break;
6642 }
6643 let mut rawid_0: [libc::c_uchar; 16] = [0; 16];
6644 if rioRead(
6645 rdb,
6646 rawid_0.as_mut_ptr() as *mut libc::c_void,
6647 core::mem::size_of::<[libc::c_uchar; 16]>()
6648 as libc::c_ulong,
6649 ) == 0 as libc::c_int as libc::c_ulong
6650 {
6651 rdbReportError(
6652 0 as libc::c_int,
6653 2566 as libc::c_int,
6654 b"Stream short read reading PEL streamID.\0" as *const u8
6655 as *const libc::c_char as *mut libc::c_char,
6656 );
6657 decrRefCount(o);
6658 return 0 as *mut robj;
6659 }
6660 let mut nack_0: *mut streamNACK = raxFind(
6661 (*cgroup).pel,
6662 rawid_0.as_mut_ptr(),
6663 core::mem::size_of::<[libc::c_uchar; 16]>()
6664 as libc::c_ulong,
6665 ) as *mut streamNACK;
6666 if nack_0 == raxNotFound as *mut streamNACK {
6667 rdbReportError(
6668 1 as libc::c_int,
6669 2573 as libc::c_int,
6670 b"Consumer entry not found in group global PEL\0"
6671 as *const u8 as *const libc::c_char as *mut libc::c_char,
6672 );
6673 decrRefCount(o);
6674 return 0 as *mut robj;
6675 }
6676 (*nack_0).consumer = consumer;
6677 if raxTryInsert(
6678 (*consumer).pel,
6679 rawid_0.as_mut_ptr(),
6680 core::mem::size_of::<[libc::c_uchar; 16]>()
6681 as libc::c_ulong,
6682 nack_0 as *mut libc::c_void,
6683 0 as *mut *mut libc::c_void,
6684 ) == 0
6685 {
6686 rdbReportError(
6687 1 as libc::c_int,
6688 2585 as libc::c_int,
6689 b"Duplicated consumer PEL entry loading a stream consumer group\0"
6690 as *const u8 as *const libc::c_char as *mut libc::c_char,
6691 );
6692 decrRefCount(o);
6693 streamFreeNACK(nack_0);
6694 return 0 as *mut robj;
6695 }
6696 }
6697 }
6698 if deep_integrity_validation != 0 {
6699 let mut ri_cg_pel: raxIterator = raxIterator {
6700 flags: 0,
6701 rt: 0 as *mut rax,
6702 key: 0 as *mut libc::c_uchar,
6703 data: 0 as *mut libc::c_void,
6704 key_len: 0,
6705 key_max: 0,
6706 key_static_string: [0; 128],
6707 node: 0 as *mut raxNode,
6708 stack: raxStack {
6709 stack: 0 as *mut *mut libc::c_void,
6710 items: 0,
6711 maxitems: 0,
6712 static_items: [0 as *mut libc::c_void; 32],
6713 oom: 0,
6714 },
6715 node_cb: None,
6716 };
6717 raxStart(&mut ri_cg_pel, (*cgroup).pel);
6718 raxSeek(
6719 &mut ri_cg_pel,
6720 b"^\0" as *const u8 as *const libc::c_char,
6721 0 as *mut libc::c_uchar,
6722 0 as libc::c_int as size_t,
6723 );
6724 while raxNext(&mut ri_cg_pel) != 0 {
6725 let mut nack_1: *mut streamNACK = ri_cg_pel.data
6726 as *mut streamNACK;
6727 if ((*nack_1).consumer).is_null() {
6728 raxStop(&mut ri_cg_pel);
6729 rdbReportError(
6730 1 as libc::c_int,
6731 2602 as libc::c_int,
6732 b"Stream CG PEL entry without consumer\0" as *const u8
6733 as *const libc::c_char as *mut libc::c_char,
6734 );
6735 decrRefCount(o);
6736 return 0 as *mut robj;
6737 }
6738 }
6739 raxStop(&mut ri_cg_pel);
6740 }
6741 }
6742 } else if rdbtype == 6 as libc::c_int || rdbtype == 7 as libc::c_int {
6743 let mut moduleid: uint64_t = rdbLoadLen(rdb, 0 as *mut libc::c_int);
6744 if rioGetReadError(rdb) != 0 {
6745 rdbReportError(
6746 0 as libc::c_int,
6747 2613 as libc::c_int,
6748 b"Short read module id\0" as *const u8 as *const libc::c_char
6749 as *mut libc::c_char,
6750 );
6751 return 0 as *mut robj;
6752 }
6753 let mut mt: *mut moduleType = moduleTypeLookupModuleByID(moduleid);
6754 if rdbCheckMode != 0 && rdbtype == 7 as libc::c_int {
6755 let mut name: [libc::c_char; 10] = [0; 10];
6756 moduleTypeNameByID(name.as_mut_ptr(), moduleid);
6757 return rdbLoadCheckModuleValue(rdb, name.as_mut_ptr());
6758 }
6759 if mt.is_null() {
6760 let mut name_0: [libc::c_char; 10] = [0; 10];
6761 moduleTypeNameByID(name_0.as_mut_ptr(), moduleid);
6762 rdbReportError(
6763 1 as libc::c_int,
6764 2627 as libc::c_int,
6765 b"The RDB file contains module data I can't load: no matching module type '%s'\0"
6766 as *const u8 as *const libc::c_char as *mut libc::c_char,
6767 name_0.as_mut_ptr(),
6768 );
6769 return 0 as *mut robj;
6770 }
6771 let mut io: RedisModuleIO = RedisModuleIO {
6772 bytes: 0,
6773 rio: 0 as *mut rio,
6774 type_0: 0 as *mut moduleType,
6775 error: 0,
6776 ver: 0,
6777 ctx: 0 as *mut RedisModuleCtx,
6778 key: 0 as *mut redisObject,
6779 dbid: 0,
6780 };
6781 let mut keyobj: robj = robj {
6782 type_0_encoding_lru: [0; 4],
6783 refcount: 0,
6784 ptr: 0 as *mut libc::c_void,
6785 };
6786 keyobj.refcount = 2147483647 as libc::c_int - 1 as libc::c_int;
6787 keyobj.set_type_0(0 as libc::c_int as libc::c_uint);
6788 keyobj.set_encoding(0 as libc::c_int as libc::c_uint);
6789 keyobj.ptr = key as *mut libc::c_void;
6790 io.rio = rdb;
6791 io.type_0 = mt;
6792 io.bytes = 0 as libc::c_int as size_t;
6793 io.error = 0 as libc::c_int;
6794 io.ver = 0 as libc::c_int;
6795 io.key = &mut keyobj;
6796 io.dbid = dbid;
6797 io.ctx = 0 as *mut RedisModuleCtx;
6798 io
6799 .ver = if rdbtype == 6 as libc::c_int {
6800 1 as libc::c_int
6801 } else {
6802 2 as libc::c_int
6803 };
6804 let mut ptr: *mut libc::c_void = ((*mt).rdb_load)
6805 .expect(
6806 "non-null function pointer",
6807 )(
6808 &mut io,
6809 (moduleid & 1023 as libc::c_int as libc::c_ulong) as libc::c_int,
6810 );
6811 if !(io.ctx).is_null() {
6812 moduleFreeContext(io.ctx);
6813 zfree(io.ctx as *mut libc::c_void);
6814 }
6815 if io.ver == 2 as libc::c_int {
6816 let mut eof: uint64_t = rdbLoadLen(rdb, 0 as *mut libc::c_int);
6817 if eof == 18446744073709551615 as libc::c_ulong {
6818 if !ptr.is_null() {
6819 o = createModuleObject(mt, ptr);
6820 decrRefCount(o);
6821 }
6822 return 0 as *mut robj;
6823 }
6824 if eof != 0 as libc::c_int as libc::c_ulong {
6825 rdbReportError(
6826 1 as libc::c_int,
6827 2655 as libc::c_int,
6828 b"The RDB file contains module data for the module '%s' that is not terminated by the proper module value EOF marker\0"
6829 as *const u8 as *const libc::c_char as *mut libc::c_char,
6830 moduleTypeModuleName(mt),
6831 );
6832 if !ptr.is_null() {
6833 o = createModuleObject(mt, ptr);
6834 decrRefCount(o);
6835 }
6836 return 0 as *mut robj;
6837 }
6838 }
6839 if ptr.is_null() {
6840 rdbReportError(
6841 1 as libc::c_int,
6842 2667 as libc::c_int,
6843 b"The RDB file contains module data for the module type '%s', that the responsible module is not able to load. Check for modules log above for additional clues.\0"
6844 as *const u8 as *const libc::c_char as *mut libc::c_char,
6845 moduleTypeModuleName(mt),
6846 );
6847 return 0 as *mut robj;
6848 }
6849 o = createModuleObject(mt, ptr);
6850 } else {
6851 rdbReportError(
6852 0 as libc::c_int,
6853 2672 as libc::c_int,
6854 b"Unknown RDB encoding type %d\0" as *const u8 as *const libc::c_char
6855 as *mut libc::c_char,
6856 rdbtype,
6857 );
6858 return 0 as *mut robj;
6859 }
6860 current_block = 10856689599696957676;
6861 }
6862 match current_block {
6863 10856689599696957676 => {}
6864 _ => {
6865 if !error.is_null() {
6866 *error = 1 as libc::c_int;
6867 }
6868 return 0 as *mut robj;
6869 }
6870 }
6871 }
6872 if !error.is_null() {
6873 *error = 0 as libc::c_int;
6874 }
6875 return o;
6876}
6877#[no_mangle]
6878pub unsafe extern "C" fn startLoading(
6879 mut size: size_t,
6880 mut rdbflags: libc::c_int,
6881 mut async_0: libc::c_int,
6882) {
6883 core::ptr::write_volatile(
6884 &mut server.loading as *mut sig_atomic_t,
6885 1 as libc::c_int,
6886 );
6887 if async_0 == 1 as libc::c_int {
6888 core::ptr::write_volatile(
6889 &mut server.async_loading as *mut sig_atomic_t,
6890 1 as libc::c_int,
6891 );
6892 }
6893 server.loading_start_time = time(0 as *mut time_t);
6894 server.loading_loaded_bytes = 0 as libc::c_int as off_t;
6895 server.loading_total_bytes = size as off_t;
6896 server.loading_rdb_used_mem = 0 as libc::c_int as off_t;
6897 server.rdb_last_load_keys_expired = 0 as libc::c_int as libc::c_longlong;
6898 server.rdb_last_load_keys_loaded = 0 as libc::c_int as libc::c_longlong;
6899 blockingOperationStarts();
6900 let mut subevent: libc::c_int = 0;
6901 if rdbflags & (1 as libc::c_int) << 0 as libc::c_int != 0 {
6902 subevent = 1 as libc::c_int;
6903 } else if rdbflags & (1 as libc::c_int) << 1 as libc::c_int != 0 {
6904 subevent = 2 as libc::c_int;
6905 } else {
6906 subevent = 0 as libc::c_int;
6907 }
6908 moduleFireServerEvent(
6909 3 as libc::c_int as uint64_t,
6910 subevent,
6911 0 as *mut libc::c_void,
6912 );
6913}
6914#[no_mangle]
6915pub unsafe extern "C" fn startLoadingFile(
6916 mut size: size_t,
6917 mut filename: *mut libc::c_char,
6918 mut rdbflags: libc::c_int,
6919) {
6920 rdbFileBeingLoaded = filename;
6921 startLoading(size, rdbflags, 0 as libc::c_int);
6922}
6923#[no_mangle]
6924pub unsafe extern "C" fn loadingAbsProgress(mut pos: off_t) {
6925 server.loading_loaded_bytes = pos;
6926 if server.stat_peak_memory < zmalloc_used_memory() {
6927 server.stat_peak_memory = zmalloc_used_memory();
6928 }
6929}
6930#[no_mangle]
6931pub unsafe extern "C" fn loadingIncrProgress(mut size: off_t) {
6932 server.loading_loaded_bytes += size;
6933 if server.stat_peak_memory < zmalloc_used_memory() {
6934 server.stat_peak_memory = zmalloc_used_memory();
6935 }
6936}
6937#[no_mangle]
6938pub unsafe extern "C" fn updateLoadingFileName(mut filename: *mut libc::c_char) {
6939 rdbFileBeingLoaded = filename;
6940}
6941#[no_mangle]
6942pub unsafe extern "C" fn stopLoading(mut success: libc::c_int) {
6943 core::ptr::write_volatile(
6944 &mut server.loading as *mut sig_atomic_t,
6945 0 as libc::c_int,
6946 );
6947 core::ptr::write_volatile(
6948 &mut server.async_loading as *mut sig_atomic_t,
6949 0 as libc::c_int,
6950 );
6951 blockingOperationEnds();
6952 rdbFileBeingLoaded = 0 as *mut libc::c_char;
6953 moduleFireServerEvent(
6954 3 as libc::c_int as uint64_t,
6955 if success != 0 { 3 as libc::c_int } else { 4 as libc::c_int },
6956 0 as *mut libc::c_void,
6957 );
6958}
6959#[no_mangle]
6960pub unsafe extern "C" fn startSaving(mut rdbflags: libc::c_int) {
6961 let mut subevent: libc::c_int = 0;
6962 if rdbflags & (1 as libc::c_int) << 0 as libc::c_int != 0 && getpid() != server.pid {
6963 subevent = 1 as libc::c_int;
6964 } else if rdbflags & (1 as libc::c_int) << 0 as libc::c_int != 0 {
6965 subevent = 5 as libc::c_int;
6966 } else if getpid() != server.pid {
6967 subevent = 0 as libc::c_int;
6968 } else {
6969 subevent = 2 as libc::c_int;
6970 }
6971 moduleFireServerEvent(
6972 1 as libc::c_int as uint64_t,
6973 subevent,
6974 0 as *mut libc::c_void,
6975 );
6976}
6977#[no_mangle]
6978pub unsafe extern "C" fn stopSaving(mut success: libc::c_int) {
6979 moduleFireServerEvent(
6980 1 as libc::c_int as uint64_t,
6981 if success != 0 { 3 as libc::c_int } else { 4 as libc::c_int },
6982 0 as *mut libc::c_void,
6983 );
6984}
6985#[no_mangle]
6986pub unsafe extern "C" fn rdbLoadProgressCallback(
6987 mut r: *mut rio,
6988 mut buf: *const libc::c_void,
6989 mut len: size_t,
6990) {
6991 if server.rdb_checksum != 0 {
6992 rioGenericUpdateChecksum(r, buf, len);
6993 }
6994 if server.loading_process_events_interval_bytes != 0
6995 && ((*r).processed_bytes)
6996 .wrapping_add(len)
6997 .wrapping_div(server.loading_process_events_interval_bytes as libc::c_ulong)
6998 > ((*r).processed_bytes)
6999 .wrapping_div(
7000 server.loading_process_events_interval_bytes as libc::c_ulong,
7001 )
7002 {
7003 if !(server.masterhost).is_null()
7004 && server.repl_state == REPL_STATE_TRANSFER as libc::c_int
7005 {
7006 replicationSendNewlineToMaster();
7007 }
7008 loadingAbsProgress((*r).processed_bytes as off_t);
7009 processEventsWhileBlocked();
7010 processModuleLoadingProgressEvent(0 as libc::c_int);
7011 }
7012 if server.repl_state == REPL_STATE_TRANSFER as libc::c_int
7013 && rioCheckType(r) as libc::c_int == (1 as libc::c_int) << 2 as libc::c_int
7014 {
7015 let fresh9 = &mut server.stat_net_repl_input_bytes;
7016 let fresh10 = len as libc::c_longlong;
7017 core::intrinsics::atomic_xadd_relaxed(fresh9, fresh10) + fresh10;
7018 }
7019}
7020#[no_mangle]
7021pub unsafe extern "C" fn rdbFunctionLoad(
7022 mut rdb: *mut rio,
7023 mut ver: libc::c_int,
7024 mut lib_ctx: *mut functionsLibCtx,
7025 mut type_0: libc::c_int,
7026 mut rdbflags: libc::c_int,
7027 mut err: *mut sds,
7028) -> libc::c_int {
7029 let mut current_block: u64;
7030 let mut error: sds = 0 as sds;
7031 let mut final_payload: sds = 0 as sds;
7032 let mut res: libc::c_int = -(1 as libc::c_int);
7033 if type_0 == 246 as libc::c_int {
7034 let mut name: sds = 0 as sds;
7035 let mut engine_name: sds = 0 as sds;
7036 let mut desc: sds = 0 as sds;
7037 let mut blob: sds = 0 as sds;
7038 let mut has_desc: uint64_t = 0;
7039 name = rdbGenericLoadStringObject(
7040 rdb,
7041 (1 as libc::c_int) << 2 as libc::c_int,
7042 0 as *mut size_t,
7043 ) as sds;
7044 if name.is_null() {
7045 error = sdsnew(
7046 b"Failed loading library name\0" as *const u8 as *const libc::c_char,
7047 );
7048 } else {
7049 engine_name = rdbGenericLoadStringObject(
7050 rdb,
7051 (1 as libc::c_int) << 2 as libc::c_int,
7052 0 as *mut size_t,
7053 ) as sds;
7054 if engine_name.is_null() {
7055 error = sdsnew(
7056 b"Failed loading engine name\0" as *const u8 as *const libc::c_char,
7057 );
7058 } else {
7059 has_desc = rdbLoadLen(rdb, 0 as *mut libc::c_int);
7060 if has_desc == 18446744073709551615 as libc::c_ulong {
7061 error = sdsnew(
7062 b"Failed loading library description indicator\0" as *const u8
7063 as *const libc::c_char,
7064 );
7065 } else if has_desc != 0
7066 && {
7067 desc = rdbGenericLoadStringObject(
7068 rdb,
7069 (1 as libc::c_int) << 2 as libc::c_int,
7070 0 as *mut size_t,
7071 ) as sds;
7072 desc.is_null()
7073 }
7074 {
7075 error = sdsnew(
7076 b"Failed loading library description\0" as *const u8
7077 as *const libc::c_char,
7078 );
7079 } else {
7080 blob = rdbGenericLoadStringObject(
7081 rdb,
7082 (1 as libc::c_int) << 2 as libc::c_int,
7083 0 as *mut size_t,
7084 ) as sds;
7085 if blob.is_null() {
7086 error = sdsnew(
7087 b"Failed loading library blob\0" as *const u8
7088 as *const libc::c_char,
7089 );
7090 } else {
7091 final_payload = sdscatfmt(
7092 sdsempty(),
7093 b"#!%s name=%s\n%s\0" as *const u8 as *const libc::c_char,
7094 engine_name,
7095 name,
7096 blob,
7097 );
7098 }
7099 }
7100 }
7101 }
7102 if !name.is_null() {
7103 sdsfree(name);
7104 }
7105 if !engine_name.is_null() {
7106 sdsfree(engine_name);
7107 }
7108 if !desc.is_null() {
7109 sdsfree(desc);
7110 }
7111 if !blob.is_null() {
7112 sdsfree(blob);
7113 }
7114 if !error.is_null() {
7115 current_block = 6387762410704612043;
7116 } else {
7117 current_block = 1608152415753874203;
7118 }
7119 } else if type_0 == 245 as libc::c_int {
7120 final_payload = rdbGenericLoadStringObject(
7121 rdb,
7122 (1 as libc::c_int) << 2 as libc::c_int,
7123 0 as *mut size_t,
7124 ) as sds;
7125 if final_payload.is_null() {
7126 error = sdsnew(
7127 b"Failed loading library payload\0" as *const u8 as *const libc::c_char,
7128 );
7129 current_block = 6387762410704612043;
7130 } else {
7131 current_block = 1608152415753874203;
7132 }
7133 } else {
7134 _serverPanic(
7135 b"rdb.c\0" as *const u8 as *const libc::c_char,
7136 2854 as libc::c_int,
7137 b"Bad function type was given to rdbFunctionLoad\0" as *const u8
7138 as *const libc::c_char,
7139 );
7140 unreachable!();
7141 current_block = 1608152415753874203;
7142 }
7143 match current_block {
7144 1608152415753874203 => {
7145 if !lib_ctx.is_null() {
7146 let mut library_name: sds = 0 as sds;
7147 library_name = functionsCreateWithLibraryCtx(
7148 final_payload,
7149 rdbflags & (1 as libc::c_int) << 2 as libc::c_int,
7150 &mut error,
7151 lib_ctx,
7152 );
7153 if library_name.is_null() {
7154 if error.is_null() {
7155 error = sdsnew(
7156 b"Failed creating the library\0" as *const u8
7157 as *const libc::c_char,
7158 );
7159 }
7160 current_block = 6387762410704612043;
7161 } else {
7162 sdsfree(library_name);
7163 current_block = 9520865839495247062;
7164 }
7165 } else {
7166 current_block = 9520865839495247062;
7167 }
7168 match current_block {
7169 6387762410704612043 => {}
7170 _ => {
7171 res = 0 as libc::c_int;
7172 }
7173 }
7174 }
7175 _ => {}
7176 }
7177 if !final_payload.is_null() {
7178 sdsfree(final_payload);
7179 }
7180 if !error.is_null() {
7181 if !err.is_null() {
7182 *err = error;
7183 } else {
7184 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
7185 _serverLog(
7186 3 as libc::c_int,
7187 b"Failed creating function, %s\0" as *const u8
7188 as *const libc::c_char,
7189 error,
7190 );
7191 }
7192 sdsfree(error);
7193 }
7194 }
7195 return res;
7196}
7197#[no_mangle]
7198pub unsafe extern "C" fn rdbLoadRio(
7199 mut rdb: *mut rio,
7200 mut rdbflags: libc::c_int,
7201 mut rsi: *mut rdbSaveInfo,
7202) -> libc::c_int {
7203 let mut functions_lib_ctx: *mut functionsLibCtx = functionsLibCtxGetCurrent();
7204 let mut loading_ctx: rdbLoadingCtx = {
7205 let mut init = rdbLoadingCtx {
7206 dbarray: server.db,
7207 functions_lib_ctx: functions_lib_ctx,
7208 };
7209 init
7210 };
7211 let mut retval: libc::c_int = rdbLoadRioWithLoadingCtx(
7212 rdb,
7213 rdbflags,
7214 rsi,
7215 &mut loading_ctx,
7216 );
7217 return retval;
7218}
7219#[no_mangle]
7220pub unsafe extern "C" fn rdbLoadRioWithLoadingCtx(
7221 mut rdb: *mut rio,
7222 mut rdbflags: libc::c_int,
7223 mut rsi: *mut rdbSaveInfo,
7224 mut rdb_loading_ctx: *mut rdbLoadingCtx,
7225) -> libc::c_int {
7226 let mut lru_idle: libc::c_longlong = 0;
7227 let mut lfu_freq: libc::c_longlong = 0;
7228 let mut expiretime: libc::c_longlong = 0;
7229 let mut now: libc::c_longlong = 0;
7230 let mut lru_clock: libc::c_longlong = 0;
7231 let mut current_block: u64;
7232 let mut dbid: uint64_t = 0 as libc::c_int as uint64_t;
7233 let mut type_0: libc::c_int = 0;
7234 let mut rdbver: libc::c_int = 0;
7235 let mut db: *mut redisDb = ((*rdb_loading_ctx).dbarray)
7236 .offset(0 as libc::c_int as isize);
7237 let mut buf: [libc::c_char; 1024] = [0; 1024];
7238 let mut error: libc::c_int = 0;
7239 let mut empty_keys_skipped: libc::c_longlong = 0 as libc::c_int as libc::c_longlong;
7240 (*rdb)
7241 .update_cksum = Some(
7242 rdbLoadProgressCallback
7243 as unsafe extern "C" fn(*mut rio, *const libc::c_void, size_t) -> (),
7244 );
7245 (*rdb).max_processing_chunk = server.loading_process_events_interval_bytes as size_t;
7246 if !(rioRead(rdb, buf.as_mut_ptr() as *mut libc::c_void, 9 as libc::c_int as size_t)
7247 == 0 as libc::c_int as libc::c_ulong)
7248 {
7249 buf[9 as libc::c_int as usize] = '\0' as i32 as libc::c_char;
7250 if memcmp(
7251 buf.as_mut_ptr() as *const libc::c_void,
7252 b"REDIS\0" as *const u8 as *const libc::c_char as *const libc::c_void,
7253 5 as libc::c_int as libc::c_ulong,
7254 ) != 0 as libc::c_int
7255 {
7256 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
7257 _serverLog(
7258 3 as libc::c_int,
7259 b"Wrong signature trying to load DB from file\0" as *const u8
7260 as *const libc::c_char,
7261 );
7262 }
7263 *__errno_location() = 22 as libc::c_int;
7264 return -(1 as libc::c_int);
7265 }
7266 rdbver = atoi(buf.as_mut_ptr().offset(5 as libc::c_int as isize));
7267 if rdbver < 1 as libc::c_int || rdbver > 10 as libc::c_int {
7268 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
7269 _serverLog(
7270 3 as libc::c_int,
7271 b"Can't handle RDB format version %d\0" as *const u8
7272 as *const libc::c_char,
7273 rdbver,
7274 );
7275 }
7276 *__errno_location() = 22 as libc::c_int;
7277 return -(1 as libc::c_int);
7278 }
7279 lru_idle = -(1 as libc::c_int) as libc::c_longlong;
7280 lfu_freq = -(1 as libc::c_int) as libc::c_longlong;
7281 expiretime = -(1 as libc::c_int) as libc::c_longlong;
7282 now = mstime();
7283 lru_clock = LRU_CLOCK() as libc::c_longlong;
7284 loop {
7285 let mut key: sds = 0 as *mut libc::c_char;
7286 let mut val: *mut robj = 0 as *mut robj;
7287 type_0 = rdbLoadType(rdb);
7288 if type_0 == -(1 as libc::c_int) {
7289 current_block = 17392992105600767133;
7290 break;
7291 }
7292 if type_0 == 253 as libc::c_int {
7293 expiretime = rdbLoadTime(rdb) as libc::c_longlong;
7294 expiretime *= 1000 as libc::c_int as libc::c_longlong;
7295 if rioGetReadError(rdb) != 0 {
7296 current_block = 17392992105600767133;
7297 break;
7298 }
7299 } else if type_0 == 252 as libc::c_int {
7300 expiretime = rdbLoadMillisecondTime(rdb, rdbver);
7301 if rioGetReadError(rdb) != 0 {
7302 current_block = 17392992105600767133;
7303 break;
7304 }
7305 } else if type_0 == 249 as libc::c_int {
7306 let mut byte: uint8_t = 0;
7307 if rioRead(
7308 rdb,
7309 &mut byte as *mut uint8_t as *mut libc::c_void,
7310 1 as libc::c_int as size_t,
7311 ) == 0 as libc::c_int as libc::c_ulong
7312 {
7313 current_block = 17392992105600767133;
7314 break;
7315 }
7316 lfu_freq = byte as libc::c_longlong;
7317 } else if type_0 == 248 as libc::c_int {
7318 let mut qword: uint64_t = 0;
7319 qword = rdbLoadLen(rdb, 0 as *mut libc::c_int);
7320 if qword == 18446744073709551615 as libc::c_ulong {
7321 current_block = 17392992105600767133;
7322 break;
7323 }
7324 lru_idle = qword as libc::c_longlong;
7325 } else if type_0 == 255 as libc::c_int {
7326 current_block = 162359820444412279;
7327 break;
7328 } else if type_0 == 254 as libc::c_int {
7329 dbid = rdbLoadLen(rdb, 0 as *mut libc::c_int);
7330 if dbid == 18446744073709551615 as libc::c_ulong {
7331 current_block = 17392992105600767133;
7332 break;
7333 }
7334 if dbid >= server.dbnum as libc::c_uint as libc::c_ulong {
7335 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
7336 _serverLog(
7337 3 as libc::c_int,
7338 b"FATAL: Data file was created with a Redis server configured to handle more than %d databases. Exiting\n\0"
7339 as *const u8 as *const libc::c_char,
7340 server.dbnum,
7341 );
7342 }
7343 exit(1 as libc::c_int);
7344 }
7345 db = ((*rdb_loading_ctx).dbarray).offset(dbid as isize);
7346 } else if type_0 == 251 as libc::c_int {
7347 let mut db_size: uint64_t = 0;
7348 let mut expires_size: uint64_t = 0;
7349 db_size = rdbLoadLen(rdb, 0 as *mut libc::c_int);
7350 if db_size == 18446744073709551615 as libc::c_ulong {
7351 current_block = 17392992105600767133;
7352 break;
7353 }
7354 expires_size = rdbLoadLen(rdb, 0 as *mut libc::c_int);
7355 if expires_size == 18446744073709551615 as libc::c_ulong {
7356 current_block = 17392992105600767133;
7357 break;
7358 }
7359 dictExpand((*db).dict, db_size);
7360 dictExpand((*db).expires, expires_size);
7361 } else if type_0 == 250 as libc::c_int {
7362 let mut auxkey: *mut robj = 0 as *mut robj;
7363 let mut auxval: *mut robj = 0 as *mut robj;
7364 auxkey = rdbLoadStringObject(rdb);
7365 if auxkey.is_null() {
7366 current_block = 17392992105600767133;
7367 break;
7368 }
7369 auxval = rdbLoadStringObject(rdb);
7370 if auxval.is_null() {
7371 decrRefCount(auxkey);
7372 current_block = 17392992105600767133;
7373 break;
7374 } else {
7375 if *((*auxkey).ptr as *mut libc::c_char)
7376 .offset(0 as libc::c_int as isize) as libc::c_int == '%' as i32
7377 {
7378 if !((2 as libc::c_int & 0xff as libc::c_int) < server.verbosity)
7379 {
7380 _serverLog(
7381 2 as libc::c_int,
7382 b"RDB '%s': %s\0" as *const u8 as *const libc::c_char,
7383 (*auxkey).ptr as *mut libc::c_char,
7384 (*auxval).ptr as *mut libc::c_char,
7385 );
7386 }
7387 } else if strcasecmp(
7388 (*auxkey).ptr as *const libc::c_char,
7389 b"repl-stream-db\0" as *const u8 as *const libc::c_char,
7390 ) == 0
7391 {
7392 if !rsi.is_null() {
7393 (*rsi)
7394 .repl_stream_db = atoi(
7395 (*auxval).ptr as *const libc::c_char,
7396 );
7397 }
7398 } else if strcasecmp(
7399 (*auxkey).ptr as *const libc::c_char,
7400 b"repl-id\0" as *const u8 as *const libc::c_char,
7401 ) == 0
7402 {
7403 if !rsi.is_null()
7404 && sdslen((*auxval).ptr as sds)
7405 == 40 as libc::c_int as libc::c_ulong
7406 {
7407 memcpy(
7408 ((*rsi).repl_id).as_mut_ptr() as *mut libc::c_void,
7409 (*auxval).ptr,
7410 (40 as libc::c_int + 1 as libc::c_int) as libc::c_ulong,
7411 );
7412 (*rsi).repl_id_is_set = 1 as libc::c_int;
7413 }
7414 } else if strcasecmp(
7415 (*auxkey).ptr as *const libc::c_char,
7416 b"repl-offset\0" as *const u8 as *const libc::c_char,
7417 ) == 0
7418 {
7419 if !rsi.is_null() {
7420 (*rsi)
7421 .repl_offset = strtoll(
7422 (*auxval).ptr as *const libc::c_char,
7423 0 as *mut *mut libc::c_char,
7424 10 as libc::c_int,
7425 );
7426 }
7427 } else if !(strcasecmp(
7428 (*auxkey).ptr as *const libc::c_char,
7429 b"lua\0" as *const u8 as *const libc::c_char,
7430 ) == 0)
7431 {
7432 if strcasecmp(
7433 (*auxkey).ptr as *const libc::c_char,
7434 b"redis-ver\0" as *const u8 as *const libc::c_char,
7435 ) == 0
7436 {
7437 if !((2 as libc::c_int & 0xff as libc::c_int)
7438 < server.verbosity)
7439 {
7440 _serverLog(
7441 2 as libc::c_int,
7442 b"Loading RDB produced by version %s\0" as *const u8
7443 as *const libc::c_char,
7444 (*auxval).ptr as *mut libc::c_char,
7445 );
7446 }
7447 } else if strcasecmp(
7448 (*auxkey).ptr as *const libc::c_char,
7449 b"ctime\0" as *const u8 as *const libc::c_char,
7450 ) == 0
7451 {
7452 let mut age: time_t = time(0 as *mut time_t)
7453 - strtol(
7454 (*auxval).ptr as *const libc::c_char,
7455 0 as *mut *mut libc::c_char,
7456 10 as libc::c_int,
7457 );
7458 if age < 0 as libc::c_int as libc::c_long {
7459 age = 0 as libc::c_int as time_t;
7460 }
7461 if !((2 as libc::c_int & 0xff as libc::c_int)
7462 < server.verbosity)
7463 {
7464 _serverLog(
7465 2 as libc::c_int,
7466 b"RDB age %ld seconds\0" as *const u8
7467 as *const libc::c_char,
7468 age as libc::c_ulong,
7469 );
7470 }
7471 } else if strcasecmp(
7472 (*auxkey).ptr as *const libc::c_char,
7473 b"used-mem\0" as *const u8 as *const libc::c_char,
7474 ) == 0
7475 {
7476 let mut usedmem: libc::c_longlong = strtoll(
7477 (*auxval).ptr as *const libc::c_char,
7478 0 as *mut *mut libc::c_char,
7479 10 as libc::c_int,
7480 );
7481 if !((2 as libc::c_int & 0xff as libc::c_int)
7482 < server.verbosity)
7483 {
7484 _serverLog(
7485 2 as libc::c_int,
7486 b"RDB memory usage when created %.2f Mb\0" as *const u8
7487 as *const libc::c_char,
7488 usedmem as libc::c_double
7489 / (1024 as libc::c_int * 1024 as libc::c_int)
7490 as libc::c_double,
7491 );
7492 }
7493 server.loading_rdb_used_mem = usedmem as off_t;
7494 } else if strcasecmp(
7495 (*auxkey).ptr as *const libc::c_char,
7496 b"aof-preamble\0" as *const u8 as *const libc::c_char,
7497 ) == 0
7498 {
7499 let mut haspreamble: libc::c_longlong = strtoll(
7500 (*auxval).ptr as *const libc::c_char,
7501 0 as *mut *mut libc::c_char,
7502 10 as libc::c_int,
7503 );
7504 if haspreamble != 0 {
7505 if !((2 as libc::c_int & 0xff as libc::c_int)
7506 < server.verbosity)
7507 {
7508 _serverLog(
7509 2 as libc::c_int,
7510 b"RDB has an AOF tail\0" as *const u8 as *const libc::c_char,
7511 );
7512 }
7513 }
7514 } else if strcasecmp(
7515 (*auxkey).ptr as *const libc::c_char,
7516 b"aof-base\0" as *const u8 as *const libc::c_char,
7517 ) == 0
7518 {
7519 let mut isbase: libc::c_longlong = strtoll(
7520 (*auxval).ptr as *const libc::c_char,
7521 0 as *mut *mut libc::c_char,
7522 10 as libc::c_int,
7523 );
7524 if isbase != 0 {
7525 if !((2 as libc::c_int & 0xff as libc::c_int)
7526 < server.verbosity)
7527 {
7528 _serverLog(
7529 2 as libc::c_int,
7530 b"RDB is base AOF\0" as *const u8 as *const libc::c_char,
7531 );
7532 }
7533 }
7534 } else if !(strcasecmp(
7535 (*auxkey).ptr as *const libc::c_char,
7536 b"redis-bits\0" as *const u8 as *const libc::c_char,
7537 ) == 0)
7538 {
7539 if !((0 as libc::c_int & 0xff as libc::c_int)
7540 < server.verbosity)
7541 {
7542 _serverLog(
7543 0 as libc::c_int,
7544 b"Unrecognized RDB AUX field: '%s'\0" as *const u8
7545 as *const libc::c_char,
7546 (*auxkey).ptr as *mut libc::c_char,
7547 );
7548 }
7549 }
7550 }
7551 decrRefCount(auxkey);
7552 decrRefCount(auxval);
7553 }
7554 } else if type_0 == 247 as libc::c_int {
7555 let mut moduleid: uint64_t = rdbLoadLen(rdb, 0 as *mut libc::c_int);
7556 let mut when_opcode: libc::c_int = rdbLoadLen(rdb, 0 as *mut libc::c_int)
7557 as libc::c_int;
7558 let mut when: libc::c_int = rdbLoadLen(rdb, 0 as *mut libc::c_int)
7559 as libc::c_int;
7560 if rioGetReadError(rdb) != 0 {
7561 current_block = 17392992105600767133;
7562 break;
7563 }
7564 if when_opcode != 2 as libc::c_int {
7565 rdbReportError(
7566 0 as libc::c_int,
7567 3057 as libc::c_int,
7568 b"bad when_opcode\0" as *const u8 as *const libc::c_char
7569 as *mut libc::c_char,
7570 );
7571 current_block = 17392992105600767133;
7572 break;
7573 } else {
7574 let mut mt: *mut moduleType = moduleTypeLookupModuleByID(moduleid);
7575 let mut name: [libc::c_char; 10] = [0; 10];
7576 moduleTypeNameByID(name.as_mut_ptr(), moduleid);
7577 if rdbCheckMode == 0 && mt.is_null() {
7578 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity)
7579 {
7580 _serverLog(
7581 3 as libc::c_int,
7582 b"The RDB file contains AUX module data I can't load: no matching module '%s'\0"
7583 as *const u8 as *const libc::c_char,
7584 name.as_mut_ptr(),
7585 );
7586 }
7587 exit(1 as libc::c_int);
7588 } else if rdbCheckMode == 0 && !mt.is_null() {
7589 if ((*mt).aux_load).is_none() {
7590 if !((3 as libc::c_int & 0xff as libc::c_int)
7591 < server.verbosity)
7592 {
7593 _serverLog(
7594 3 as libc::c_int,
7595 b"The RDB file contains module AUX data, but the module '%s' doesn't seem to support it.\0"
7596 as *const u8 as *const libc::c_char,
7597 name.as_mut_ptr(),
7598 );
7599 }
7600 exit(1 as libc::c_int);
7601 }
7602 let mut io: RedisModuleIO = RedisModuleIO {
7603 bytes: 0,
7604 rio: 0 as *mut rio,
7605 type_0: 0 as *mut moduleType,
7606 error: 0,
7607 ver: 0,
7608 ctx: 0 as *mut RedisModuleCtx,
7609 key: 0 as *mut redisObject,
7610 dbid: 0,
7611 };
7612 io.rio = rdb;
7613 io.type_0 = mt;
7614 io.bytes = 0 as libc::c_int as size_t;
7615 io.error = 0 as libc::c_int;
7616 io.ver = 0 as libc::c_int;
7617 io.key = 0 as *mut redisObject;
7618 io.dbid = -(1 as libc::c_int);
7619 io.ctx = 0 as *mut RedisModuleCtx;
7620 io.ver = 2 as libc::c_int;
7621 let mut rc: libc::c_int = ((*mt).aux_load)
7622 .expect(
7623 "non-null function pointer",
7624 )(
7625 &mut io,
7626 (moduleid & 1023 as libc::c_int as libc::c_ulong)
7627 as libc::c_int,
7628 when,
7629 );
7630 if !(io.ctx).is_null() {
7631 moduleFreeContext(io.ctx);
7632 zfree(io.ctx as *mut libc::c_void);
7633 }
7634 if rc != 0 as libc::c_int || io.error != 0 {
7635 moduleTypeNameByID(name.as_mut_ptr(), moduleid);
7636 if !((3 as libc::c_int & 0xff as libc::c_int)
7637 < server.verbosity)
7638 {
7639 _serverLog(
7640 3 as libc::c_int,
7641 b"The RDB file contains module AUX data for the module type '%s', that the responsible module is not able to load. Check for modules log above for additional clues.\0"
7642 as *const u8 as *const libc::c_char,
7643 name.as_mut_ptr(),
7644 );
7645 }
7646 current_block = 17392992105600767133;
7647 break;
7648 } else {
7649 let mut eof: uint64_t = rdbLoadLen(
7650 rdb,
7651 0 as *mut libc::c_int,
7652 );
7653 if !(eof != 0 as libc::c_int as libc::c_ulong) {
7654 continue;
7655 }
7656 if !((3 as libc::c_int & 0xff as libc::c_int)
7657 < server.verbosity)
7658 {
7659 _serverLog(
7660 3 as libc::c_int,
7661 b"The RDB file contains module AUX data for the module '%s' that is not terminated by the proper module value EOF marker\0"
7662 as *const u8 as *const libc::c_char,
7663 name.as_mut_ptr(),
7664 );
7665 }
7666 current_block = 17392992105600767133;
7667 break;
7668 }
7669 } else {
7670 let mut aux: *mut robj = rdbLoadCheckModuleValue(
7671 rdb,
7672 name.as_mut_ptr(),
7673 );
7674 decrRefCount(aux);
7675 }
7676 }
7677 } else if type_0 == 246 as libc::c_int || type_0 == 245 as libc::c_int {
7678 let mut err: sds = 0 as sds;
7679 if !(rdbFunctionLoad(
7680 rdb,
7681 rdbver,
7682 (*rdb_loading_ctx).functions_lib_ctx,
7683 type_0,
7684 rdbflags,
7685 &mut err,
7686 ) != 0 as libc::c_int)
7687 {
7688 continue;
7689 }
7690 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
7691 _serverLog(
7692 3 as libc::c_int,
7693 b"Failed loading library, %s\0" as *const u8
7694 as *const libc::c_char,
7695 err,
7696 );
7697 }
7698 sdsfree(err);
7699 current_block = 17392992105600767133;
7700 break;
7701 } else {
7702 key = rdbGenericLoadStringObject(
7703 rdb,
7704 (1 as libc::c_int) << 2 as libc::c_int,
7705 0 as *mut size_t,
7706 ) as sds;
7707 if key.is_null() {
7708 current_block = 17392992105600767133;
7709 break;
7710 }
7711 val = rdbLoadObject(type_0, rdb, key, (*db).id, &mut error);
7712 if val.is_null() {
7713 if error == 1 as libc::c_int {
7714 let fresh11 = empty_keys_skipped;
7715 empty_keys_skipped = empty_keys_skipped + 1;
7716 if fresh11 < 10 as libc::c_int as libc::c_longlong {
7717 if !((3 as libc::c_int & 0xff as libc::c_int)
7718 < server.verbosity)
7719 {
7720 _serverLog(
7721 3 as libc::c_int,
7722 b"rdbLoadObject skipping empty key: %s\0" as *const u8
7723 as *const libc::c_char,
7724 key,
7725 );
7726 }
7727 }
7728 sdsfree(key);
7729 } else {
7730 sdsfree(key);
7731 current_block = 17392992105600767133;
7732 break;
7733 }
7734 } else if iAmMaster() != 0
7735 && rdbflags & (1 as libc::c_int) << 0 as libc::c_int == 0
7736 && expiretime != -(1 as libc::c_int) as libc::c_longlong
7737 && expiretime < now
7738 {
7739 if rdbflags & (1 as libc::c_int) << 3 as libc::c_int != 0 {
7740 if !(server.repl_backlog).is_null()
7741 && (*server.slaves).len == 0 as libc::c_int as libc::c_ulong
7742 {} else {
7743 _serverAssert(
7744 b"server.repl_backlog != NULL && listLength(server.slaves) == 0\0"
7745 as *const u8 as *const libc::c_char,
7746 b"rdb.c\0" as *const u8 as *const libc::c_char,
7747 3147 as libc::c_int,
7748 );
7749 unreachable!();
7750 };
7751 let mut keyobj: robj = robj {
7752 type_0_encoding_lru: [0; 4],
7753 refcount: 0,
7754 ptr: 0 as *mut libc::c_void,
7755 };
7756 keyobj.refcount = 2147483647 as libc::c_int - 1 as libc::c_int;
7757 keyobj.set_type_0(0 as libc::c_int as libc::c_uint);
7758 keyobj.set_encoding(0 as libc::c_int as libc::c_uint);
7759 keyobj.ptr = key as *mut libc::c_void;
7760 let mut argv: [*mut robj; 2] = [0 as *mut robj; 2];
7761 argv[0 as libc::c_int
7762 as usize] = if server.lazyfree_lazy_expire != 0 {
7763 shared.unlink
7764 } else {
7765 shared.del
7766 };
7767 argv[1 as libc::c_int as usize] = &mut keyobj;
7768 replicationFeedSlaves(
7769 server.slaves,
7770 dbid as libc::c_int,
7771 argv.as_mut_ptr(),
7772 2 as libc::c_int,
7773 );
7774 }
7775 sdsfree(key);
7776 decrRefCount(val);
7777 server.rdb_last_load_keys_expired += 1;
7778 } else {
7779 let mut keyobj_0: robj = robj {
7780 type_0_encoding_lru: [0; 4],
7781 refcount: 0,
7782 ptr: 0 as *mut libc::c_void,
7783 };
7784 keyobj_0.refcount = 2147483647 as libc::c_int - 1 as libc::c_int;
7785 keyobj_0.set_type_0(0 as libc::c_int as libc::c_uint);
7786 keyobj_0.set_encoding(0 as libc::c_int as libc::c_uint);
7787 keyobj_0.ptr = key as *mut libc::c_void;
7788 let mut added: libc::c_int = dbAddRDBLoad(db, key, val);
7789 server.rdb_last_load_keys_loaded += 1;
7790 if added == 0 {
7791 if rdbflags & (1 as libc::c_int) << 2 as libc::c_int != 0 {
7792 dbSyncDelete(db, &mut keyobj_0);
7793 dbAddRDBLoad(db, key, val);
7794 } else {
7795 if !((3 as libc::c_int & 0xff as libc::c_int)
7796 < server.verbosity)
7797 {
7798 _serverLog(
7799 3 as libc::c_int,
7800 b"RDB has duplicated key '%s' in DB %d\0" as *const u8
7801 as *const libc::c_char,
7802 key,
7803 (*db).id,
7804 );
7805 }
7806 _serverPanic(
7807 b"rdb.c\0" as *const u8 as *const libc::c_char,
7808 3175 as libc::c_int,
7809 b"Duplicated key found in RDB file\0" as *const u8
7810 as *const libc::c_char,
7811 );
7812 unreachable!();
7813 }
7814 }
7815 if expiretime != -(1 as libc::c_int) as libc::c_longlong {
7816 setExpire(0 as *mut client, db, &mut keyobj_0, expiretime);
7817 }
7818 objectSetLRUOrLFU(
7819 val,
7820 lfu_freq,
7821 lru_idle,
7822 lru_clock,
7823 1000 as libc::c_int,
7824 );
7825 moduleNotifyKeyspaceEvent(
7826 (1 as libc::c_int) << 12 as libc::c_int,
7827 b"loaded\0" as *const u8 as *const libc::c_char,
7828 &mut keyobj_0,
7829 (*db).id,
7830 );
7831 }
7832 if server.key_load_delay != 0 {
7833 debugDelay(server.key_load_delay);
7834 }
7835 expiretime = -(1 as libc::c_int) as libc::c_longlong;
7836 lfu_freq = -(1 as libc::c_int) as libc::c_longlong;
7837 lru_idle = -(1 as libc::c_int) as libc::c_longlong;
7838 }
7839 }
7840 match current_block {
7841 17392992105600767133 => {}
7842 _ => {
7843 if rdbver >= 5 as libc::c_int {
7844 let mut cksum: uint64_t = 0;
7845 let mut expected: uint64_t = (*rdb).cksum;
7846 if rioRead(
7847 rdb,
7848 &mut cksum as *mut uint64_t as *mut libc::c_void,
7849 8 as libc::c_int as size_t,
7850 ) == 0 as libc::c_int as libc::c_ulong
7851 {
7852 current_block = 17392992105600767133;
7853 } else {
7854 if server.rdb_checksum != 0
7855 && server.skip_checksum_validation == 0
7856 {
7857 if cksum == 0 as libc::c_int as libc::c_ulong {
7858 if !((3 as libc::c_int & 0xff as libc::c_int)
7859 < server.verbosity)
7860 {
7861 _serverLog(
7862 3 as libc::c_int,
7863 b"RDB file was saved with checksum disabled: no check performed.\0"
7864 as *const u8 as *const libc::c_char,
7865 );
7866 }
7867 } else if cksum != expected {
7868 if !((3 as libc::c_int & 0xff as libc::c_int)
7869 < server.verbosity)
7870 {
7871 _serverLog(
7872 3 as libc::c_int,
7873 b"Wrong RDB checksum expected: (%llx) but got (%llx). Aborting now.\0"
7874 as *const u8 as *const libc::c_char,
7875 expected as libc::c_ulonglong,
7876 cksum as libc::c_ulonglong,
7877 );
7878 }
7879 rdbReportError(
7880 1 as libc::c_int,
7881 3216 as libc::c_int,
7882 b"RDB CRC error\0" as *const u8 as *const libc::c_char
7883 as *mut libc::c_char,
7884 );
7885 return -(1 as libc::c_int);
7886 }
7887 }
7888 current_block = 16286683003977321678;
7889 }
7890 } else {
7891 current_block = 16286683003977321678;
7892 }
7893 match current_block {
7894 17392992105600767133 => {}
7895 _ => {
7896 if empty_keys_skipped != 0 {
7897 if !((3 as libc::c_int & 0xff as libc::c_int)
7898 < server.verbosity)
7899 {
7900 _serverLog(
7901 3 as libc::c_int,
7902 b"Done loading RDB, keys loaded: %lld, keys expired: %lld, empty keys skipped: %lld.\0"
7903 as *const u8 as *const libc::c_char,
7904 server.rdb_last_load_keys_loaded,
7905 server.rdb_last_load_keys_expired,
7906 empty_keys_skipped,
7907 );
7908 }
7909 } else if !((2 as libc::c_int & 0xff as libc::c_int)
7910 < server.verbosity)
7911 {
7912 _serverLog(
7913 2 as libc::c_int,
7914 b"Done loading RDB, keys loaded: %lld, keys expired: %lld.\0"
7915 as *const u8 as *const libc::c_char,
7916 server.rdb_last_load_keys_loaded,
7917 server.rdb_last_load_keys_expired,
7918 );
7919 }
7920 return 0 as libc::c_int;
7921 }
7922 }
7923 }
7924 }
7925 }
7926 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
7927 _serverLog(
7928 3 as libc::c_int,
7929 b"Short read or OOM loading DB. Unrecoverable error, aborting now.\0"
7930 as *const u8 as *const libc::c_char,
7931 );
7932 }
7933 rdbReportError(
7934 0 as libc::c_int,
7935 3240 as libc::c_int,
7936 b"Unexpected EOF reading RDB file\0" as *const u8 as *const libc::c_char
7937 as *mut libc::c_char,
7938 );
7939 return -(1 as libc::c_int);
7940}
7941#[no_mangle]
7942pub unsafe extern "C" fn rdbLoad(
7943 mut filename: *mut libc::c_char,
7944 mut rsi: *mut rdbSaveInfo,
7945 mut rdbflags: libc::c_int,
7946) -> libc::c_int {
7947 let mut fp: *mut FILE = 0 as *mut FILE;
7948 let mut rdb: rio = rio {
7949 read: None,
7950 write: None,
7951 tell: None,
7952 flush: None,
7953 update_cksum: None,
7954 cksum: 0,
7955 flags: 0,
7956 processed_bytes: 0,
7957 max_processing_chunk: 0,
7958 io: C2RustUnnamed {
7959 buffer: C2RustUnnamed_3 {
7960 ptr: 0 as *mut libc::c_char,
7961 pos: 0,
7962 },
7963 },
7964 };
7965 let mut retval: libc::c_int = 0;
7966 let mut sb: stat = stat {
7967 st_dev: 0,
7968 st_ino: 0,
7969 st_mode: 0,
7970 st_nlink: 0,
7971 st_uid: 0,
7972 st_gid: 0,
7973 st_rdev: 0,
7974 __pad1: 0,
7975 st_size: 0,
7976 st_blksize: 0,
7977 __pad2: 0,
7978 st_blocks: 0,
7979 st_atim: timespec { tv_sec: 0, tv_nsec: 0 },
7980 st_mtim: timespec { tv_sec: 0, tv_nsec: 0 },
7981 st_ctim: timespec { tv_sec: 0, tv_nsec: 0 },
7982 __glibc_reserved: [0; 2],
7983 };
7984 fp = fopen(filename, b"r\0" as *const u8 as *const libc::c_char);
7985 if fp.is_null() {
7986 return -(1 as libc::c_int);
7987 }
7988 if fstat(fileno(fp), &mut sb) == -(1 as libc::c_int) {
7989 sb.st_size = 0 as libc::c_int as __off64_t;
7990 }
7991 startLoadingFile(sb.st_size as size_t, filename, rdbflags);
7992 rioInitWithFile(&mut rdb, fp);
7993 retval = rdbLoadRio(&mut rdb, rdbflags, rsi);
7994 fclose(fp);
7995 stopLoading((retval == 0 as libc::c_int) as libc::c_int);
7996 return retval;
7997}
7998unsafe extern "C" fn backgroundSaveDoneHandlerDisk(
7999 mut exitcode: libc::c_int,
8000 mut bysignal: libc::c_int,
8001) {
8002 if bysignal == 0 && exitcode == 0 as libc::c_int {
8003 if !((2 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
8004 _serverLog(
8005 2 as libc::c_int,
8006 b"Background saving terminated with success\0" as *const u8
8007 as *const libc::c_char,
8008 );
8009 }
8010 server.dirty = server.dirty - server.dirty_before_bgsave;
8011 server.lastsave = time(0 as *mut time_t);
8012 server.lastbgsave_status = 0 as libc::c_int;
8013 } else if bysignal == 0 && exitcode != 0 as libc::c_int {
8014 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
8015 _serverLog(
8016 3 as libc::c_int,
8017 b"Background saving error\0" as *const u8 as *const libc::c_char,
8018 );
8019 }
8020 server.lastbgsave_status = -(1 as libc::c_int);
8021 } else {
8022 let mut latency: mstime_t = 0;
8023 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
8024 _serverLog(
8025 3 as libc::c_int,
8026 b"Background saving terminated by signal %d\0" as *const u8
8027 as *const libc::c_char,
8028 bysignal,
8029 );
8030 }
8031 if server.latency_monitor_threshold != 0 {
8032 latency = mstime();
8033 } else {
8034 latency = 0 as libc::c_int as mstime_t;
8035 }
8036 rdbRemoveTempFile(server.child_pid, 0 as libc::c_int);
8037 if server.latency_monitor_threshold != 0 {
8038 latency = mstime() - latency;
8039 }
8040 if server.latency_monitor_threshold != 0
8041 && latency >= server.latency_monitor_threshold
8042 {
8043 latencyAddSample(
8044 b"rdb-unlink-temp-file\0" as *const u8 as *const libc::c_char,
8045 latency,
8046 );
8047 }
8048 if bysignal != 10 as libc::c_int {
8049 server.lastbgsave_status = -(1 as libc::c_int);
8050 }
8051 };
8052}
8053unsafe extern "C" fn backgroundSaveDoneHandlerSocket(
8054 mut exitcode: libc::c_int,
8055 mut bysignal: libc::c_int,
8056) {
8057 if bysignal == 0 && exitcode == 0 as libc::c_int {
8058 if !((2 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
8059 _serverLog(
8060 2 as libc::c_int,
8061 b"Background RDB transfer terminated with success\0" as *const u8
8062 as *const libc::c_char,
8063 );
8064 }
8065 } else if bysignal == 0 && exitcode != 0 as libc::c_int {
8066 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
8067 _serverLog(
8068 3 as libc::c_int,
8069 b"Background transfer error\0" as *const u8 as *const libc::c_char,
8070 );
8071 }
8072 } else if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
8073 _serverLog(
8074 3 as libc::c_int,
8075 b"Background transfer terminated by signal %d\0" as *const u8
8076 as *const libc::c_char,
8077 bysignal,
8078 );
8079 }
8080 if server.rdb_child_exit_pipe != -(1 as libc::c_int) {
8081 close(server.rdb_child_exit_pipe);
8082 }
8083 aeDeleteFileEvent(server.el, server.rdb_pipe_read, 1 as libc::c_int);
8084 close(server.rdb_pipe_read);
8085 server.rdb_child_exit_pipe = -(1 as libc::c_int);
8086 server.rdb_pipe_read = -(1 as libc::c_int);
8087 zfree(server.rdb_pipe_conns as *mut libc::c_void);
8088 server.rdb_pipe_conns = 0 as *mut *mut connection;
8089 server.rdb_pipe_numconns = 0 as libc::c_int;
8090 server.rdb_pipe_numconns_writing = 0 as libc::c_int;
8091 zfree(server.rdb_pipe_buff as *mut libc::c_void);
8092 server.rdb_pipe_buff = 0 as *mut libc::c_char;
8093 server.rdb_pipe_bufflen = 0 as libc::c_int;
8094}
8095#[no_mangle]
8096pub unsafe extern "C" fn backgroundSaveDoneHandler(
8097 mut exitcode: libc::c_int,
8098 mut bysignal: libc::c_int,
8099) {
8100 let mut type_0: libc::c_int = server.rdb_child_type;
8101 match server.rdb_child_type {
8102 1 => {
8103 backgroundSaveDoneHandlerDisk(exitcode, bysignal);
8104 }
8105 2 => {
8106 backgroundSaveDoneHandlerSocket(exitcode, bysignal);
8107 }
8108 _ => {
8109 _serverPanic(
8110 b"rdb.c\0" as *const u8 as *const libc::c_char,
8111 3339 as libc::c_int,
8112 b"Unknown RDB child type.\0" as *const u8 as *const libc::c_char,
8113 );
8114 unreachable!();
8115 }
8116 }
8117 server.rdb_child_type = 0 as libc::c_int;
8118 server.rdb_save_time_last = time(0 as *mut time_t) - server.rdb_save_time_start;
8119 server.rdb_save_time_start = -(1 as libc::c_int) as time_t;
8120 updateSlavesWaitingBgsave(
8121 if bysignal == 0 && exitcode == 0 as libc::c_int {
8122 0 as libc::c_int
8123 } else {
8124 -(1 as libc::c_int)
8125 },
8126 type_0,
8127 );
8128}
8129#[no_mangle]
8130pub unsafe extern "C" fn killRDBChild() {
8131 kill(server.child_pid, 10 as libc::c_int);
8132}
8133#[no_mangle]
8134pub unsafe extern "C" fn rdbSaveToSlavesSockets(
8135 mut req: libc::c_int,
8136 mut rsi: *mut rdbSaveInfo,
8137) -> libc::c_int {
8138 let mut ln: *mut listNode = 0 as *mut listNode;
8139 let mut li: listIter = listIter {
8140 next: 0 as *mut listNode,
8141 direction: 0,
8142 };
8143 let mut childpid: pid_t = 0;
8144 let mut pipefds: [libc::c_int; 2] = [0; 2];
8145 let mut rdb_pipe_write: libc::c_int = 0;
8146 let mut safe_to_exit_pipe: libc::c_int = 0;
8147 if hasActiveChildProcess() != 0 {
8148 return -(1 as libc::c_int);
8149 }
8150 if !(server.rdb_pipe_conns).is_null() {
8151 return -(1 as libc::c_int);
8152 }
8153 if anetPipe(pipefds.as_mut_ptr(), 0o4000 as libc::c_int, 0 as libc::c_int)
8154 == -(1 as libc::c_int)
8155 {
8156 return -(1 as libc::c_int);
8157 }
8158 server.rdb_pipe_read = pipefds[0 as libc::c_int as usize];
8159 rdb_pipe_write = pipefds[1 as libc::c_int as usize];
8160 if anetPipe(pipefds.as_mut_ptr(), 0 as libc::c_int, 0 as libc::c_int)
8161 == -(1 as libc::c_int)
8162 {
8163 close(rdb_pipe_write);
8164 close(server.rdb_pipe_read);
8165 return -(1 as libc::c_int);
8166 }
8167 safe_to_exit_pipe = pipefds[0 as libc::c_int as usize];
8168 server.rdb_child_exit_pipe = pipefds[1 as libc::c_int as usize];
8169 server
8170 .rdb_pipe_conns = zmalloc(
8171 (core::mem::size_of::<*mut connection>() as libc::c_ulong)
8172 .wrapping_mul((*server.slaves).len),
8173 ) as *mut *mut connection;
8174 server.rdb_pipe_numconns = 0 as libc::c_int;
8175 server.rdb_pipe_numconns_writing = 0 as libc::c_int;
8176 listRewind(server.slaves, &mut li);
8177 loop {
8178 ln = listNext(&mut li);
8179 if ln.is_null() {
8180 break;
8181 }
8182 let mut slave: *mut client = (*ln).value as *mut client;
8183 if !((*slave).replstate == 6 as libc::c_int) {
8184 continue;
8185 }
8186 if (*slave).slave_req != req {
8187 continue;
8188 }
8189 let fresh12 = server.rdb_pipe_numconns;
8190 server.rdb_pipe_numconns = server.rdb_pipe_numconns + 1;
8191 let ref mut fresh13 = *(server.rdb_pipe_conns).offset(fresh12 as isize);
8192 *fresh13 = (*slave).conn;
8193 replicationSetupSlaveForFullResync(slave, getPsyncInitialOffset());
8194 }
8195 childpid = redisFork(1 as libc::c_int);
8196 if childpid == 0 as libc::c_int {
8197 let mut retval: libc::c_int = 0;
8198 let mut dummy: libc::c_int = 0;
8199 let mut rdb: rio = rio {
8200 read: None,
8201 write: None,
8202 tell: None,
8203 flush: None,
8204 update_cksum: None,
8205 cksum: 0,
8206 flags: 0,
8207 processed_bytes: 0,
8208 max_processing_chunk: 0,
8209 io: C2RustUnnamed {
8210 buffer: C2RustUnnamed_3 {
8211 ptr: 0 as *mut libc::c_char,
8212 pos: 0,
8213 },
8214 },
8215 };
8216 rioInitWithFd(&mut rdb, rdb_pipe_write);
8217 close(server.rdb_pipe_read);
8218 redisSetProcTitle(
8219 b"redis-rdb-to-slaves\0" as *const u8 as *const libc::c_char
8220 as *mut libc::c_char,
8221 );
8222 redisSetCpuAffinity(server.bgsave_cpulist);
8223 retval = rdbSaveRioWithEOFMark(req, &mut rdb, 0 as *mut libc::c_int, rsi);
8224 if retval == 0 as libc::c_int && rioFlush(&mut rdb) == 0 as libc::c_int {
8225 retval = -(1 as libc::c_int);
8226 }
8227 if retval == 0 as libc::c_int {
8228 sendChildCowInfo(
8229 CHILD_INFO_TYPE_RDB_COW_SIZE,
8230 b"RDB\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
8231 );
8232 }
8233 rioFreeFd(&mut rdb);
8234 close(rdb_pipe_write);
8235 close(server.rdb_child_exit_pipe);
8236 dummy = read(
8237 safe_to_exit_pipe,
8238 pipefds.as_mut_ptr() as *mut libc::c_void,
8239 1 as libc::c_int as size_t,
8240 ) as libc::c_int;
8241 exitFromChild(
8242 if retval == 0 as libc::c_int { 0 as libc::c_int } else { 1 as libc::c_int },
8243 );
8244 } else {
8245 if childpid == -(1 as libc::c_int) {
8246 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
8247 _serverLog(
8248 3 as libc::c_int,
8249 b"Can't save in background: fork: %s\0" as *const u8
8250 as *const libc::c_char,
8251 strerror(*__errno_location()),
8252 );
8253 }
8254 listRewind(server.slaves, &mut li);
8255 loop {
8256 ln = listNext(&mut li);
8257 if ln.is_null() {
8258 break;
8259 }
8260 let mut slave_0: *mut client = (*ln).value as *mut client;
8261 if (*slave_0).replstate == 7 as libc::c_int {
8262 (*slave_0).replstate = 6 as libc::c_int;
8263 }
8264 }
8265 close(rdb_pipe_write);
8266 close(server.rdb_pipe_read);
8267 zfree(server.rdb_pipe_conns as *mut libc::c_void);
8268 server.rdb_pipe_conns = 0 as *mut *mut connection;
8269 server.rdb_pipe_numconns = 0 as libc::c_int;
8270 server.rdb_pipe_numconns_writing = 0 as libc::c_int;
8271 } else {
8272 if !((2 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
8273 _serverLog(
8274 2 as libc::c_int,
8275 b"Background RDB transfer started by pid %ld\0" as *const u8
8276 as *const libc::c_char,
8277 childpid as libc::c_long,
8278 );
8279 }
8280 server.rdb_save_time_start = time(0 as *mut time_t);
8281 server.rdb_child_type = 2 as libc::c_int;
8282 close(rdb_pipe_write);
8283 if aeCreateFileEvent(
8284 server.el,
8285 server.rdb_pipe_read,
8286 1 as libc::c_int,
8287 Some(
8288 rdbPipeReadHandler
8289 as unsafe extern "C" fn(
8290 *mut aeEventLoop,
8291 libc::c_int,
8292 *mut libc::c_void,
8293 libc::c_int,
8294 ) -> (),
8295 ),
8296 0 as *mut libc::c_void,
8297 ) == -(1 as libc::c_int)
8298 {
8299 _serverPanic(
8300 b"rdb.c\0" as *const u8 as *const libc::c_char,
8301 3474 as libc::c_int,
8302 b"Unrecoverable error creating server.rdb_pipe_read file event.\0"
8303 as *const u8 as *const libc::c_char,
8304 );
8305 unreachable!();
8306 }
8307 }
8308 close(safe_to_exit_pipe);
8309 return if childpid == -(1 as libc::c_int) {
8310 -(1 as libc::c_int)
8311 } else {
8312 0 as libc::c_int
8313 };
8314 }
8315 return 0 as libc::c_int;
8316}
8317#[no_mangle]
8318pub unsafe extern "C" fn saveCommand(mut c: *mut client) {
8319 if server.child_type == 1 as libc::c_int {
8320 addReplyError(
8321 c,
8322 b"Background save already in progress\0" as *const u8 as *const libc::c_char,
8323 );
8324 return;
8325 }
8326 server.stat_rdb_saves += 1;
8327 let mut rsi: rdbSaveInfo = rdbSaveInfo {
8328 repl_stream_db: 0,
8329 repl_id_is_set: 0,
8330 repl_id: [0; 41],
8331 repl_offset: 0,
8332 };
8333 let mut rsiptr: *mut rdbSaveInfo = 0 as *mut rdbSaveInfo;
8334 rsiptr = rdbPopulateSaveInfo(&mut rsi);
8335 if rdbSave(0 as libc::c_int, server.rdb_filename, rsiptr) == 0 as libc::c_int {
8336 addReply(c, shared.ok);
8337 } else {
8338 addReplyErrorObject(c, shared.err);
8339 };
8340}
8341#[no_mangle]
8342pub unsafe extern "C" fn bgsaveCommand(mut c: *mut client) {
8343 let mut schedule: libc::c_int = 0 as libc::c_int;
8344 if (*c).argc > 1 as libc::c_int {
8345 if (*c).argc == 2 as libc::c_int
8346 && strcasecmp(
8347 (**((*c).argv).offset(1 as libc::c_int as isize)).ptr
8348 as *const libc::c_char,
8349 b"schedule\0" as *const u8 as *const libc::c_char,
8350 ) == 0
8351 {
8352 schedule = 1 as libc::c_int;
8353 } else {
8354 addReplyErrorObject(c, shared.syntaxerr);
8355 return;
8356 }
8357 }
8358 let mut rsi: rdbSaveInfo = rdbSaveInfo {
8359 repl_stream_db: 0,
8360 repl_id_is_set: 0,
8361 repl_id: [0; 41],
8362 repl_offset: 0,
8363 };
8364 let mut rsiptr: *mut rdbSaveInfo = 0 as *mut rdbSaveInfo;
8365 rsiptr = rdbPopulateSaveInfo(&mut rsi);
8366 if server.child_type == 1 as libc::c_int {
8367 addReplyError(
8368 c,
8369 b"Background save already in progress\0" as *const u8 as *const libc::c_char,
8370 );
8371 } else if hasActiveChildProcess() != 0 || server.in_exec != 0 {
8372 if schedule != 0 || server.in_exec != 0 {
8373 server.rdb_bgsave_scheduled = 1 as libc::c_int;
8374 addReplyStatus(
8375 c,
8376 b"Background saving scheduled\0" as *const u8 as *const libc::c_char,
8377 );
8378 } else {
8379 addReplyError(
8380 c,
8381 b"Another child process is active (AOF?): can't BGSAVE right now. Use BGSAVE SCHEDULE in order to schedule a BGSAVE whenever possible.\0"
8382 as *const u8 as *const libc::c_char,
8383 );
8384 }
8385 } else if rdbSaveBackground(0 as libc::c_int, server.rdb_filename, rsiptr)
8386 == 0 as libc::c_int
8387 {
8388 addReplyStatus(
8389 c,
8390 b"Background saving started\0" as *const u8 as *const libc::c_char,
8391 );
8392 } else {
8393 addReplyErrorObject(c, shared.err);
8394 };
8395}
8396#[no_mangle]
8397pub unsafe extern "C" fn rdbPopulateSaveInfo(
8398 mut rsi: *mut rdbSaveInfo,
8399) -> *mut rdbSaveInfo {
8400 let mut rsi_init: rdbSaveInfo = {
8401 let mut init = rdbSaveInfo {
8402 repl_stream_db: -(1 as libc::c_int),
8403 repl_id_is_set: 0 as libc::c_int,
8404 repl_id: {
8405 let id_bytes: &[u8; 41] = b"00000000000000000000000000000000000000000";
8406 let id_chars: &mut [libc::c_char; 41] = unsafe {
8407 &mut *(&id_bytes as *const _ as *mut [libc::c_char; 41])
8408 };
8409 let id_cell = UnsafeCell::new(id_chars);
8410 unsafe { **id_cell.get() }
8411 },
8412 repl_offset: -(1 as libc::c_int) as libc::c_longlong,
8413 };
8414
8415 init
8416 };
8417 *rsi = rsi_init;
8418 if (server.masterhost).is_null() && !(server.repl_backlog).is_null() {
8419 (*rsi)
8420 .repl_stream_db = if server.slaveseldb == -(1 as libc::c_int) {
8421 0 as libc::c_int
8422 } else {
8423 server.slaveseldb
8424 };
8425 return rsi;
8426 }
8427 if !(server.master).is_null() {
8428 (*rsi).repl_stream_db = (*(*server.master).db).id;
8429 return rsi;
8430 }
8431 if !(server.cached_master).is_null() {
8432 (*rsi).repl_stream_db = (*(*server.cached_master).db).id;
8433 return rsi;
8434 }
8435 return 0 as *mut rdbSaveInfo;
8436}