1extern crate c2rust_bitfields;
2extern crate libc;
3extern crate core;
4use aof::core::cell::UnsafeCell;
5use std::convert::TryInto;
6extern "C" {
7 pub type _IO_wide_data;
8 pub type _IO_codecvt;
9 pub type _IO_marker;
10 pub type RedisModuleCtx;
11 pub type RedisModuleDefragCtx;
12 pub type RedisModuleInfoCtx;
13 pub type RedisModuleKeyOptCtx;
14 pub type RedisModuleCommand;
15 pub type clusterSlotToKeyMapping;
16 pub type clusterState;
17 fn zmalloc(size: size_t) -> *mut libc::c_void;
18 fn zcalloc(size: size_t) -> *mut libc::c_void;
19 fn open(__file: *const libc::c_char, __oflag: libc::c_int, _: ...) -> libc::c_int;
20 fn rename(__old: *const libc::c_char, __new: *const libc::c_char) -> libc::c_int;
21 fn fclose(__stream: *mut FILE) -> libc::c_int;
22 fn fflush(__stream: *mut FILE) -> libc::c_int;
23 fn fopen(_: *const libc::c_char, _: *const libc::c_char) -> *mut FILE;
24 fn snprintf(
25 _: *mut libc::c_char,
26 _: libc::c_ulong,
27 _: *const libc::c_char,
28 _: ...
29 ) -> libc::c_int;
30 fn fgets(
31 __s: *mut libc::c_char,
32 __n: libc::c_int,
33 __stream: *mut FILE,
34 ) -> *mut libc::c_char;
35 fn fread(
36 _: *mut libc::c_void,
37 _: libc::c_ulong,
38 _: libc::c_ulong,
39 _: *mut FILE,
40 ) -> libc::c_ulong;
41 fn fseek(
42 __stream: *mut FILE,
43 __off: libc::c_long,
44 __whence: libc::c_int,
45 ) -> libc::c_int;
46 fn ftello(__stream: *mut FILE) -> __off64_t;
47 fn feof(__stream: *mut FILE) -> libc::c_int;
48 fn fileno(__stream: *mut FILE) -> libc::c_int;
49 static mut SDS_NOINIT: *const libc::c_char;
50 fn sdsnewlen(init: *const libc::c_void, initlen: size_t) -> sds;
51 fn sdsnew(init: *const libc::c_char) -> sds;
52 fn sdsempty() -> sds;
53 fn sdsdup(s: sds) -> sds;
54 fn sdsfree(s: sds);
55 fn sdscatlen(s: sds, t: *const libc::c_void, len: size_t) -> sds;
56 fn sdscatsds(s: sds, t: sds) -> sds;
57 fn sdscatprintf(s: sds, fmt: *const libc::c_char, _: ...) -> sds;
58 fn sdscatfmt(s: sds, fmt: *const libc::c_char, _: ...) -> sds;
59 fn sdstrim(s: sds, cset: *const libc::c_char) -> sds;
60 fn sdsrange(s: sds, start: ssize_t, end: ssize_t);
61 fn sdsclear(s: sds);
62 fn sdsfreesplitres(tokens: *mut sds, count: libc::c_int);
63 fn sdscatrepr(s: sds, p: *const libc::c_char, len: size_t) -> sds;
64 fn sdssplitargs(line: *const libc::c_char, argc: *mut libc::c_int) -> *mut sds;
65 fn sdsneedsrepr(s: sds) -> libc::c_int;
66 fn __errno_location() -> *mut libc::c_int;
67 fn rioInitWithFile(r: *mut rio, fp: *mut FILE);
68 fn rioWriteBulkCount(
69 r: *mut rio,
70 prefix: libc::c_char,
71 count: libc::c_long,
72 ) -> size_t;
73 fn rioWriteBulkString(r: *mut rio, buf: *const libc::c_char, len: size_t) -> size_t;
74 fn rioWriteBulkLongLong(r: *mut rio, l: libc::c_longlong) -> size_t;
75 fn rioWriteBulkDouble(r: *mut rio, d: libc::c_double) -> size_t;
76 fn _serverPanic(
77 file: *const libc::c_char,
78 line: libc::c_int,
79 msg: *const libc::c_char,
80 _: ...
81 );
82 fn rioSetAutoSync(r: *mut rio, bytes: off_t);
83 fn time(__timer: *mut time_t) -> time_t;
84 fn strtol(
85 _: *const libc::c_char,
86 _: *mut *mut libc::c_char,
87 _: libc::c_int,
88 ) -> libc::c_long;
89 fn strtoll(
90 _: *const libc::c_char,
91 _: *mut *mut libc::c_char,
92 _: libc::c_int,
93 ) -> libc::c_longlong;
94 fn exit(_: libc::c_int) -> !;
95 fn memcmp(
96 _: *const libc::c_void,
97 _: *const libc::c_void,
98 _: libc::c_ulong,
99 ) -> libc::c_int;
100 fn strcmp(_: *const libc::c_char, _: *const libc::c_char) -> libc::c_int;
101 fn strchr(_: *const libc::c_char, _: libc::c_int) -> *mut libc::c_char;
102 fn strlen(_: *const libc::c_char) -> libc::c_ulong;
103 fn strerror(_: libc::c_int) -> *mut libc::c_char;
104 fn strcasecmp(__s1: *const libc::c_char, __s2: *const libc::c_char) -> libc::c_int;
105 fn lseek(__fd: libc::c_int, __offset: __off64_t, __whence: libc::c_int) -> __off64_t;
106 fn close(__fd: libc::c_int) -> libc::c_int;
107 fn write(__fd: libc::c_int, __buf: *const libc::c_void, __n: size_t) -> ssize_t;
108 fn usleep(__useconds: __useconds_t) -> libc::c_int;
109 fn getpid() -> __pid_t;
110 fn unlink(__name: *const libc::c_char) -> libc::c_int;
111 fn fsync(__fd: libc::c_int) -> libc::c_int;
112 fn truncate(__file: *const libc::c_char, __length: __off64_t) -> libc::c_int;
113 fn ftruncate(__fd: libc::c_int, __length: __off64_t) -> libc::c_int;
114 fn fdatasync(__fildes: libc::c_int) -> libc::c_int;
115 fn kill(__pid: __pid_t, __sig: libc::c_int) -> libc::c_int;
116 fn dictGetIterator(d: *mut dict) -> *mut dictIterator;
117 fn dictGetSafeIterator(d: *mut dict) -> *mut dictIterator;
118 fn dictNext(iter: *mut dictIterator) -> *mut dictEntry;
119 fn dictReleaseIterator(iter: *mut dictIterator);
120 fn listCreate() -> *mut list;
121 fn listRelease(list: *mut list);
122 fn listAddNodeHead(list: *mut list, value: *mut libc::c_void) -> *mut list;
123 fn listAddNodeTail(list: *mut list, value: *mut libc::c_void) -> *mut list;
124 fn listDelNode(list: *mut list, node: *mut listNode);
125 fn listNext(iter: *mut listIter) -> *mut listNode;
126 fn listDup(orig: *mut list) -> *mut list;
127 fn listIndex(list: *mut list, index: libc::c_long) -> *mut listNode;
128 fn listRewind(list: *mut list, li: *mut listIter);
129 fn listRewindTail(list: *mut list, li: *mut listIter);
130 fn zfree(ptr: *mut libc::c_void);
131 fn intsetGet(is: *mut intset, pos: uint32_t, value: *mut int64_t) -> uint8_t;
132 fn ll2string(
133 s: *mut libc::c_char,
134 len: size_t,
135 value: libc::c_longlong,
136 ) -> libc::c_int;
137 fn pathIsBaseName(path: *mut libc::c_char) -> libc::c_int;
138 fn dirCreateIfMissing(dname: *mut libc::c_char) -> libc::c_int;
139 fn dirExists(dname: *mut libc::c_char) -> libc::c_int;
140 fn fileExist(filename: *mut libc::c_char) -> libc::c_int;
141 fn makePath(path: *mut libc::c_char, filename: *mut libc::c_char) -> sds;
142 fn fsyncFileDir(filename: *const libc::c_char) -> libc::c_int;
143 fn latencyAddSample(event: *const libc::c_char, latency: mstime_t);
144 fn quicklistGetIterator(
145 quicklist: *mut quicklist,
146 direction: libc::c_int,
147 ) -> *mut quicklistIter;
148 fn quicklistNext(
149 iter: *mut quicklistIter,
150 entry: *mut quicklistEntry,
151 ) -> libc::c_int;
152 fn quicklistReleaseIterator(iter: *mut quicklistIter);
153 fn raxStart(it: *mut raxIterator, rt: *mut rax);
154 fn raxSeek(
155 it: *mut raxIterator,
156 op: *const libc::c_char,
157 ele: *mut libc::c_uchar,
158 len: size_t,
159 ) -> libc::c_int;
160 fn raxNext(it: *mut raxIterator) -> libc::c_int;
161 fn raxStop(it: *mut raxIterator);
162 fn raxSize(rax: *mut rax) -> uint64_t;
163 fn lpGetValue(
164 p: *mut libc::c_uchar,
165 slen: *mut libc::c_uint,
166 lval: *mut libc::c_longlong,
167 ) -> *mut libc::c_uchar;
168 fn lpNext(lp: *mut libc::c_uchar, p: *mut libc::c_uchar) -> *mut libc::c_uchar;
169 fn lpSeek(lp: *mut libc::c_uchar, index: libc::c_long) -> *mut libc::c_uchar;
170 fn streamIteratorStart(
171 si: *mut streamIterator,
172 s: *mut stream,
173 start: *mut streamID,
174 end: *mut streamID,
175 rev: libc::c_int,
176 );
177 fn streamIteratorGetID(
178 si: *mut streamIterator,
179 id: *mut streamID,
180 numfields: *mut int64_t,
181 ) -> libc::c_int;
182 fn streamIteratorGetField(
183 si: *mut streamIterator,
184 fieldptr: *mut *mut libc::c_uchar,
185 valueptr: *mut *mut libc::c_uchar,
186 fieldlen: *mut int64_t,
187 valuelen: *mut int64_t,
188 );
189 fn streamIteratorStop(si: *mut streamIterator);
190 fn streamDecodeID(buf: *mut libc::c_void, id: *mut streamID);
191 static mut server: redisServer;
192 fn moduleFreeContext(ctx: *mut RedisModuleCtx);
193 fn processModuleLoadingProgressEvent(is_aof: libc::c_int);
194 fn ustime() -> libc::c_longlong;
195 fn mstime() -> libc::c_longlong;
196 fn exitFromChild(retcode: libc::c_int);
197 fn redisSetProcTitle(title: *mut libc::c_char) -> libc::c_int;
198 fn redisSetCpuAffinity(cpulist: *const libc::c_char);
199 fn createClient(conn: *mut connection) -> *mut client;
200 fn freeClient(c: *mut client);
201 fn freeClientArgv(c: *mut client);
202 fn addReplyError(c: *mut client, err: *const libc::c_char);
203 fn addReplyStatus(c: *mut client, status: *const libc::c_char);
204 fn processEventsWhileBlocked();
205 fn listTypeLength(subject: *const robj) -> libc::c_ulong;
206 fn queueMultiCommand(c: *mut client, cmd_flags: uint64_t);
207 fn decrRefCount(o: *mut robj);
208 fn dismissObject(o: *mut robj, dump_size: size_t);
209 fn createObject(type_0: libc::c_int, ptr: *mut libc::c_void) -> *mut robj;
210 fn getDecodedObject(o: *mut robj) -> *mut robj;
211 fn startLoading(size: size_t, rdbflags: libc::c_int, async_0: libc::c_int);
212 fn loadingAbsProgress(pos: off_t);
213 fn loadingIncrProgress(size: off_t);
214 fn stopLoading(success: libc::c_int);
215 fn updateLoadingFileName(filename: *mut libc::c_char);
216 fn startSaving(rdbflags: libc::c_int);
217 fn stopSaving(success: libc::c_int);
218 fn rdbLoadRio(
219 rdb: *mut rio,
220 rdbflags: libc::c_int,
221 rsi: *mut rdbSaveInfo,
222 ) -> libc::c_int;
223 fn rdbSaveRio(
224 req: libc::c_int,
225 rdb: *mut rio,
226 error: *mut libc::c_int,
227 rdbflags: libc::c_int,
228 rsi: *mut rdbSaveInfo,
229 ) -> libc::c_int;
230 fn bg_unlink(filename: *const libc::c_char) -> libc::c_int;
231 fn _serverLog(level: libc::c_int, fmt: *const libc::c_char, _: ...);
232 fn hasActiveChildProcess() -> libc::c_int;
233 fn _serverAssert(
234 estr: *const libc::c_char,
235 file: *const libc::c_char,
236 line: libc::c_int,
237 );
238 fn sendChildCowInfo(info_type: childInfoType, pname: *mut libc::c_char);
239 fn debugDelay(usec: libc::c_int);
240 fn sendChildInfo(info_type: childInfoType, keys: size_t, pname: *mut libc::c_char);
241 fn hashTypeReleaseIterator(hi: *mut hashTypeIterator);
242 fn hashTypeLength(o: *const robj) -> libc::c_ulong;
243 fn hashTypeCurrentFromHashTable(hi: *mut hashTypeIterator, what: libc::c_int) -> sds;
244 fn hashTypeCurrentFromListpack(
245 hi: *mut hashTypeIterator,
246 what: libc::c_int,
247 vstr: *mut *mut libc::c_uchar,
248 vlen: *mut libc::c_uint,
249 vll: *mut libc::c_longlong,
250 );
251 fn hashTypeNext(hi: *mut hashTypeIterator) -> libc::c_int;
252 fn hashTypeInitIterator(subject: *mut robj) -> *mut hashTypeIterator;
253 fn zsetLength(zobj: *const robj) -> libc::c_ulong;
254 fn zzlNext(
255 zl: *mut libc::c_uchar,
256 eptr: *mut *mut libc::c_uchar,
257 sptr: *mut *mut libc::c_uchar,
258 );
259 fn zzlGetScore(sptr: *mut libc::c_uchar) -> libc::c_double;
260 fn setTypeSize(subject: *const robj) -> libc::c_ulong;
261 fn getExpire(db: *mut redisDb, key: *mut robj) -> libc::c_longlong;
262 fn redisFork(purpose: libc::c_int) -> libc::c_int;
263 fn execCommand(c: *mut client);
264 fn multiCommand(c: *mut client);
265 fn lookupCommand(argv: *mut *mut robj, argc: libc::c_int) -> *mut redisCommand;
266 fn resetChildState();
267 fn bioPendingJobsOfType(type_0: libc::c_int) -> libc::c_ulonglong;
268 fn bioCreateCloseJob(fd: libc::c_int, need_fsync: libc::c_int);
269 fn bioCreateFsyncJob(fd: libc::c_int);
270 fn functionsLibGet() -> *mut dict;
271 fn __fxstat(
272 __ver: libc::c_int,
273 __fildes: libc::c_int,
274 __stat_buf: *mut stat,
275 ) -> libc::c_int;
276 fn __xstat(
277 __ver: libc::c_int,
278 __filename: *const libc::c_char,
279 __stat_buf: *mut stat,
280 ) -> libc::c_int;
281 fn waitpid(
282 __pid: __pid_t,
283 __stat_loc: *mut libc::c_int,
284 __options: libc::c_int,
285 ) -> __pid_t;
286}
287pub type __int8_t = libc::c_schar;
288pub type __uint8_t = libc::c_uchar;
289pub type __int16_t = libc::c_short;
290pub type __uint16_t = libc::c_ushort;
291pub type __int32_t = libc::c_int;
292pub type __uint32_t = libc::c_uint;
293pub type __int64_t = libc::c_long;
294pub type __uint64_t = libc::c_ulong;
295pub type __uint_least64_t = __uint64_t;
296pub type __dev_t = libc::c_ulong;
297pub type __uid_t = libc::c_uint;
298pub type __gid_t = libc::c_uint;
299pub type __ino64_t = libc::c_ulong;
300pub type __mode_t = libc::c_uint;
301pub type __nlink_t = libc::c_uint;
302pub type __off_t = libc::c_long;
303pub type __off64_t = libc::c_long;
304pub type __pid_t = libc::c_int;
305pub type __time_t = libc::c_long;
306pub type __useconds_t = libc::c_uint;
307pub type __blksize_t = libc::c_int;
308pub type __blkcnt64_t = libc::c_long;
309pub type __ssize_t = libc::c_long;
310pub type __syscall_slong_t = libc::c_long;
311pub type __sig_atomic_t = libc::c_int;
312pub type size_t = libc::c_ulong;
313#[derive(Copy, Clone)]
314#[repr(C)]
315pub struct iovec {
316 pub iov_base: *mut libc::c_void,
317 pub iov_len: size_t,
318}
319pub type mode_t = __mode_t;
320pub type off_t = __off64_t;
321pub type pid_t = __pid_t;
322#[derive(Copy, Clone)]
323#[repr(C)]
324pub struct timespec {
325 pub tv_sec: __time_t,
326 pub tv_nsec: __syscall_slong_t,
327}
328#[derive(Copy, Clone)]
329#[repr(C)]
330pub struct stat {
331 pub st_dev: __dev_t,
332 pub st_ino: __ino64_t,
333 pub st_mode: __mode_t,
334 pub st_nlink: __nlink_t,
335 pub st_uid: __uid_t,
336 pub st_gid: __gid_t,
337 pub st_rdev: __dev_t,
338 pub __pad1: __dev_t,
339 pub st_size: __off64_t,
340 pub st_blksize: __blksize_t,
341 pub __pad2: libc::c_int,
342 pub st_blocks: __blkcnt64_t,
343 pub st_atim: timespec,
344 pub st_mtim: timespec,
345 pub st_ctim: timespec,
346 pub __glibc_reserved: [libc::c_int; 2],
347}
348pub type ssize_t = __ssize_t;
349pub type time_t = __time_t;
350pub type int8_t = __int8_t;
351pub type int16_t = __int16_t;
352pub type int32_t = __int32_t;
353pub type int64_t = __int64_t;
354pub type pthread_t = libc::c_ulong;
355#[derive(Copy, Clone)]
356#[repr(C)]
357pub struct _IO_FILE {
358 pub _flags: libc::c_int,
359 pub _IO_read_ptr: *mut libc::c_char,
360 pub _IO_read_end: *mut libc::c_char,
361 pub _IO_read_base: *mut libc::c_char,
362 pub _IO_write_base: *mut libc::c_char,
363 pub _IO_write_ptr: *mut libc::c_char,
364 pub _IO_write_end: *mut libc::c_char,
365 pub _IO_buf_base: *mut libc::c_char,
366 pub _IO_buf_end: *mut libc::c_char,
367 pub _IO_save_base: *mut libc::c_char,
368 pub _IO_backup_base: *mut libc::c_char,
369 pub _IO_save_end: *mut libc::c_char,
370 pub _markers: *mut _IO_marker,
371 pub _chain: *mut _IO_FILE,
372 pub _fileno: libc::c_int,
373 pub _flags2: libc::c_int,
374 pub _old_offset: __off_t,
375 pub _cur_column: libc::c_ushort,
376 pub _vtable_offset: libc::c_schar,
377 pub _shortbuf: [libc::c_char; 1],
378 pub _lock: *mut libc::c_void,
379 pub _offset: __off64_t,
380 pub _codecvt: *mut _IO_codecvt,
381 pub _wide_data: *mut _IO_wide_data,
382 pub _freeres_list: *mut _IO_FILE,
383 pub _freeres_buf: *mut libc::c_void,
384 pub __pad5: size_t,
385 pub _mode: libc::c_int,
386 pub _unused2: [libc::c_char; 20],
387}
388pub type _IO_lock_t = ();
389pub type FILE = _IO_FILE;
390pub type uint8_t = __uint8_t;
391pub type uint16_t = __uint16_t;
392pub type uint32_t = __uint32_t;
393pub type uint64_t = __uint64_t;
394pub type uint_least64_t = __uint_least64_t;
395pub type sds = *mut libc::c_char;
396#[derive(Copy, Clone)]
397#[repr(C, packed)]
398pub struct sdshdr8 {
399 pub len: uint8_t,
400 pub alloc: uint8_t,
401 pub flags: libc::c_uchar,
402 pub buf: [libc::c_char; 0],
403}
404#[derive(Copy, Clone)]
405#[repr(C, packed)]
406pub struct sdshdr16 {
407 pub len: uint16_t,
408 pub alloc: uint16_t,
409 pub flags: libc::c_uchar,
410 pub buf: [libc::c_char; 0],
411}
412#[derive(Copy, Clone)]
413#[repr(C, packed)]
414pub struct sdshdr32 {
415 pub len: uint32_t,
416 pub alloc: uint32_t,
417 pub flags: libc::c_uchar,
418 pub buf: [libc::c_char; 0],
419}
420#[derive(Copy, Clone)]
421#[repr(C, packed)]
422pub struct sdshdr64 {
423 pub len: uint64_t,
424 pub alloc: uint64_t,
425 pub flags: libc::c_uchar,
426 pub buf: [libc::c_char; 0],
427}
428#[derive(Copy, Clone)]
429#[repr(C)]
430pub struct aeEventLoop {
431 pub maxfd: libc::c_int,
432 pub setsize: libc::c_int,
433 pub timeEventNextId: libc::c_longlong,
434 pub events: *mut aeFileEvent,
435 pub fired: *mut aeFiredEvent,
436 pub timeEventHead: *mut aeTimeEvent,
437 pub stop: libc::c_int,
438 pub apidata: *mut libc::c_void,
439 pub beforesleep: Option::<aeBeforeSleepProc>,
440 pub aftersleep: Option::<aeBeforeSleepProc>,
441 pub flags: libc::c_int,
442}
443pub type aeBeforeSleepProc = unsafe extern "C" fn(*mut aeEventLoop) -> ();
444#[derive(Copy, Clone)]
445#[repr(C)]
446pub struct aeTimeEvent {
447 pub id: libc::c_longlong,
448 pub when: monotime,
449 pub timeProc: Option::<aeTimeProc>,
450 pub finalizerProc: Option::<aeEventFinalizerProc>,
451 pub clientData: *mut libc::c_void,
452 pub prev: *mut aeTimeEvent,
453 pub next: *mut aeTimeEvent,
454 pub refcount: libc::c_int,
455}
456pub type aeEventFinalizerProc = unsafe extern "C" fn(
457 *mut aeEventLoop,
458 *mut libc::c_void,
459) -> ();
460pub type aeTimeProc = unsafe extern "C" fn(
461 *mut aeEventLoop,
462 libc::c_longlong,
463 *mut libc::c_void,
464) -> libc::c_int;
465pub type monotime = uint64_t;
466#[derive(Copy, Clone)]
467#[repr(C)]
468pub struct aeFiredEvent {
469 pub fd: libc::c_int,
470 pub mask: libc::c_int,
471}
472#[derive(Copy, Clone)]
473#[repr(C)]
474pub struct aeFileEvent {
475 pub mask: libc::c_int,
476 pub rfileProc: Option::<aeFileProc>,
477 pub wfileProc: Option::<aeFileProc>,
478 pub clientData: *mut libc::c_void,
479}
480pub type aeFileProc = unsafe extern "C" fn(
481 *mut aeEventLoop,
482 libc::c_int,
483 *mut libc::c_void,
484 libc::c_int,
485) -> ();
486#[derive(Copy, Clone)]
487#[repr(C)]
488pub struct connection {
489 pub type_0: *mut ConnectionType,
490 pub state: ConnectionState,
491 pub flags: libc::c_short,
492 pub refs: libc::c_short,
493 pub last_errno: libc::c_int,
494 pub private_data: *mut libc::c_void,
495 pub conn_handler: ConnectionCallbackFunc,
496 pub write_handler: ConnectionCallbackFunc,
497 pub read_handler: ConnectionCallbackFunc,
498 pub fd: libc::c_int,
499}
500pub type ConnectionCallbackFunc = Option::<unsafe extern "C" fn(*mut connection) -> ()>;
501pub type ConnectionState = libc::c_uint;
502pub const CONN_STATE_ERROR: ConnectionState = 5;
503pub const CONN_STATE_CLOSED: ConnectionState = 4;
504pub const CONN_STATE_CONNECTED: ConnectionState = 3;
505pub const CONN_STATE_ACCEPTING: ConnectionState = 2;
506pub const CONN_STATE_CONNECTING: ConnectionState = 1;
507pub const CONN_STATE_NONE: ConnectionState = 0;
508#[derive(Copy, Clone)]
509#[repr(C)]
510pub struct ConnectionType {
511 pub ae_handler: Option::<
512 unsafe extern "C" fn(
513 *mut aeEventLoop,
514 libc::c_int,
515 *mut libc::c_void,
516 libc::c_int,
517 ) -> (),
518 >,
519 pub connect: Option::<
520 unsafe extern "C" fn(
521 *mut connection,
522 *const libc::c_char,
523 libc::c_int,
524 *const libc::c_char,
525 ConnectionCallbackFunc,
526 ) -> libc::c_int,
527 >,
528 pub write: Option::<
529 unsafe extern "C" fn(*mut connection, *const libc::c_void, size_t) -> libc::c_int,
530 >,
531 pub writev: Option::<
532 unsafe extern "C" fn(*mut connection, *const iovec, libc::c_int) -> libc::c_int,
533 >,
534 pub read: Option::<
535 unsafe extern "C" fn(*mut connection, *mut libc::c_void, size_t) -> libc::c_int,
536 >,
537 pub close: Option::<unsafe extern "C" fn(*mut connection) -> ()>,
538 pub accept: Option::<
539 unsafe extern "C" fn(*mut connection, ConnectionCallbackFunc) -> libc::c_int,
540 >,
541 pub set_write_handler: Option::<
542 unsafe extern "C" fn(
543 *mut connection,
544 ConnectionCallbackFunc,
545 libc::c_int,
546 ) -> libc::c_int,
547 >,
548 pub set_read_handler: Option::<
549 unsafe extern "C" fn(*mut connection, ConnectionCallbackFunc) -> libc::c_int,
550 >,
551 pub get_last_error: Option::<
552 unsafe extern "C" fn(*mut connection) -> *const libc::c_char,
553 >,
554 pub blocking_connect: Option::<
555 unsafe extern "C" fn(
556 *mut connection,
557 *const libc::c_char,
558 libc::c_int,
559 libc::c_longlong,
560 ) -> libc::c_int,
561 >,
562 pub sync_write: Option::<
563 unsafe extern "C" fn(
564 *mut connection,
565 *mut libc::c_char,
566 ssize_t,
567 libc::c_longlong,
568 ) -> ssize_t,
569 >,
570 pub sync_read: Option::<
571 unsafe extern "C" fn(
572 *mut connection,
573 *mut libc::c_char,
574 ssize_t,
575 libc::c_longlong,
576 ) -> ssize_t,
577 >,
578 pub sync_readline: Option::<
579 unsafe extern "C" fn(
580 *mut connection,
581 *mut libc::c_char,
582 ssize_t,
583 libc::c_longlong,
584 ) -> ssize_t,
585 >,
586 pub get_type: Option::<unsafe extern "C" fn(*mut connection) -> libc::c_int>,
587}
588#[derive(Copy, Clone)]
589#[repr(C)]
590pub struct _rio {
591 pub read: Option::<
592 unsafe extern "C" fn(*mut _rio, *mut libc::c_void, size_t) -> size_t,
593 >,
594 pub write: Option::<
595 unsafe extern "C" fn(*mut _rio, *const libc::c_void, size_t) -> size_t,
596 >,
597 pub tell: Option::<unsafe extern "C" fn(*mut _rio) -> off_t>,
598 pub flush: Option::<unsafe extern "C" fn(*mut _rio) -> libc::c_int>,
599 pub update_cksum: Option::<
600 unsafe extern "C" fn(*mut _rio, *const libc::c_void, size_t) -> (),
601 >,
602 pub cksum: uint64_t,
603 pub flags: uint64_t,
604 pub processed_bytes: size_t,
605 pub max_processing_chunk: size_t,
606 pub io: C2RustUnnamed,
607}
608#[derive(Copy, Clone)]
609#[repr(C)]
610pub union C2RustUnnamed {
611 pub buffer: C2RustUnnamed_3,
612 pub file: C2RustUnnamed_2,
613 pub conn: C2RustUnnamed_1,
614 pub fd: C2RustUnnamed_0,
615}
616#[derive(Copy, Clone)]
617#[repr(C)]
618pub struct C2RustUnnamed_0 {
619 pub fd: libc::c_int,
620 pub pos: off_t,
621 pub buf: sds,
622}
623#[derive(Copy, Clone)]
624#[repr(C)]
625pub struct C2RustUnnamed_1 {
626 pub conn: *mut connection,
627 pub pos: off_t,
628 pub buf: sds,
629 pub read_limit: size_t,
630 pub read_so_far: size_t,
631}
632#[derive(Copy, Clone)]
633#[repr(C)]
634pub struct C2RustUnnamed_2 {
635 pub fp: *mut FILE,
636 pub buffered: off_t,
637 pub autosync: off_t,
638}
639#[derive(Copy, Clone)]
640#[repr(C)]
641pub struct C2RustUnnamed_3 {
642 pub ptr: sds,
643 pub pos: off_t,
644}
645pub type rio = _rio;
646#[derive(Copy, Clone, c2rust_bitfields::BitfieldStruct)]
647#[repr(C)]
648pub struct redisObject {
649 #[bitfield(name = "type_0", ty = "libc::c_uint", bits = "0..=3")]
650 #[bitfield(name = "encoding", ty = "libc::c_uint", bits = "4..=7")]
651 #[bitfield(name = "lru", ty = "libc::c_uint", bits = "8..=31")]
652 pub type_0_encoding_lru: [u8; 4],
653 pub refcount: libc::c_int,
654 pub ptr: *mut libc::c_void,
655}
656pub type robj = redisObject;
657pub type memory_order = libc::c_uint;
658pub const memory_order_seq_cst: memory_order = 5;
659pub const memory_order_acq_rel: memory_order = 4;
660pub const memory_order_release: memory_order = 3;
661pub const memory_order_acquire: memory_order = 2;
662pub const memory_order_consume: memory_order = 1;
663pub const memory_order_relaxed: memory_order = 0;
664pub type atomic_int = libc::c_int;
665pub type atomic_uint = libc::c_uint;
666pub type atomic_llong = libc::c_longlong;
667pub type sig_atomic_t = __sig_atomic_t;
668#[derive(Copy, Clone)]
669#[repr(C)]
670pub struct hdr_histogram {
671 pub lowest_discernible_value: int64_t,
672 pub highest_trackable_value: int64_t,
673 pub unit_magnitude: int32_t,
674 pub significant_figures: int32_t,
675 pub sub_bucket_half_count_magnitude: int32_t,
676 pub sub_bucket_half_count: int32_t,
677 pub sub_bucket_mask: int64_t,
678 pub sub_bucket_count: int32_t,
679 pub bucket_count: int32_t,
680 pub min_value: int64_t,
681 pub max_value: int64_t,
682 pub normalizing_index_offset: int32_t,
683 pub conversion_ratio: libc::c_double,
684 pub counts_len: int32_t,
685 pub total_count: int64_t,
686 pub counts: *mut int64_t,
687}
688pub type mstime_t = libc::c_longlong;
689pub type ustime_t = libc::c_longlong;
690#[derive(Copy, Clone)]
691#[repr(C)]
692pub struct dictEntry {
693 pub key: *mut libc::c_void,
694 pub v: C2RustUnnamed_4,
695 pub next: *mut dictEntry,
696 pub metadata: [*mut libc::c_void; 0],
697}
698#[derive(Copy, Clone)]
699#[repr(C)]
700pub union C2RustUnnamed_4 {
701 pub val: *mut libc::c_void,
702 pub u64_0: uint64_t,
703 pub s64: int64_t,
704 pub d: libc::c_double,
705}
706#[derive(Copy, Clone)]
707#[repr(C)]
708pub struct dict {
709 pub type_0: *mut dictType,
710 pub ht_table: [*mut *mut dictEntry; 2],
711 pub ht_used: [libc::c_ulong; 2],
712 pub rehashidx: libc::c_long,
713 pub pauserehash: int16_t,
714 pub ht_size_exp: [libc::c_schar; 2],
715}
716#[derive(Copy, Clone)]
717#[repr(C)]
718pub struct dictType {
719 pub hashFunction: Option::<unsafe extern "C" fn(*const libc::c_void) -> uint64_t>,
720 pub keyDup: Option::<
721 unsafe extern "C" fn(*mut dict, *const libc::c_void) -> *mut libc::c_void,
722 >,
723 pub valDup: Option::<
724 unsafe extern "C" fn(*mut dict, *const libc::c_void) -> *mut libc::c_void,
725 >,
726 pub keyCompare: Option::<
727 unsafe extern "C" fn(
728 *mut dict,
729 *const libc::c_void,
730 *const libc::c_void,
731 ) -> libc::c_int,
732 >,
733 pub keyDestructor: Option::<
734 unsafe extern "C" fn(*mut dict, *mut libc::c_void) -> (),
735 >,
736 pub valDestructor: Option::<
737 unsafe extern "C" fn(*mut dict, *mut libc::c_void) -> (),
738 >,
739 pub expandAllowed: Option::<
740 unsafe extern "C" fn(size_t, libc::c_double) -> libc::c_int,
741 >,
742 pub dictEntryMetadataBytes: Option::<unsafe extern "C" fn(*mut dict) -> size_t>,
743}
744#[derive(Copy, Clone)]
745#[repr(C)]
746pub struct dictIterator {
747 pub d: *mut dict,
748 pub index: libc::c_long,
749 pub table: libc::c_int,
750 pub safe: libc::c_int,
751 pub entry: *mut dictEntry,
752 pub nextEntry: *mut dictEntry,
753 pub fingerprint: libc::c_ulonglong,
754}
755#[derive(Copy, Clone)]
756#[repr(C)]
757pub struct listNode {
758 pub prev: *mut listNode,
759 pub next: *mut listNode,
760 pub value: *mut libc::c_void,
761}
762#[derive(Copy, Clone)]
763#[repr(C)]
764pub struct listIter {
765 pub next: *mut listNode,
766 pub direction: libc::c_int,
767}
768#[derive(Copy, Clone)]
769#[repr(C)]
770pub struct list {
771 pub head: *mut listNode,
772 pub tail: *mut listNode,
773 pub dup: Option::<unsafe extern "C" fn(*mut libc::c_void) -> *mut libc::c_void>,
774 pub free: Option::<unsafe extern "C" fn(*mut libc::c_void) -> ()>,
775 pub match_0: Option::<
776 unsafe extern "C" fn(*mut libc::c_void, *mut libc::c_void) -> libc::c_int,
777 >,
778 pub len: libc::c_ulong,
779}
780#[derive(Copy, Clone)]
781#[repr(C)]
782pub struct intset {
783 pub encoding: uint32_t,
784 pub length: uint32_t,
785 pub contents: [int8_t; 0],
786}
787#[derive(Copy, Clone, c2rust_bitfields::BitfieldStruct)]
788#[repr(C)]
789pub struct quicklistNode {
790 pub prev: *mut quicklistNode,
791 pub next: *mut quicklistNode,
792 pub entry: *mut libc::c_uchar,
793 pub sz: size_t,
794 #[bitfield(name = "count", ty = "libc::c_uint", bits = "0..=15")]
795 #[bitfield(name = "encoding", ty = "libc::c_uint", bits = "16..=17")]
796 #[bitfield(name = "container", ty = "libc::c_uint", bits = "18..=19")]
797 #[bitfield(name = "recompress", ty = "libc::c_uint", bits = "20..=20")]
798 #[bitfield(name = "attempted_compress", ty = "libc::c_uint", bits = "21..=21")]
799 #[bitfield(name = "dont_compress", ty = "libc::c_uint", bits = "22..=22")]
800 #[bitfield(name = "extra", ty = "libc::c_uint", bits = "23..=31")]
801 pub count_encoding_container_recompress_attempted_compress_dont_compress_extra: [u8; 4],
802 #[bitfield(padding)]
803 pub c2rust_padding: [u8; 4],
804}
805#[derive(Copy, Clone)]
806#[repr(C)]
807pub struct quicklistBookmark {
808 pub node: *mut quicklistNode,
809 pub name: *mut libc::c_char,
810}
811#[derive(Copy, Clone, c2rust_bitfields::BitfieldStruct)]
812#[repr(C)]
813pub struct quicklist {
814 pub head: *mut quicklistNode,
815 pub tail: *mut quicklistNode,
816 pub count: libc::c_ulong,
817 pub len: libc::c_ulong,
818 #[bitfield(name = "fill", ty = "libc::c_int", bits = "0..=15")]
819 #[bitfield(name = "compress", ty = "libc::c_uint", bits = "16..=31")]
820 #[bitfield(name = "bookmark_count", ty = "libc::c_uint", bits = "32..=35")]
821 pub fill_compress_bookmark_count: [u8; 5],
822 #[bitfield(padding)]
823 pub c2rust_padding: [u8; 3],
824 pub bookmarks: [quicklistBookmark; 0],
825}
826#[derive(Copy, Clone)]
827#[repr(C)]
828pub struct quicklistIter {
829 pub quicklist: *mut quicklist,
830 pub current: *mut quicklistNode,
831 pub zi: *mut libc::c_uchar,
832 pub offset: libc::c_long,
833 pub direction: libc::c_int,
834}
835#[derive(Copy, Clone)]
836#[repr(C)]
837pub struct quicklistEntry {
838 pub quicklist: *const quicklist,
839 pub node: *mut quicklistNode,
840 pub zi: *mut libc::c_uchar,
841 pub value: *mut libc::c_uchar,
842 pub longval: libc::c_longlong,
843 pub sz: size_t,
844 pub offset: libc::c_int,
845}
846#[derive(Copy, Clone, c2rust_bitfields::BitfieldStruct)]
847#[repr(C)]
848pub struct raxNode {
849 #[bitfield(name = "iskey", ty = "uint32_t", bits = "0..=0")]
850 #[bitfield(name = "isnull", ty = "uint32_t", bits = "1..=1")]
851 #[bitfield(name = "iscompr", ty = "uint32_t", bits = "2..=2")]
852 #[bitfield(name = "size", ty = "uint32_t", bits = "3..=31")]
853 pub iskey_isnull_iscompr_size: [u8; 4],
854 pub data: [libc::c_uchar; 0],
855}
856#[derive(Copy, Clone)]
857#[repr(C)]
858pub struct rax {
859 pub head: *mut raxNode,
860 pub numele: uint64_t,
861 pub numnodes: uint64_t,
862}
863#[derive(Copy, Clone)]
864#[repr(C)]
865pub struct raxStack {
866 pub stack: *mut *mut libc::c_void,
867 pub items: size_t,
868 pub maxitems: size_t,
869 pub static_items: [*mut libc::c_void; 32],
870 pub oom: libc::c_int,
871}
872pub type raxNodeCallback = Option::<
873 unsafe extern "C" fn(*mut *mut raxNode) -> libc::c_int,
874>;
875#[derive(Copy, Clone)]
876#[repr(C)]
877pub struct raxIterator {
878 pub flags: libc::c_int,
879 pub rt: *mut rax,
880 pub key: *mut libc::c_uchar,
881 pub data: *mut libc::c_void,
882 pub key_len: size_t,
883 pub key_max: size_t,
884 pub key_static_string: [libc::c_uchar; 128],
885 pub node: *mut raxNode,
886 pub stack: raxStack,
887 pub node_cb: raxNodeCallback,
888}
889pub type pause_type = libc::c_uint;
890pub const CLIENT_PAUSE_ALL: pause_type = 2;
891pub const CLIENT_PAUSE_WRITE: pause_type = 1;
892pub const CLIENT_PAUSE_OFF: pause_type = 0;
893#[derive(Copy, Clone)]
894#[repr(C)]
895pub struct pause_event {
896 pub type_0: pause_type,
897 pub end: mstime_t,
898}
899#[derive(Copy, Clone)]
900#[repr(C)]
901pub struct RedisModule {
902 pub handle: *mut libc::c_void,
903 pub name: *mut libc::c_char,
904 pub ver: libc::c_int,
905 pub apiver: libc::c_int,
906 pub types: *mut list,
907 pub usedby: *mut list,
908 pub using: *mut list,
909 pub filters: *mut list,
910 pub module_configs: *mut list,
911 pub configs_initialized: libc::c_int,
912 pub in_call: libc::c_int,
913 pub in_hook: libc::c_int,
914 pub options: libc::c_int,
915 pub blocked_clients: libc::c_int,
916 pub info_cb: RedisModuleInfoFunc,
917 pub defrag_cb: RedisModuleDefragFunc,
918 pub loadmod: *mut moduleLoadQueueEntry,
919}
920#[derive(Copy, Clone)]
921#[repr(C)]
922pub struct moduleLoadQueueEntry {
923 pub path: sds,
924 pub argc: libc::c_int,
925 pub argv: *mut *mut robj,
926}
927pub type RedisModuleDefragFunc = Option::<
928 unsafe extern "C" fn(*mut RedisModuleDefragCtx) -> (),
929>;
930pub type RedisModuleInfoFunc = Option::<
931 unsafe extern "C" fn(*mut RedisModuleInfoCtx, libc::c_int) -> (),
932>;
933#[derive(Copy, Clone)]
934#[repr(C)]
935pub struct RedisModuleIO {
936 pub bytes: size_t,
937 pub rio: *mut rio,
938 pub type_0: *mut moduleType,
939 pub error: libc::c_int,
940 pub ver: libc::c_int,
941 pub ctx: *mut RedisModuleCtx,
942 pub key: *mut redisObject,
943 pub dbid: libc::c_int,
944}
945pub type moduleType = RedisModuleType;
946#[derive(Copy, Clone)]
947#[repr(C)]
948pub struct RedisModuleType {
949 pub id: uint64_t,
950 pub module: *mut RedisModule,
951 pub rdb_load: moduleTypeLoadFunc,
952 pub rdb_save: moduleTypeSaveFunc,
953 pub aof_rewrite: moduleTypeRewriteFunc,
954 pub mem_usage: moduleTypeMemUsageFunc,
955 pub digest: moduleTypeDigestFunc,
956 pub free: moduleTypeFreeFunc,
957 pub free_effort: moduleTypeFreeEffortFunc,
958 pub unlink: moduleTypeUnlinkFunc,
959 pub copy: moduleTypeCopyFunc,
960 pub defrag: moduleTypeDefragFunc,
961 pub aux_load: moduleTypeAuxLoadFunc,
962 pub aux_save: moduleTypeAuxSaveFunc,
963 pub mem_usage2: moduleTypeMemUsageFunc2,
964 pub free_effort2: moduleTypeFreeEffortFunc2,
965 pub unlink2: moduleTypeUnlinkFunc2,
966 pub copy2: moduleTypeCopyFunc2,
967 pub aux_save_triggers: libc::c_int,
968 pub name: [libc::c_char; 10],
969}
970pub type moduleTypeCopyFunc2 = Option::<
971 unsafe extern "C" fn(
972 *mut RedisModuleKeyOptCtx,
973 *const libc::c_void,
974 ) -> *mut libc::c_void,
975>;
976pub type moduleTypeUnlinkFunc2 = Option::<
977 unsafe extern "C" fn(*mut RedisModuleKeyOptCtx, *mut libc::c_void) -> (),
978>;
979pub type moduleTypeFreeEffortFunc2 = Option::<
980 unsafe extern "C" fn(*mut RedisModuleKeyOptCtx, *const libc::c_void) -> size_t,
981>;
982pub type moduleTypeMemUsageFunc2 = Option::<
983 unsafe extern "C" fn(
984 *mut RedisModuleKeyOptCtx,
985 *const libc::c_void,
986 size_t,
987 ) -> size_t,
988>;
989pub type moduleTypeAuxSaveFunc = Option::<
990 unsafe extern "C" fn(*mut RedisModuleIO, libc::c_int) -> (),
991>;
992pub type moduleTypeAuxLoadFunc = Option::<
993 unsafe extern "C" fn(*mut RedisModuleIO, libc::c_int, libc::c_int) -> libc::c_int,
994>;
995pub type moduleTypeDefragFunc = Option::<
996 unsafe extern "C" fn(
997 *mut RedisModuleDefragCtx,
998 *mut redisObject,
999 *mut *mut libc::c_void,
1000 ) -> libc::c_int,
1001>;
1002pub type moduleTypeCopyFunc = Option::<
1003 unsafe extern "C" fn(
1004 *mut redisObject,
1005 *mut redisObject,
1006 *const libc::c_void,
1007 ) -> *mut libc::c_void,
1008>;
1009pub type moduleTypeUnlinkFunc = Option::<
1010 unsafe extern "C" fn(*mut redisObject, *mut libc::c_void) -> (),
1011>;
1012pub type moduleTypeFreeEffortFunc = Option::<
1013 unsafe extern "C" fn(*mut redisObject, *const libc::c_void) -> size_t,
1014>;
1015pub type moduleTypeFreeFunc = Option::<unsafe extern "C" fn(*mut libc::c_void) -> ()>;
1016pub type moduleTypeDigestFunc = Option::<
1017 unsafe extern "C" fn(*mut RedisModuleDigest, *mut libc::c_void) -> (),
1018>;
1019#[derive(Copy, Clone)]
1020#[repr(C)]
1021pub struct RedisModuleDigest {
1022 pub o: [libc::c_uchar; 20],
1023 pub x: [libc::c_uchar; 20],
1024 pub key: *mut redisObject,
1025 pub dbid: libc::c_int,
1026}
1027pub type moduleTypeMemUsageFunc = Option::<
1028 unsafe extern "C" fn(*const libc::c_void) -> size_t,
1029>;
1030pub type moduleTypeRewriteFunc = Option::<
1031 unsafe extern "C" fn(*mut RedisModuleIO, *mut redisObject, *mut libc::c_void) -> (),
1032>;
1033pub type moduleTypeSaveFunc = Option::<
1034 unsafe extern "C" fn(*mut RedisModuleIO, *mut libc::c_void) -> (),
1035>;
1036pub type moduleTypeLoadFunc = Option::<
1037 unsafe extern "C" fn(*mut RedisModuleIO, libc::c_int) -> *mut libc::c_void,
1038>;
1039pub type RedisModuleUserChangedFunc = Option::<
1040 unsafe extern "C" fn(uint64_t, *mut libc::c_void) -> (),
1041>;
1042#[derive(Copy, Clone)]
1043#[repr(C)]
1044pub struct moduleValue {
1045 pub type_0: *mut moduleType,
1046 pub value: *mut libc::c_void,
1047}
1048#[derive(Copy, Clone)]
1049#[repr(C)]
1050pub struct redisDb {
1051 pub dict: *mut dict,
1052 pub expires: *mut dict,
1053 pub blocking_keys: *mut dict,
1054 pub ready_keys: *mut dict,
1055 pub watched_keys: *mut dict,
1056 pub id: libc::c_int,
1057 pub avg_ttl: libc::c_longlong,
1058 pub expires_cursor: libc::c_ulong,
1059 pub defrag_later: *mut list,
1060 pub slots_to_keys: *mut clusterSlotToKeyMapping,
1061}
1062#[derive(Copy, Clone)]
1063#[repr(C)]
1064pub struct multiCmd {
1065 pub argv: *mut *mut robj,
1066 pub argv_len: libc::c_int,
1067 pub argc: libc::c_int,
1068 pub cmd: *mut redisCommand,
1069}
1070#[derive(Copy, Clone)]
1071#[repr(C)]
1072pub struct redisCommand {
1073 pub declared_name: *const libc::c_char,
1074 pub summary: *const libc::c_char,
1075 pub complexity: *const libc::c_char,
1076 pub since: *const libc::c_char,
1077 pub doc_flags: libc::c_int,
1078 pub replaced_by: *const libc::c_char,
1079 pub deprecated_since: *const libc::c_char,
1080 pub group: redisCommandGroup,
1081 pub history: *mut commandHistory,
1082 pub tips: *mut *const libc::c_char,
1083 pub proc_0: Option::<redisCommandProc>,
1084 pub arity: libc::c_int,
1085 pub flags: uint64_t,
1086 pub acl_categories: uint64_t,
1087 pub key_specs_static: [keySpec; 4],
1088 pub getkeys_proc: Option::<redisGetKeysProc>,
1089 pub subcommands: *mut redisCommand,
1090 pub args: *mut redisCommandArg,
1091 pub microseconds: libc::c_longlong,
1092 pub calls: libc::c_longlong,
1093 pub rejected_calls: libc::c_longlong,
1094 pub failed_calls: libc::c_longlong,
1095 pub id: libc::c_int,
1096 pub fullname: sds,
1097 pub latency_histogram: *mut hdr_histogram,
1098 pub key_specs: *mut keySpec,
1099 pub legacy_range_key_spec: keySpec,
1100 pub num_args: libc::c_int,
1101 pub num_history: libc::c_int,
1102 pub num_tips: libc::c_int,
1103 pub key_specs_num: libc::c_int,
1104 pub key_specs_max: libc::c_int,
1105 pub subcommands_dict: *mut dict,
1106 pub parent: *mut redisCommand,
1107 pub module_cmd: *mut RedisModuleCommand,
1108}
1109#[derive(Copy, Clone)]
1110#[repr(C)]
1111pub struct keySpec {
1112 pub notes: *const libc::c_char,
1113 pub flags: uint64_t,
1114 pub begin_search_type: kspec_bs_type,
1115 pub bs: C2RustUnnamed_8,
1116 pub find_keys_type: kspec_fk_type,
1117 pub fk: C2RustUnnamed_5,
1118}
1119#[derive(Copy, Clone)]
1120#[repr(C)]
1121pub union C2RustUnnamed_5 {
1122 pub range: C2RustUnnamed_7,
1123 pub keynum: C2RustUnnamed_6,
1124}
1125#[derive(Copy, Clone)]
1126#[repr(C)]
1127pub struct C2RustUnnamed_6 {
1128 pub keynumidx: libc::c_int,
1129 pub firstkey: libc::c_int,
1130 pub keystep: libc::c_int,
1131}
1132#[derive(Copy, Clone)]
1133#[repr(C)]
1134pub struct C2RustUnnamed_7 {
1135 pub lastkey: libc::c_int,
1136 pub keystep: libc::c_int,
1137 pub limit: libc::c_int,
1138}
1139pub type kspec_fk_type = libc::c_uint;
1140pub const KSPEC_FK_KEYNUM: kspec_fk_type = 3;
1141pub const KSPEC_FK_RANGE: kspec_fk_type = 2;
1142pub const KSPEC_FK_UNKNOWN: kspec_fk_type = 1;
1143pub const KSPEC_FK_INVALID: kspec_fk_type = 0;
1144#[derive(Copy, Clone)]
1145#[repr(C)]
1146pub union C2RustUnnamed_8 {
1147 pub index: C2RustUnnamed_10,
1148 pub keyword: C2RustUnnamed_9,
1149}
1150#[derive(Copy, Clone)]
1151#[repr(C)]
1152pub struct C2RustUnnamed_9 {
1153 pub keyword: *const libc::c_char,
1154 pub startfrom: libc::c_int,
1155}
1156#[derive(Copy, Clone)]
1157#[repr(C)]
1158pub struct C2RustUnnamed_10 {
1159 pub pos: libc::c_int,
1160}
1161pub type kspec_bs_type = libc::c_uint;
1162pub const KSPEC_BS_KEYWORD: kspec_bs_type = 3;
1163pub const KSPEC_BS_INDEX: kspec_bs_type = 2;
1164pub const KSPEC_BS_UNKNOWN: kspec_bs_type = 1;
1165pub const KSPEC_BS_INVALID: kspec_bs_type = 0;
1166#[derive(Copy, Clone)]
1167#[repr(C)]
1168pub struct redisCommandArg {
1169 pub name: *const libc::c_char,
1170 pub type_0: redisCommandArgType,
1171 pub key_spec_index: libc::c_int,
1172 pub token: *const libc::c_char,
1173 pub summary: *const libc::c_char,
1174 pub since: *const libc::c_char,
1175 pub flags: libc::c_int,
1176 pub deprecated_since: *const libc::c_char,
1177 pub subargs: *mut redisCommandArg,
1178 pub num_args: libc::c_int,
1179}
1180pub type redisCommandArgType = libc::c_uint;
1181pub const ARG_TYPE_BLOCK: redisCommandArgType = 8;
1182pub const ARG_TYPE_ONEOF: redisCommandArgType = 7;
1183pub const ARG_TYPE_PURE_TOKEN: redisCommandArgType = 6;
1184pub const ARG_TYPE_UNIX_TIME: redisCommandArgType = 5;
1185pub const ARG_TYPE_PATTERN: redisCommandArgType = 4;
1186pub const ARG_TYPE_KEY: redisCommandArgType = 3;
1187pub const ARG_TYPE_DOUBLE: redisCommandArgType = 2;
1188pub const ARG_TYPE_INTEGER: redisCommandArgType = 1;
1189pub const ARG_TYPE_STRING: redisCommandArgType = 0;
1190pub type redisGetKeysProc = unsafe extern "C" fn(
1191 *mut redisCommand,
1192 *mut *mut robj,
1193 libc::c_int,
1194 *mut getKeysResult,
1195) -> libc::c_int;
1196#[derive(Copy, Clone)]
1197#[repr(C)]
1198pub struct getKeysResult {
1199 pub keysbuf: [keyReference; 256],
1200 pub keys: *mut keyReference,
1201 pub numkeys: libc::c_int,
1202 pub size: libc::c_int,
1203}
1204#[derive(Copy, Clone)]
1205#[repr(C)]
1206pub struct keyReference {
1207 pub pos: libc::c_int,
1208 pub flags: libc::c_int,
1209}
1210pub type redisCommandProc = unsafe extern "C" fn(*mut client) -> ();
1211#[derive(Copy, Clone)]
1212#[repr(C)]
1213pub struct client {
1214 pub id: uint64_t,
1215 pub flags: uint64_t,
1216 pub conn: *mut connection,
1217 pub resp: libc::c_int,
1218 pub db: *mut redisDb,
1219 pub name: *mut robj,
1220 pub querybuf: sds,
1221 pub qb_pos: size_t,
1222 pub querybuf_peak: size_t,
1223 pub argc: libc::c_int,
1224 pub argv: *mut *mut robj,
1225 pub argv_len: libc::c_int,
1226 pub original_argc: libc::c_int,
1227 pub original_argv: *mut *mut robj,
1228 pub argv_len_sum: size_t,
1229 pub cmd: *mut redisCommand,
1230 pub lastcmd: *mut redisCommand,
1231 pub realcmd: *mut redisCommand,
1232 pub user: *mut user,
1233 pub reqtype: libc::c_int,
1234 pub multibulklen: libc::c_int,
1235 pub bulklen: libc::c_long,
1236 pub reply: *mut list,
1237 pub reply_bytes: libc::c_ulonglong,
1238 pub deferred_reply_errors: *mut list,
1239 pub sentlen: size_t,
1240 pub ctime: time_t,
1241 pub duration: libc::c_long,
1242 pub slot: libc::c_int,
1243 pub cur_script: *mut dictEntry,
1244 pub lastinteraction: time_t,
1245 pub obuf_soft_limit_reached_time: time_t,
1246 pub authenticated: libc::c_int,
1247 pub replstate: libc::c_int,
1248 pub repl_start_cmd_stream_on_ack: libc::c_int,
1249 pub repldbfd: libc::c_int,
1250 pub repldboff: off_t,
1251 pub repldbsize: off_t,
1252 pub replpreamble: sds,
1253 pub read_reploff: libc::c_longlong,
1254 pub reploff: libc::c_longlong,
1255 pub repl_applied: libc::c_longlong,
1256 pub repl_ack_off: libc::c_longlong,
1257 pub repl_ack_time: libc::c_longlong,
1258 pub repl_last_partial_write: libc::c_longlong,
1259 pub psync_initial_offset: libc::c_longlong,
1260 pub replid: [libc::c_char; 41],
1261 pub slave_listening_port: libc::c_int,
1262 pub slave_addr: *mut libc::c_char,
1263 pub slave_capa: libc::c_int,
1264 pub slave_req: libc::c_int,
1265 pub mstate: multiState,
1266 pub btype: libc::c_int,
1267 pub bpop: blockingState,
1268 pub woff: libc::c_longlong,
1269 pub watched_keys: *mut list,
1270 pub pubsub_channels: *mut dict,
1271 pub pubsub_patterns: *mut list,
1272 pub pubsubshard_channels: *mut dict,
1273 pub peerid: sds,
1274 pub sockname: sds,
1275 pub client_list_node: *mut listNode,
1276 pub postponed_list_node: *mut listNode,
1277 pub pending_read_list_node: *mut listNode,
1278 pub auth_callback: RedisModuleUserChangedFunc,
1279 pub auth_callback_privdata: *mut libc::c_void,
1280 pub auth_module: *mut libc::c_void,
1281 pub client_tracking_redirection: uint64_t,
1282 pub client_tracking_prefixes: *mut rax,
1283 pub last_memory_usage: size_t,
1284 pub last_memory_type: libc::c_int,
1285 pub mem_usage_bucket_node: *mut listNode,
1286 pub mem_usage_bucket: *mut clientMemUsageBucket,
1287 pub ref_repl_buf_node: *mut listNode,
1288 pub ref_block_pos: size_t,
1289 pub buf_peak: size_t,
1290 pub buf_peak_last_reset_time: mstime_t,
1291 pub bufpos: libc::c_int,
1292 pub buf_usable_size: size_t,
1293 pub buf: *mut libc::c_char,
1294}
1295#[derive(Copy, Clone)]
1296#[repr(C)]
1297pub struct clientMemUsageBucket {
1298 pub clients: *mut list,
1299 pub mem_usage_sum: size_t,
1300}
1301#[derive(Copy, Clone)]
1302#[repr(C)]
1303pub struct blockingState {
1304 pub count: libc::c_long,
1305 pub timeout: mstime_t,
1306 pub keys: *mut dict,
1307 pub target: *mut robj,
1308 pub blockpos: blockPos,
1309 pub xread_count: size_t,
1310 pub xread_group: *mut robj,
1311 pub xread_consumer: *mut robj,
1312 pub xread_group_noack: libc::c_int,
1313 pub numreplicas: libc::c_int,
1314 pub reploffset: libc::c_longlong,
1315 pub module_blocked_handle: *mut libc::c_void,
1316}
1317#[derive(Copy, Clone)]
1318#[repr(C)]
1319pub struct blockPos {
1320 pub wherefrom: libc::c_int,
1321 pub whereto: libc::c_int,
1322}
1323#[derive(Copy, Clone)]
1324#[repr(C)]
1325pub struct multiState {
1326 pub commands: *mut multiCmd,
1327 pub count: libc::c_int,
1328 pub cmd_flags: libc::c_int,
1329 pub cmd_inv_flags: libc::c_int,
1330 pub argv_len_sums: size_t,
1331 pub alloc_count: libc::c_int,
1332}
1333#[derive(Copy, Clone)]
1334#[repr(C)]
1335pub struct user {
1336 pub name: sds,
1337 pub flags: uint32_t,
1338 pub passwords: *mut list,
1339 pub selectors: *mut list,
1340 pub acl_string: *mut robj,
1341}
1342#[derive(Copy, Clone)]
1343#[repr(C)]
1344pub struct commandHistory {
1345 pub since: *const libc::c_char,
1346 pub changes: *const libc::c_char,
1347}
1348pub type redisCommandGroup = libc::c_uint;
1349pub const COMMAND_GROUP_MODULE: redisCommandGroup = 17;
1350pub const COMMAND_GROUP_BITMAP: redisCommandGroup = 16;
1351pub const COMMAND_GROUP_STREAM: redisCommandGroup = 15;
1352pub const COMMAND_GROUP_GEO: redisCommandGroup = 14;
1353pub const COMMAND_GROUP_SENTINEL: redisCommandGroup = 13;
1354pub const COMMAND_GROUP_CLUSTER: redisCommandGroup = 12;
1355pub const COMMAND_GROUP_HYPERLOGLOG: redisCommandGroup = 11;
1356pub const COMMAND_GROUP_SCRIPTING: redisCommandGroup = 10;
1357pub const COMMAND_GROUP_SERVER: redisCommandGroup = 9;
1358pub const COMMAND_GROUP_CONNECTION: redisCommandGroup = 8;
1359pub const COMMAND_GROUP_TRANSACTIONS: redisCommandGroup = 7;
1360pub const COMMAND_GROUP_PUBSUB: redisCommandGroup = 6;
1361pub const COMMAND_GROUP_HASH: redisCommandGroup = 5;
1362pub const COMMAND_GROUP_SORTED_SET: redisCommandGroup = 4;
1363pub const COMMAND_GROUP_SET: redisCommandGroup = 3;
1364pub const COMMAND_GROUP_LIST: redisCommandGroup = 2;
1365pub const COMMAND_GROUP_STRING: redisCommandGroup = 1;
1366pub const COMMAND_GROUP_GENERIC: redisCommandGroup = 0;
1367#[derive(Copy, Clone)]
1368#[repr(C)]
1369pub struct replBacklog {
1370 pub ref_repl_buf_node: *mut listNode,
1371 pub unindexed_count: size_t,
1372 pub blocks_index: *mut rax,
1373 pub histlen: libc::c_longlong,
1374 pub offset: libc::c_longlong,
1375}
1376#[derive(Copy, Clone)]
1377#[repr(C)]
1378pub struct saveparam {
1379 pub seconds: time_t,
1380 pub changes: libc::c_int,
1381}
1382#[derive(Copy, Clone)]
1383#[repr(C)]
1384pub struct sentinelConfig {
1385 pub pre_monitor_cfg: *mut list,
1386 pub monitor_cfg: *mut list,
1387 pub post_monitor_cfg: *mut list,
1388}
1389#[derive(Copy, Clone)]
1390#[repr(C)]
1391pub struct zskiplistNode {
1392 pub ele: sds,
1393 pub score: libc::c_double,
1394 pub backward: *mut zskiplistNode,
1395 pub level: [zskiplistLevel; 0],
1396}
1397#[derive(Copy, Clone)]
1398#[repr(C)]
1399pub struct zskiplistLevel {
1400 pub forward: *mut zskiplistNode,
1401 pub span: libc::c_ulong,
1402}
1403#[derive(Copy, Clone)]
1404#[repr(C)]
1405pub struct zskiplist {
1406 pub header: *mut zskiplistNode,
1407 pub tail: *mut zskiplistNode,
1408 pub length: libc::c_ulong,
1409 pub level: libc::c_int,
1410}
1411#[derive(Copy, Clone)]
1412#[repr(C)]
1413pub struct zset {
1414 pub dict: *mut dict,
1415 pub zsl: *mut zskiplist,
1416}
1417#[derive(Copy, Clone)]
1418#[repr(C)]
1419pub struct clientBufferLimitsConfig {
1420 pub hard_limit_bytes: libc::c_ulonglong,
1421 pub soft_limit_bytes: libc::c_ulonglong,
1422 pub soft_limit_seconds: time_t,
1423}
1424#[derive(Copy, Clone)]
1425#[repr(C)]
1426pub struct redisOp {
1427 pub argv: *mut *mut robj,
1428 pub argc: libc::c_int,
1429 pub dbid: libc::c_int,
1430 pub target: libc::c_int,
1431}
1432#[derive(Copy, Clone)]
1433#[repr(C)]
1434pub struct redisOpArray {
1435 pub ops: *mut redisOp,
1436 pub numops: libc::c_int,
1437 pub capacity: libc::c_int,
1438}
1439#[derive(Copy, Clone)]
1440#[repr(C)]
1441pub struct rdbSaveInfo {
1442 pub repl_stream_db: libc::c_int,
1443 pub repl_id_is_set: libc::c_int,
1444 pub repl_id: [libc::c_char; 41],
1445 pub repl_offset: libc::c_longlong,
1446}
1447#[derive(Copy, Clone)]
1448#[repr(C)]
1449pub struct malloc_stats {
1450 pub zmalloc_used: size_t,
1451 pub process_rss: size_t,
1452 pub allocator_allocated: size_t,
1453 pub allocator_active: size_t,
1454 pub allocator_resident: size_t,
1455}
1456#[derive(Copy, Clone)]
1457#[repr(C)]
1458pub struct socketFds {
1459 pub fd: [libc::c_int; 16],
1460 pub count: libc::c_int,
1461}
1462#[derive(Copy, Clone)]
1463#[repr(C)]
1464pub struct redisTLSContextConfig {
1465 pub cert_file: *mut libc::c_char,
1466 pub key_file: *mut libc::c_char,
1467 pub key_file_pass: *mut libc::c_char,
1468 pub client_cert_file: *mut libc::c_char,
1469 pub client_key_file: *mut libc::c_char,
1470 pub client_key_file_pass: *mut libc::c_char,
1471 pub dh_params_file: *mut libc::c_char,
1472 pub ca_cert_file: *mut libc::c_char,
1473 pub ca_cert_dir: *mut libc::c_char,
1474 pub protocols: *mut libc::c_char,
1475 pub ciphers: *mut libc::c_char,
1476 pub ciphersuites: *mut libc::c_char,
1477 pub prefer_server_ciphers: libc::c_int,
1478 pub session_caching: libc::c_int,
1479 pub session_cache_size: libc::c_int,
1480 pub session_cache_timeout: libc::c_int,
1481}
1482pub type aof_file_type = libc::c_uint;
1483pub const AOF_FILE_TYPE_INCR: aof_file_type = 105;
1484pub const AOF_FILE_TYPE_HIST: aof_file_type = 104;
1485pub const AOF_FILE_TYPE_BASE: aof_file_type = 98;
1486#[derive(Copy, Clone)]
1487#[repr(C)]
1488pub struct aofInfo {
1489 pub file_name: sds,
1490 pub file_seq: libc::c_longlong,
1491 pub file_type: aof_file_type,
1492}
1493#[derive(Copy, Clone)]
1494#[repr(C)]
1495pub struct aofManifest {
1496 pub base_aof_info: *mut aofInfo,
1497 pub incr_aof_list: *mut list,
1498 pub history_aof_list: *mut list,
1499 pub curr_base_file_seq: libc::c_longlong,
1500 pub curr_incr_file_seq: libc::c_longlong,
1501 pub dirty: libc::c_int,
1502}
1503pub type childInfoType = libc::c_uint;
1504pub const CHILD_INFO_TYPE_MODULE_COW_SIZE: childInfoType = 3;
1505pub const CHILD_INFO_TYPE_RDB_COW_SIZE: childInfoType = 2;
1506pub const CHILD_INFO_TYPE_AOF_COW_SIZE: childInfoType = 1;
1507pub const CHILD_INFO_TYPE_CURRENT_INFO: childInfoType = 0;
1508#[derive(Copy, Clone)]
1509#[repr(C)]
1510pub struct redisServer {
1511 pub pid: pid_t,
1512 pub main_thread_id: pthread_t,
1513 pub configfile: *mut libc::c_char,
1514 pub executable: *mut libc::c_char,
1515 pub exec_argv: *mut *mut libc::c_char,
1516 pub dynamic_hz: libc::c_int,
1517 pub config_hz: libc::c_int,
1518 pub umask: mode_t,
1519 pub hz: libc::c_int,
1520 pub in_fork_child: libc::c_int,
1521 pub db: *mut redisDb,
1522 pub commands: *mut dict,
1523 pub orig_commands: *mut dict,
1524 pub el: *mut aeEventLoop,
1525 pub errors: *mut rax,
1526 pub lruclock: atomic_uint,
1527 pub shutdown_asap: sig_atomic_t,
1528 pub shutdown_mstime: mstime_t,
1529 pub last_sig_received: libc::c_int,
1530 pub shutdown_flags: libc::c_int,
1531 pub activerehashing: libc::c_int,
1532 pub active_defrag_running: libc::c_int,
1533 pub pidfile: *mut libc::c_char,
1534 pub arch_bits: libc::c_int,
1535 pub cronloops: libc::c_int,
1536 pub runid: [libc::c_char; 41],
1537 pub sentinel_mode: libc::c_int,
1538 pub initial_memory_usage: size_t,
1539 pub always_show_logo: libc::c_int,
1540 pub in_exec: libc::c_int,
1541 pub busy_module_yield_flags: libc::c_int,
1542 pub busy_module_yield_reply: *const libc::c_char,
1543 pub core_propagates: libc::c_int,
1544 pub propagate_no_multi: libc::c_int,
1545 pub module_ctx_nesting: libc::c_int,
1546 pub ignore_warnings: *mut libc::c_char,
1547 pub client_pause_in_transaction: libc::c_int,
1548 pub thp_enabled: libc::c_int,
1549 pub page_size: size_t,
1550 pub moduleapi: *mut dict,
1551 pub sharedapi: *mut dict,
1552 pub module_configs_queue: *mut dict,
1553 pub loadmodule_queue: *mut list,
1554 pub module_pipe: [libc::c_int; 2],
1555 pub child_pid: pid_t,
1556 pub child_type: libc::c_int,
1557 pub port: libc::c_int,
1558 pub tls_port: libc::c_int,
1559 pub tcp_backlog: libc::c_int,
1560 pub bindaddr: [*mut libc::c_char; 16],
1561 pub bindaddr_count: libc::c_int,
1562 pub bind_source_addr: *mut libc::c_char,
1563 pub unixsocket: *mut libc::c_char,
1564 pub unixsocketperm: libc::c_uint,
1565 pub ipfd: socketFds,
1566 pub tlsfd: socketFds,
1567 pub sofd: libc::c_int,
1568 pub socket_mark_id: uint32_t,
1569 pub cfd: socketFds,
1570 pub clients: *mut list,
1571 pub clients_to_close: *mut list,
1572 pub clients_pending_write: *mut list,
1573 pub clients_pending_read: *mut list,
1574 pub slaves: *mut list,
1575 pub monitors: *mut list,
1576 pub current_client: *mut client,
1577 pub client_mem_usage_buckets: *mut clientMemUsageBucket,
1578 pub clients_timeout_table: *mut rax,
1579 pub fixed_time_expire: libc::c_long,
1580 pub in_nested_call: libc::c_int,
1581 pub clients_index: *mut rax,
1582 pub client_pause_type: pause_type,
1583 pub postponed_clients: *mut list,
1584 pub client_pause_end_time: mstime_t,
1585 pub client_pause_per_purpose: [*mut pause_event; 3],
1586 pub neterr: [libc::c_char; 256],
1587 pub migrate_cached_sockets: *mut dict,
1588 pub next_client_id: uint_least64_t,
1589 pub protected_mode: libc::c_int,
1590 pub io_threads_num: libc::c_int,
1591 pub io_threads_do_reads: libc::c_int,
1592 pub io_threads_active: libc::c_int,
1593 pub events_processed_while_blocked: libc::c_longlong,
1594 pub enable_protected_configs: libc::c_int,
1595 pub enable_debug_cmd: libc::c_int,
1596 pub enable_module_cmd: libc::c_int,
1597 pub loading: sig_atomic_t,
1598 pub async_loading: sig_atomic_t,
1599 pub loading_total_bytes: off_t,
1600 pub loading_rdb_used_mem: off_t,
1601 pub loading_loaded_bytes: off_t,
1602 pub loading_start_time: time_t,
1603 pub loading_process_events_interval_bytes: off_t,
1604 pub stat_starttime: time_t,
1605 pub stat_numcommands: libc::c_longlong,
1606 pub stat_numconnections: libc::c_longlong,
1607 pub stat_expiredkeys: libc::c_longlong,
1608 pub stat_expired_stale_perc: libc::c_double,
1609 pub stat_expired_time_cap_reached_count: libc::c_longlong,
1610 pub stat_expire_cycle_time_used: libc::c_longlong,
1611 pub stat_evictedkeys: libc::c_longlong,
1612 pub stat_evictedclients: libc::c_longlong,
1613 pub stat_total_eviction_exceeded_time: libc::c_longlong,
1614 pub stat_last_eviction_exceeded_time: monotime,
1615 pub stat_keyspace_hits: libc::c_longlong,
1616 pub stat_keyspace_misses: libc::c_longlong,
1617 pub stat_active_defrag_hits: libc::c_longlong,
1618 pub stat_active_defrag_misses: libc::c_longlong,
1619 pub stat_active_defrag_key_hits: libc::c_longlong,
1620 pub stat_active_defrag_key_misses: libc::c_longlong,
1621 pub stat_active_defrag_scanned: libc::c_longlong,
1622 pub stat_total_active_defrag_time: libc::c_longlong,
1623 pub stat_last_active_defrag_time: monotime,
1624 pub stat_peak_memory: size_t,
1625 pub stat_aof_rewrites: libc::c_longlong,
1626 pub stat_aofrw_consecutive_failures: libc::c_longlong,
1627 pub stat_rdb_saves: libc::c_longlong,
1628 pub stat_fork_time: libc::c_longlong,
1629 pub stat_fork_rate: libc::c_double,
1630 pub stat_total_forks: libc::c_longlong,
1631 pub stat_rejected_conn: libc::c_longlong,
1632 pub stat_sync_full: libc::c_longlong,
1633 pub stat_sync_partial_ok: libc::c_longlong,
1634 pub stat_sync_partial_err: libc::c_longlong,
1635 pub slowlog: *mut list,
1636 pub slowlog_entry_id: libc::c_longlong,
1637 pub slowlog_log_slower_than: libc::c_longlong,
1638 pub slowlog_max_len: libc::c_ulong,
1639 pub cron_malloc_stats: malloc_stats,
1640 pub stat_net_input_bytes: atomic_llong,
1641 pub stat_net_output_bytes: atomic_llong,
1642 pub stat_net_repl_input_bytes: atomic_llong,
1643 pub stat_net_repl_output_bytes: atomic_llong,
1644 pub stat_current_cow_peak: size_t,
1645 pub stat_current_cow_bytes: size_t,
1646 pub stat_current_cow_updated: monotime,
1647 pub stat_current_save_keys_processed: size_t,
1648 pub stat_current_save_keys_total: size_t,
1649 pub stat_rdb_cow_bytes: size_t,
1650 pub stat_aof_cow_bytes: size_t,
1651 pub stat_module_cow_bytes: size_t,
1652 pub stat_module_progress: libc::c_double,
1653 pub stat_clients_type_memory: [size_t; 4],
1654 pub stat_cluster_links_memory: size_t,
1655 pub stat_unexpected_error_replies: libc::c_longlong,
1656 pub stat_total_error_replies: libc::c_longlong,
1657 pub stat_dump_payload_sanitizations: libc::c_longlong,
1658 pub stat_io_reads_processed: libc::c_longlong,
1659 pub stat_io_writes_processed: libc::c_longlong,
1660 pub stat_total_reads_processed: atomic_llong,
1661 pub stat_total_writes_processed: atomic_llong,
1662 pub inst_metric: [C2RustUnnamed_11; 5],
1663 pub stat_reply_buffer_shrinks: libc::c_longlong,
1664 pub stat_reply_buffer_expands: libc::c_longlong,
1665 pub verbosity: libc::c_int,
1666 pub maxidletime: libc::c_int,
1667 pub tcpkeepalive: libc::c_int,
1668 pub active_expire_enabled: libc::c_int,
1669 pub active_expire_effort: libc::c_int,
1670 pub active_defrag_enabled: libc::c_int,
1671 pub sanitize_dump_payload: libc::c_int,
1672 pub skip_checksum_validation: libc::c_int,
1673 pub jemalloc_bg_thread: libc::c_int,
1674 pub active_defrag_ignore_bytes: size_t,
1675 pub active_defrag_threshold_lower: libc::c_int,
1676 pub active_defrag_threshold_upper: libc::c_int,
1677 pub active_defrag_cycle_min: libc::c_int,
1678 pub active_defrag_cycle_max: libc::c_int,
1679 pub active_defrag_max_scan_fields: libc::c_ulong,
1680 pub client_max_querybuf_len: size_t,
1681 pub dbnum: libc::c_int,
1682 pub supervised: libc::c_int,
1683 pub supervised_mode: libc::c_int,
1684 pub daemonize: libc::c_int,
1685 pub set_proc_title: libc::c_int,
1686 pub proc_title_template: *mut libc::c_char,
1687 pub client_obuf_limits: [clientBufferLimitsConfig; 3],
1688 pub pause_cron: libc::c_int,
1689 pub latency_tracking_enabled: libc::c_int,
1690 pub latency_tracking_info_percentiles: *mut libc::c_double,
1691 pub latency_tracking_info_percentiles_len: libc::c_int,
1692 pub aof_enabled: libc::c_int,
1693 pub aof_state: libc::c_int,
1694 pub aof_fsync: libc::c_int,
1695 pub aof_filename: *mut libc::c_char,
1696 pub aof_dirname: *mut libc::c_char,
1697 pub aof_no_fsync_on_rewrite: libc::c_int,
1698 pub aof_rewrite_perc: libc::c_int,
1699 pub aof_rewrite_min_size: off_t,
1700 pub aof_rewrite_base_size: off_t,
1701 pub aof_current_size: off_t,
1702 pub aof_last_incr_size: off_t,
1703 pub aof_fsync_offset: off_t,
1704 pub aof_flush_sleep: libc::c_int,
1705 pub aof_rewrite_scheduled: libc::c_int,
1706 pub aof_buf: sds,
1707 pub aof_fd: libc::c_int,
1708 pub aof_selected_db: libc::c_int,
1709 pub aof_flush_postponed_start: time_t,
1710 pub aof_last_fsync: time_t,
1711 pub aof_rewrite_time_last: time_t,
1712 pub aof_rewrite_time_start: time_t,
1713 pub aof_cur_timestamp: time_t,
1714 pub aof_timestamp_enabled: libc::c_int,
1715 pub aof_lastbgrewrite_status: libc::c_int,
1716 pub aof_delayed_fsync: libc::c_ulong,
1717 pub aof_rewrite_incremental_fsync: libc::c_int,
1718 pub rdb_save_incremental_fsync: libc::c_int,
1719 pub aof_last_write_status: libc::c_int,
1720 pub aof_last_write_errno: libc::c_int,
1721 pub aof_load_truncated: libc::c_int,
1722 pub aof_use_rdb_preamble: libc::c_int,
1723 pub aof_bio_fsync_status: atomic_int,
1724 pub aof_bio_fsync_errno: atomic_int,
1725 pub aof_manifest: *mut aofManifest,
1726 pub aof_disable_auto_gc: libc::c_int,
1727 pub dirty: libc::c_longlong,
1728 pub dirty_before_bgsave: libc::c_longlong,
1729 pub rdb_last_load_keys_expired: libc::c_longlong,
1730 pub rdb_last_load_keys_loaded: libc::c_longlong,
1731 pub saveparams: *mut saveparam,
1732 pub saveparamslen: libc::c_int,
1733 pub rdb_filename: *mut libc::c_char,
1734 pub rdb_compression: libc::c_int,
1735 pub rdb_checksum: libc::c_int,
1736 pub rdb_del_sync_files: libc::c_int,
1737 pub lastsave: time_t,
1738 pub lastbgsave_try: time_t,
1739 pub rdb_save_time_last: time_t,
1740 pub rdb_save_time_start: time_t,
1741 pub rdb_bgsave_scheduled: libc::c_int,
1742 pub rdb_child_type: libc::c_int,
1743 pub lastbgsave_status: libc::c_int,
1744 pub stop_writes_on_bgsave_err: libc::c_int,
1745 pub rdb_pipe_read: libc::c_int,
1746 pub rdb_child_exit_pipe: libc::c_int,
1747 pub rdb_pipe_conns: *mut *mut connection,
1748 pub rdb_pipe_numconns: libc::c_int,
1749 pub rdb_pipe_numconns_writing: libc::c_int,
1750 pub rdb_pipe_buff: *mut libc::c_char,
1751 pub rdb_pipe_bufflen: libc::c_int,
1752 pub rdb_key_save_delay: libc::c_int,
1753 pub key_load_delay: libc::c_int,
1754 pub child_info_pipe: [libc::c_int; 2],
1755 pub child_info_nread: libc::c_int,
1756 pub also_propagate: redisOpArray,
1757 pub replication_allowed: libc::c_int,
1758 pub logfile: *mut libc::c_char,
1759 pub syslog_enabled: libc::c_int,
1760 pub syslog_ident: *mut libc::c_char,
1761 pub syslog_facility: libc::c_int,
1762 pub crashlog_enabled: libc::c_int,
1763 pub memcheck_enabled: libc::c_int,
1764 pub use_exit_on_panic: libc::c_int,
1765 pub shutdown_timeout: libc::c_int,
1766 pub shutdown_on_sigint: libc::c_int,
1767 pub shutdown_on_sigterm: libc::c_int,
1768 pub replid: [libc::c_char; 41],
1769 pub replid2: [libc::c_char; 41],
1770 pub master_repl_offset: libc::c_longlong,
1771 pub second_replid_offset: libc::c_longlong,
1772 pub slaveseldb: libc::c_int,
1773 pub repl_ping_slave_period: libc::c_int,
1774 pub repl_backlog: *mut replBacklog,
1775 pub repl_backlog_size: libc::c_longlong,
1776 pub repl_backlog_time_limit: time_t,
1777 pub repl_no_slaves_since: time_t,
1778 pub repl_min_slaves_to_write: libc::c_int,
1779 pub repl_min_slaves_max_lag: libc::c_int,
1780 pub repl_good_slaves_count: libc::c_int,
1781 pub repl_diskless_sync: libc::c_int,
1782 pub repl_diskless_load: libc::c_int,
1783 pub repl_diskless_sync_delay: libc::c_int,
1784 pub repl_diskless_sync_max_replicas: libc::c_int,
1785 pub repl_buffer_mem: size_t,
1786 pub repl_buffer_blocks: *mut list,
1787 pub masteruser: *mut libc::c_char,
1788 pub masterauth: sds,
1789 pub masterhost: *mut libc::c_char,
1790 pub masterport: libc::c_int,
1791 pub repl_timeout: libc::c_int,
1792 pub master: *mut client,
1793 pub cached_master: *mut client,
1794 pub repl_syncio_timeout: libc::c_int,
1795 pub repl_state: libc::c_int,
1796 pub repl_transfer_size: off_t,
1797 pub repl_transfer_read: off_t,
1798 pub repl_transfer_last_fsync_off: off_t,
1799 pub repl_transfer_s: *mut connection,
1800 pub repl_transfer_fd: libc::c_int,
1801 pub repl_transfer_tmpfile: *mut libc::c_char,
1802 pub repl_transfer_lastio: time_t,
1803 pub repl_serve_stale_data: libc::c_int,
1804 pub repl_slave_ro: libc::c_int,
1805 pub repl_slave_ignore_maxmemory: libc::c_int,
1806 pub repl_down_since: time_t,
1807 pub repl_disable_tcp_nodelay: libc::c_int,
1808 pub slave_priority: libc::c_int,
1809 pub replica_announced: libc::c_int,
1810 pub slave_announce_port: libc::c_int,
1811 pub slave_announce_ip: *mut libc::c_char,
1812 pub propagation_error_behavior: libc::c_int,
1813 pub repl_ignore_disk_write_error: libc::c_int,
1814 pub master_replid: [libc::c_char; 41],
1815 pub master_initial_offset: libc::c_longlong,
1816 pub repl_slave_lazy_flush: libc::c_int,
1817 pub clients_waiting_acks: *mut list,
1818 pub get_ack_from_slaves: libc::c_int,
1819 pub maxclients: libc::c_uint,
1820 pub maxmemory: libc::c_ulonglong,
1821 pub maxmemory_clients: ssize_t,
1822 pub maxmemory_policy: libc::c_int,
1823 pub maxmemory_samples: libc::c_int,
1824 pub maxmemory_eviction_tenacity: libc::c_int,
1825 pub lfu_log_factor: libc::c_int,
1826 pub lfu_decay_time: libc::c_int,
1827 pub proto_max_bulk_len: libc::c_longlong,
1828 pub oom_score_adj_values: [libc::c_int; 3],
1829 pub oom_score_adj: libc::c_int,
1830 pub disable_thp: libc::c_int,
1831 pub blocked_clients: libc::c_uint,
1832 pub blocked_clients_by_type: [libc::c_uint; 8],
1833 pub unblocked_clients: *mut list,
1834 pub ready_keys: *mut list,
1835 pub tracking_clients: libc::c_uint,
1836 pub tracking_table_max_keys: size_t,
1837 pub tracking_pending_keys: *mut list,
1838 pub sort_desc: libc::c_int,
1839 pub sort_alpha: libc::c_int,
1840 pub sort_bypattern: libc::c_int,
1841 pub sort_store: libc::c_int,
1842 pub hash_max_listpack_entries: size_t,
1843 pub hash_max_listpack_value: size_t,
1844 pub set_max_intset_entries: size_t,
1845 pub zset_max_listpack_entries: size_t,
1846 pub zset_max_listpack_value: size_t,
1847 pub hll_sparse_max_bytes: size_t,
1848 pub stream_node_max_bytes: size_t,
1849 pub stream_node_max_entries: libc::c_longlong,
1850 pub list_max_listpack_size: libc::c_int,
1851 pub list_compress_depth: libc::c_int,
1852 pub unixtime: atomic_int,
1853 pub timezone: time_t,
1854 pub daylight_active: libc::c_int,
1855 pub mstime: mstime_t,
1856 pub ustime: ustime_t,
1857 pub blocking_op_nesting: size_t,
1858 pub blocked_last_cron: libc::c_longlong,
1859 pub pubsub_channels: *mut dict,
1860 pub pubsub_patterns: *mut dict,
1861 pub notify_keyspace_events: libc::c_int,
1862 pub pubsubshard_channels: *mut dict,
1863 pub cluster_enabled: libc::c_int,
1864 pub cluster_port: libc::c_int,
1865 pub cluster_node_timeout: mstime_t,
1866 pub cluster_configfile: *mut libc::c_char,
1867 pub cluster: *mut clusterState,
1868 pub cluster_migration_barrier: libc::c_int,
1869 pub cluster_allow_replica_migration: libc::c_int,
1870 pub cluster_slave_validity_factor: libc::c_int,
1871 pub cluster_require_full_coverage: libc::c_int,
1872 pub cluster_slave_no_failover: libc::c_int,
1873 pub cluster_announce_ip: *mut libc::c_char,
1874 pub cluster_announce_hostname: *mut libc::c_char,
1875 pub cluster_preferred_endpoint_type: libc::c_int,
1876 pub cluster_announce_port: libc::c_int,
1877 pub cluster_announce_tls_port: libc::c_int,
1878 pub cluster_announce_bus_port: libc::c_int,
1879 pub cluster_module_flags: libc::c_int,
1880 pub cluster_allow_reads_when_down: libc::c_int,
1881 pub cluster_config_file_lock_fd: libc::c_int,
1882 pub cluster_link_sendbuf_limit_bytes: libc::c_ulonglong,
1883 pub cluster_drop_packet_filter: libc::c_int,
1884 pub script_caller: *mut client,
1885 pub busy_reply_threshold: mstime_t,
1886 pub pre_command_oom_state: libc::c_int,
1887 pub script_disable_deny_script: libc::c_int,
1888 pub lazyfree_lazy_eviction: libc::c_int,
1889 pub lazyfree_lazy_expire: libc::c_int,
1890 pub lazyfree_lazy_server_del: libc::c_int,
1891 pub lazyfree_lazy_user_del: libc::c_int,
1892 pub lazyfree_lazy_user_flush: libc::c_int,
1893 pub latency_monitor_threshold: libc::c_longlong,
1894 pub latency_events: *mut dict,
1895 pub acl_filename: *mut libc::c_char,
1896 pub acllog_max_len: libc::c_ulong,
1897 pub requirepass: sds,
1898 pub acl_pubsub_default: libc::c_int,
1899 pub watchdog_period: libc::c_int,
1900 pub system_memory_size: size_t,
1901 pub tls_cluster: libc::c_int,
1902 pub tls_replication: libc::c_int,
1903 pub tls_auth_clients: libc::c_int,
1904 pub tls_ctx_config: redisTLSContextConfig,
1905 pub server_cpulist: *mut libc::c_char,
1906 pub bio_cpulist: *mut libc::c_char,
1907 pub aof_rewrite_cpulist: *mut libc::c_char,
1908 pub bgsave_cpulist: *mut libc::c_char,
1909 pub sentinel_config: *mut sentinelConfig,
1910 pub failover_end_time: mstime_t,
1911 pub force_failover: libc::c_int,
1912 pub target_replica_host: *mut libc::c_char,
1913 pub target_replica_port: libc::c_int,
1914 pub failover_state: libc::c_int,
1915 pub cluster_allow_pubsubshard_when_down: libc::c_int,
1916 pub reply_buffer_peak_reset_time: libc::c_long,
1917 pub reply_buffer_resizing_enabled: libc::c_int,
1918}
1919#[derive(Copy, Clone)]
1920#[repr(C)]
1921pub struct C2RustUnnamed_11 {
1922 pub last_sample_time: libc::c_longlong,
1923 pub last_sample_count: libc::c_longlong,
1924 pub samples: [libc::c_longlong; 16],
1925 pub idx: libc::c_int,
1926}
1927#[derive(Copy, Clone)]
1928#[repr(C)]
1929pub struct hashTypeIterator {
1930 pub subject: *mut robj,
1931 pub encoding: libc::c_int,
1932 pub fptr: *mut libc::c_uchar,
1933 pub vptr: *mut libc::c_uchar,
1934 pub di: *mut dictIterator,
1935 pub de: *mut dictEntry,
1936}
1937#[derive(Copy, Clone)]
1938#[repr(C)]
1939pub struct streamID {
1940 pub ms: uint64_t,
1941 pub seq: uint64_t,
1942}
1943#[derive(Copy, Clone)]
1944#[repr(C)]
1945pub struct stream {
1946 pub rax: *mut rax,
1947 pub length: uint64_t,
1948 pub last_id: streamID,
1949 pub first_id: streamID,
1950 pub max_deleted_entry_id: streamID,
1951 pub entries_added: uint64_t,
1952 pub cgroups: *mut rax,
1953}
1954#[derive(Copy, Clone)]
1955#[repr(C)]
1956pub struct streamIterator {
1957 pub stream: *mut stream,
1958 pub master_id: streamID,
1959 pub master_fields_count: uint64_t,
1960 pub master_fields_start: *mut libc::c_uchar,
1961 pub master_fields_ptr: *mut libc::c_uchar,
1962 pub entry_flags: libc::c_int,
1963 pub rev: libc::c_int,
1964 pub skip_tombstones: libc::c_int,
1965 pub start_key: [uint64_t; 2],
1966 pub end_key: [uint64_t; 2],
1967 pub ri: raxIterator,
1968 pub lp: *mut libc::c_uchar,
1969 pub lp_ele: *mut libc::c_uchar,
1970 pub lp_flags: *mut libc::c_uchar,
1971 pub field_buf: [libc::c_uchar; 21],
1972 pub value_buf: [libc::c_uchar; 21],
1973}
1974#[derive(Copy, Clone)]
1975#[repr(C)]
1976pub struct streamCG {
1977 pub last_id: streamID,
1978 pub entries_read: libc::c_longlong,
1979 pub pel: *mut rax,
1980 pub consumers: *mut rax,
1981}
1982#[derive(Copy, Clone)]
1983#[repr(C)]
1984pub struct streamConsumer {
1985 pub seen_time: mstime_t,
1986 pub name: sds,
1987 pub pel: *mut rax,
1988}
1989#[derive(Copy, Clone)]
1990#[repr(C)]
1991pub struct streamNACK {
1992 pub delivery_time: mstime_t,
1993 pub delivery_count: uint64_t,
1994 pub consumer: *mut streamConsumer,
1995}
1996#[derive(Copy, Clone)]
1997#[repr(C)]
1998pub struct functionLibInfo {
1999 pub name: sds,
2000 pub functions: *mut dict,
2001 pub ei: *mut engineInfo,
2002 pub code: sds,
2003}
2004#[derive(Copy, Clone)]
2005#[repr(C)]
2006pub struct engineInfo {
2007 pub name: sds,
2008 pub engine: *mut engine,
2009 pub c: *mut client,
2010}
2011#[derive(Copy, Clone)]
2012#[repr(C)]
2013pub struct engine {
2014 pub engine_ctx: *mut libc::c_void,
2015 pub create: Option::<
2016 unsafe extern "C" fn(
2017 *mut libc::c_void,
2018 *mut functionLibInfo,
2019 sds,
2020 *mut sds,
2021 ) -> libc::c_int,
2022 >,
2023 pub call: Option::<
2024 unsafe extern "C" fn(
2025 *mut scriptRunCtx,
2026 *mut libc::c_void,
2027 *mut libc::c_void,
2028 *mut *mut robj,
2029 size_t,
2030 *mut *mut robj,
2031 size_t,
2032 ) -> (),
2033 >,
2034 pub get_used_memory: Option::<unsafe extern "C" fn(*mut libc::c_void) -> size_t>,
2035 pub get_function_memory_overhead: Option::<
2036 unsafe extern "C" fn(*mut libc::c_void) -> size_t,
2037 >,
2038 pub get_engine_memory_overhead: Option::<
2039 unsafe extern "C" fn(*mut libc::c_void) -> size_t,
2040 >,
2041 pub free_function: Option::<
2042 unsafe extern "C" fn(*mut libc::c_void, *mut libc::c_void) -> (),
2043 >,
2044}
2045#[derive(Copy, Clone)]
2046#[repr(C)]
2047pub struct scriptRunCtx {
2048 pub funcname: *const libc::c_char,
2049 pub c: *mut client,
2050 pub original_client: *mut client,
2051 pub flags: libc::c_int,
2052 pub repl_flags: libc::c_int,
2053 pub start_time: monotime,
2054 pub snapshot_time: mstime_t,
2055}
2056#[inline]
2057unsafe extern "C" fn sdslen(s: sds) -> size_t {
2058 let mut flags: libc::c_uchar = *s.offset(-(1 as libc::c_int) as isize)
2059 as libc::c_uchar;
2060 match flags as libc::c_int & 7 as libc::c_int {
2061 0 => return (flags as libc::c_int >> 3 as libc::c_int) as size_t,
2062 1 => {
2063 return (*(s
2064 .offset(-(core::mem::size_of::<sdshdr8>() as libc::c_ulong as isize))
2065 as *mut sdshdr8))
2066 .len as size_t;
2067 }
2068 2 => {
2069 return (*(s
2070 .offset(-(core::mem::size_of::<sdshdr16>() as libc::c_ulong as isize))
2071 as *mut sdshdr16))
2072 .len as size_t;
2073 }
2074 3 => {
2075 return (*(s
2076 .offset(-(core::mem::size_of::<sdshdr32>() as libc::c_ulong as isize))
2077 as *mut sdshdr32))
2078 .len as size_t;
2079 }
2080 4 => {
2081 return (*(s
2082 .offset(-(core::mem::size_of::<sdshdr64>() as libc::c_ulong as isize))
2083 as *mut sdshdr64))
2084 .len;
2085 }
2086 _ => {}
2087 }
2088 return 0 as libc::c_int as size_t;
2089}
2090#[inline]
2091unsafe extern "C" fn sdsavail(s: sds) -> size_t {
2092 let mut flags: libc::c_uchar = *s.offset(-(1 as libc::c_int) as isize)
2093 as libc::c_uchar;
2094 match flags as libc::c_int & 7 as libc::c_int {
2095 0 => return 0 as libc::c_int as size_t,
2096 1 => {
2097 let mut sh: *mut sdshdr8 = s
2098 .offset(-(core::mem::size_of::<sdshdr8>() as libc::c_ulong as isize))
2099 as *mut libc::c_void as *mut sdshdr8;
2100 return ((*sh).alloc as libc::c_int - (*sh).len as libc::c_int) as size_t;
2101 }
2102 2 => {
2103 let mut sh_0: *mut sdshdr16 = s
2104 .offset(-(core::mem::size_of::<sdshdr16>() as libc::c_ulong as isize))
2105 as *mut libc::c_void as *mut sdshdr16;
2106 return ((*sh_0).alloc as libc::c_int - (*sh_0).len as libc::c_int) as size_t;
2107 }
2108 3 => {
2109 let mut sh_1: *mut sdshdr32 = s
2110 .offset(-(core::mem::size_of::<sdshdr32>() as libc::c_ulong as isize))
2111 as *mut libc::c_void as *mut sdshdr32;
2112 return ((*sh_1).alloc).wrapping_sub((*sh_1).len) as size_t;
2113 }
2114 4 => {
2115 let mut sh_2: *mut sdshdr64 = s
2116 .offset(-(core::mem::size_of::<sdshdr64>() as libc::c_ulong as isize))
2117 as *mut libc::c_void as *mut sdshdr64;
2118 return ((*sh_2).alloc).wrapping_sub((*sh_2).len);
2119 }
2120 _ => {}
2121 }
2122 return 0 as libc::c_int as size_t;
2123}
2124#[inline]
2125unsafe extern "C" fn rioWrite(
2126 mut r: *mut rio,
2127 mut buf: *const libc::c_void,
2128 mut len: size_t,
2129) -> size_t {
2130 if (*r).flags & ((1 as libc::c_int) << 1 as libc::c_int) as libc::c_ulong != 0 {
2131 return 0 as libc::c_int as size_t;
2132 }
2133 while len != 0 {
2134 let mut bytes_to_write: size_t = if (*r).max_processing_chunk != 0
2135 && (*r).max_processing_chunk < len
2136 {
2137 (*r).max_processing_chunk
2138 } else {
2139 len
2140 };
2141 if ((*r).update_cksum).is_some() {
2142 ((*r).update_cksum)
2143 .expect("non-null function pointer")(r, buf, bytes_to_write);
2144 }
2145 if ((*r).write).expect("non-null function pointer")(r, buf, bytes_to_write)
2146 == 0 as libc::c_int as libc::c_ulong
2147 {
2148 (*r).flags |= ((1 as libc::c_int) << 1 as libc::c_int) as libc::c_ulong;
2149 return 0 as libc::c_int as size_t;
2150 }
2151 buf = (buf as *mut libc::c_char).offset(bytes_to_write as isize)
2152 as *const libc::c_void;
2153 len = (len as libc::c_ulong).wrapping_sub(bytes_to_write) as size_t as size_t;
2154 (*r)
2155 .processed_bytes = ((*r).processed_bytes as libc::c_ulong)
2156 .wrapping_add(bytes_to_write) as size_t as size_t;
2157 }
2158 return 1 as libc::c_int as size_t;
2159}
2160#[inline]
2161unsafe extern "C" fn atoi(mut __nptr: *const libc::c_char) -> libc::c_int {
2162 return strtol(
2163 __nptr,
2164 0 as *mut libc::c_void as *mut *mut libc::c_char,
2165 10 as libc::c_int,
2166 ) as libc::c_int;
2167}
2168#[inline]
2169unsafe extern "C" fn atoll(mut __nptr: *const libc::c_char) -> libc::c_longlong {
2170 return strtoll(
2171 __nptr,
2172 0 as *mut libc::c_void as *mut *mut libc::c_char,
2173 10 as libc::c_int,
2174 );
2175}
2176#[inline]
2177unsafe extern "C" fn stat(
2178 mut __path: *const libc::c_char,
2179 mut __statbuf: *mut stat,
2180) -> libc::c_int {
2181 return __xstat(0 as libc::c_int, __path, __statbuf);
2182}
2183#[inline]
2184unsafe extern "C" fn fstat(
2185 mut __fd: libc::c_int,
2186 mut __statbuf: *mut stat,
2187) -> libc::c_int {
2188 return __fxstat(0 as libc::c_int, __fd, __statbuf);
2189}
2190#[no_mangle]
2191pub unsafe extern "C" fn aofInfoCreate() -> *mut aofInfo {
2192 return zcalloc(core::mem::size_of::<aofInfo>() as libc::c_ulong) as *mut aofInfo;
2193}
2194#[no_mangle]
2195pub unsafe extern "C" fn aofInfoFree(mut ai: *mut aofInfo) {
2196 if !ai.is_null() {} else {
2197 _serverAssert(
2198 b"ai != NULL\0" as *const u8 as *const libc::c_char,
2199 b"aof.c\0" as *const u8 as *const libc::c_char,
2200 105 as libc::c_int,
2201 );
2202 unreachable!();
2203 };
2204 if !((*ai).file_name).is_null() {
2205 sdsfree((*ai).file_name);
2206 }
2207 zfree(ai as *mut libc::c_void);
2208}
2209#[no_mangle]
2210pub unsafe extern "C" fn aofInfoDup(mut orig: *mut aofInfo) -> *mut aofInfo {
2211 if !orig.is_null() {} else {
2212 _serverAssert(
2213 b"orig != NULL\0" as *const u8 as *const libc::c_char,
2214 b"aof.c\0" as *const u8 as *const libc::c_char,
2215 112 as libc::c_int,
2216 );
2217 unreachable!();
2218 };
2219 let mut ai: *mut aofInfo = aofInfoCreate();
2220 (*ai).file_name = sdsdup((*orig).file_name);
2221 (*ai).file_seq = (*orig).file_seq;
2222 (*ai).file_type = (*orig).file_type;
2223 return ai;
2224}
2225#[no_mangle]
2226pub unsafe extern "C" fn aofInfoFormat(mut buf: sds, mut ai: *mut aofInfo) -> sds {
2227 let mut filename_repr: sds = 0 as sds;
2228 if sdsneedsrepr((*ai).file_name) != 0 {
2229 filename_repr = sdscatrepr(
2230 sdsempty(),
2231 (*ai).file_name as *const libc::c_char,
2232 sdslen((*ai).file_name),
2233 );
2234 }
2235 let mut ret: sds = sdscatprintf(
2236 buf,
2237 b"%s %s %s %lld %s %c\n\0" as *const u8 as *const libc::c_char,
2238 b"file\0" as *const u8 as *const libc::c_char,
2239 if !filename_repr.is_null() { filename_repr } else { (*ai).file_name },
2240 b"seq\0" as *const u8 as *const libc::c_char,
2241 (*ai).file_seq,
2242 b"type\0" as *const u8 as *const libc::c_char,
2243 (*ai).file_type as libc::c_uint,
2244 );
2245 sdsfree(filename_repr);
2246 return ret;
2247}
2248#[no_mangle]
2249pub unsafe extern "C" fn aofListFree(mut item: *mut libc::c_void) {
2250 let mut ai: *mut aofInfo = item as *mut aofInfo;
2251 aofInfoFree(ai);
2252}
2253#[no_mangle]
2254pub unsafe extern "C" fn aofListDup(mut item: *mut libc::c_void) -> *mut libc::c_void {
2255 return aofInfoDup(item as *mut aofInfo) as *mut libc::c_void;
2256}
2257#[no_mangle]
2258pub unsafe extern "C" fn aofManifestCreate() -> *mut aofManifest {
2259 let mut am: *mut aofManifest = zcalloc(
2260 core::mem::size_of::<aofManifest>() as libc::c_ulong,
2261 ) as *mut aofManifest;
2262 (*am).incr_aof_list = listCreate();
2263 (*am).history_aof_list = listCreate();
2264 (*(*am).incr_aof_list)
2265 .free = Some(aofListFree as unsafe extern "C" fn(*mut libc::c_void) -> ());
2266 (*(*am).incr_aof_list)
2267 .dup = Some(
2268 aofListDup as unsafe extern "C" fn(*mut libc::c_void) -> *mut libc::c_void,
2269 );
2270 (*(*am).history_aof_list)
2271 .free = Some(aofListFree as unsafe extern "C" fn(*mut libc::c_void) -> ());
2272 (*(*am).history_aof_list)
2273 .dup = Some(
2274 aofListDup as unsafe extern "C" fn(*mut libc::c_void) -> *mut libc::c_void,
2275 );
2276 return am;
2277}
2278#[no_mangle]
2279pub unsafe extern "C" fn aofManifestFree(mut am: *mut aofManifest) {
2280 if !((*am).base_aof_info).is_null() {
2281 aofInfoFree((*am).base_aof_info);
2282 }
2283 if !((*am).incr_aof_list).is_null() {
2284 listRelease((*am).incr_aof_list);
2285 }
2286 if !((*am).history_aof_list).is_null() {
2287 listRelease((*am).history_aof_list);
2288 }
2289 zfree(am as *mut libc::c_void);
2290}
2291#[no_mangle]
2292pub unsafe extern "C" fn getAofManifestFileName() -> sds {
2293 return sdscatprintf(
2294 sdsempty(),
2295 b"%s%s\0" as *const u8 as *const libc::c_char,
2296 server.aof_filename,
2297 b".manifest\0" as *const u8 as *const libc::c_char,
2298 );
2299}
2300#[no_mangle]
2301pub unsafe extern "C" fn getTempAofManifestFileName() -> sds {
2302 return sdscatprintf(
2303 sdsempty(),
2304 b"%s%s%s\0" as *const u8 as *const libc::c_char,
2305 b"temp-\0" as *const u8 as *const libc::c_char,
2306 server.aof_filename,
2307 b".manifest\0" as *const u8 as *const libc::c_char,
2308 );
2309}
2310#[no_mangle]
2311pub unsafe extern "C" fn getAofManifestAsString(mut am: *mut aofManifest) -> sds {
2312 if !am.is_null() {} else {
2313 _serverAssert(
2314 b"am != NULL\0" as *const u8 as *const libc::c_char,
2315 b"aof.c\0" as *const u8 as *const libc::c_char,
2316 193 as libc::c_int,
2317 );
2318 unreachable!();
2319 };
2320 let mut buf: sds = sdsempty();
2321 let mut ln: *mut listNode = 0 as *mut listNode;
2322 let mut li: listIter = listIter {
2323 next: 0 as *mut listNode,
2324 direction: 0,
2325 };
2326 if !((*am).base_aof_info).is_null() {
2327 buf = aofInfoFormat(buf, (*am).base_aof_info);
2328 }
2329 listRewind((*am).history_aof_list, &mut li);
2330 loop {
2331 ln = listNext(&mut li);
2332 if ln.is_null() {
2333 break;
2334 }
2335 let mut ai: *mut aofInfo = (*ln).value as *mut aofInfo;
2336 buf = aofInfoFormat(buf, ai);
2337 }
2338 listRewind((*am).incr_aof_list, &mut li);
2339 loop {
2340 ln = listNext(&mut li);
2341 if ln.is_null() {
2342 break;
2343 }
2344 let mut ai_0: *mut aofInfo = (*ln).value as *mut aofInfo;
2345 buf = aofInfoFormat(buf, ai_0);
2346 }
2347 return buf;
2348}
2349#[no_mangle]
2350pub unsafe extern "C" fn aofLoadManifestFromDisk() {
2351 server.aof_manifest = aofManifestCreate();
2352 if dirExists(server.aof_dirname) == 0 {
2353 if !((0 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
2354 _serverLog(
2355 0 as libc::c_int,
2356 b"The AOF directory %s doesn't exist\0" as *const u8
2357 as *const libc::c_char,
2358 server.aof_dirname,
2359 );
2360 }
2361 return;
2362 }
2363 let mut am_name: sds = getAofManifestFileName();
2364 let mut am_filepath: sds = makePath(server.aof_dirname, am_name);
2365 if fileExist(am_filepath) == 0 {
2366 if !((0 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
2367 _serverLog(
2368 0 as libc::c_int,
2369 b"The AOF manifest file %s doesn't exist\0" as *const u8
2370 as *const libc::c_char,
2371 am_name,
2372 );
2373 }
2374 sdsfree(am_name);
2375 sdsfree(am_filepath);
2376 return;
2377 }
2378 let mut am: *mut aofManifest = aofLoadManifestFromFile(am_filepath);
2379 if !am.is_null() {
2380 aofManifestFreeAndUpdate(am);
2381 }
2382 sdsfree(am_name);
2383 sdsfree(am_filepath);
2384}
2385#[no_mangle]
2386pub unsafe extern "C" fn aofLoadManifestFromFile(
2387 mut am_filepath: sds,
2388) -> *mut aofManifest {
2389 let mut current_block: u64;
2390 let mut err: *const libc::c_char = 0 as *const libc::c_char;
2391 let mut maxseq: libc::c_longlong = 0 as libc::c_int as libc::c_longlong;
2392 let mut am: *mut aofManifest = aofManifestCreate();
2393 let mut fp: *mut FILE = fopen(
2394 am_filepath as *const libc::c_char,
2395 b"r\0" as *const u8 as *const libc::c_char,
2396 );
2397 if fp.is_null() {
2398 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
2399 _serverLog(
2400 3 as libc::c_int,
2401 b"Fatal error: can't open the AOF manifest file %s for reading: %s\0"
2402 as *const u8 as *const libc::c_char,
2403 am_filepath,
2404 strerror(*__errno_location()),
2405 );
2406 }
2407 exit(1 as libc::c_int);
2408 }
2409 let mut buf: [libc::c_char; 1025] = [0; 1025];
2410 let mut argv: *mut sds = 0 as *mut sds;
2411 let mut argc: libc::c_int = 0;
2412 let mut ai: *mut aofInfo = 0 as *mut aofInfo;
2413 let mut line: sds = 0 as sds;
2414 let mut linenum: libc::c_int = 0 as libc::c_int;
2415 's_51: loop {
2416 if (fgets(buf.as_mut_ptr(), 1024 as libc::c_int + 1 as libc::c_int, fp))
2417 .is_null()
2418 {
2419 if feof(fp) != 0 {
2420 if !(linenum == 0 as libc::c_int) {
2421 current_block = 2520131295878969859;
2422 break;
2423 }
2424 err = b"Found an empty AOF manifest\0" as *const u8
2425 as *const libc::c_char;
2426 current_block = 10149789293494588487;
2427 break;
2428 } else {
2429 err = b"Read AOF manifest failed\0" as *const u8 as *const libc::c_char;
2430 current_block = 10149789293494588487;
2431 break;
2432 }
2433 } else {
2434 linenum += 1;
2435 if buf[0 as libc::c_int as usize] as libc::c_int == '#' as i32 {
2436 continue;
2437 }
2438 if (strchr(buf.as_mut_ptr(), '\n' as i32)).is_null() {
2439 err = b"The AOF manifest file contains too long line\0" as *const u8
2440 as *const libc::c_char;
2441 current_block = 10149789293494588487;
2442 break;
2443 } else {
2444 line = sdstrim(
2445 sdsnew(buf.as_mut_ptr()),
2446 b" \t\r\n\0" as *const u8 as *const libc::c_char,
2447 );
2448 if sdslen(line) == 0 {
2449 err = b"Invalid AOF manifest file format\0" as *const u8
2450 as *const libc::c_char;
2451 current_block = 10149789293494588487;
2452 break;
2453 } else {
2454 argv = sdssplitargs(line as *const libc::c_char, &mut argc);
2455 if argv.is_null() || argc < 6 as libc::c_int
2456 || argc % 2 as libc::c_int != 0
2457 {
2458 err = b"Invalid AOF manifest file format\0" as *const u8
2459 as *const libc::c_char;
2460 current_block = 10149789293494588487;
2461 break;
2462 } else {
2463 ai = aofInfoCreate();
2464 let mut i: libc::c_int = 0 as libc::c_int;
2465 while i < argc {
2466 if strcasecmp(
2467 *argv.offset(i as isize) as *const libc::c_char,
2468 b"file\0" as *const u8 as *const libc::c_char,
2469 ) == 0
2470 {
2471 (*ai)
2472 .file_name = sdsnew(
2473 *argv.offset((i + 1 as libc::c_int) as isize)
2474 as *const libc::c_char,
2475 );
2476 if pathIsBaseName((*ai).file_name) == 0 {
2477 err = b"File can't be a path, just a filename\0"
2478 as *const u8 as *const libc::c_char;
2479 current_block = 10149789293494588487;
2480 break 's_51;
2481 }
2482 } else if strcasecmp(
2483 *argv.offset(i as isize) as *const libc::c_char,
2484 b"seq\0" as *const u8 as *const libc::c_char,
2485 ) == 0
2486 {
2487 (*ai)
2488 .file_seq = atoll(
2489 *argv.offset((i + 1 as libc::c_int) as isize)
2490 as *const libc::c_char,
2491 );
2492 } else if strcasecmp(
2493 *argv.offset(i as isize) as *const libc::c_char,
2494 b"type\0" as *const u8 as *const libc::c_char,
2495 ) == 0
2496 {
2497 (*ai)
2498 .file_type = *(*argv
2499 .offset((i + 1 as libc::c_int) as isize))
2500 .offset(0 as libc::c_int as isize) as aof_file_type;
2501 }
2502 i += 2 as libc::c_int;
2503 }
2504 if ((*ai).file_name).is_null() || (*ai).file_seq == 0
2505 || (*ai).file_type as u64 == 0
2506 {
2507 err = b"Invalid AOF manifest file format\0" as *const u8
2508 as *const libc::c_char;
2509 current_block = 10149789293494588487;
2510 break;
2511 } else {
2512 sdsfreesplitres(argv, argc);
2513 argv = 0 as *mut sds;
2514 if (*ai).file_type as libc::c_uint
2515 == AOF_FILE_TYPE_BASE as libc::c_int as libc::c_uint
2516 {
2517 if !((*am).base_aof_info).is_null() {
2518 err = b"Found duplicate base file information\0"
2519 as *const u8 as *const libc::c_char;
2520 current_block = 10149789293494588487;
2521 break;
2522 } else {
2523 (*am).base_aof_info = ai;
2524 (*am).curr_base_file_seq = (*ai).file_seq;
2525 }
2526 } else if (*ai).file_type as libc::c_uint
2527 == AOF_FILE_TYPE_HIST as libc::c_int as libc::c_uint
2528 {
2529 listAddNodeTail(
2530 (*am).history_aof_list,
2531 ai as *mut libc::c_void,
2532 );
2533 } else if (*ai).file_type as libc::c_uint
2534 == AOF_FILE_TYPE_INCR as libc::c_int as libc::c_uint
2535 {
2536 if (*ai).file_seq <= maxseq {
2537 err = b"Found a non-monotonic sequence number\0"
2538 as *const u8 as *const libc::c_char;
2539 current_block = 10149789293494588487;
2540 break;
2541 } else {
2542 listAddNodeTail(
2543 (*am).incr_aof_list,
2544 ai as *mut libc::c_void,
2545 );
2546 (*am).curr_incr_file_seq = (*ai).file_seq;
2547 maxseq = (*ai).file_seq;
2548 }
2549 } else {
2550 err = b"Unknown AOF file type\0" as *const u8
2551 as *const libc::c_char;
2552 current_block = 10149789293494588487;
2553 break;
2554 }
2555 sdsfree(line);
2556 line = 0 as sds;
2557 ai = 0 as *mut aofInfo;
2558 }
2559 }
2560 }
2561 }
2562 }
2563 }
2564 match current_block {
2565 10149789293494588487 => {
2566 if !argv.is_null() {
2567 sdsfreesplitres(argv, argc);
2568 }
2569 if !ai.is_null() {
2570 aofInfoFree(ai);
2571 }
2572 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
2573 _serverLog(
2574 3 as libc::c_int,
2575 b"\n*** FATAL AOF MANIFEST FILE ERROR ***\n\0" as *const u8
2576 as *const libc::c_char,
2577 );
2578 }
2579 if !line.is_null() {
2580 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
2581 _serverLog(
2582 3 as libc::c_int,
2583 b"Reading the manifest file, at line %d\n\0" as *const u8
2584 as *const libc::c_char,
2585 linenum,
2586 );
2587 }
2588 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
2589 _serverLog(
2590 3 as libc::c_int,
2591 b">>> '%s'\n\0" as *const u8 as *const libc::c_char,
2592 line,
2593 );
2594 }
2595 }
2596 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
2597 _serverLog(
2598 3 as libc::c_int,
2599 b"%s\n\0" as *const u8 as *const libc::c_char,
2600 err,
2601 );
2602 }
2603 exit(1 as libc::c_int);
2604 }
2605 _ => {
2606 fclose(fp);
2607 return am;
2608 }
2609 };
2610}
2611#[no_mangle]
2612pub unsafe extern "C" fn aofManifestDup(mut orig: *mut aofManifest) -> *mut aofManifest {
2613 if !orig.is_null() {} else {
2614 _serverAssert(
2615 b"orig != NULL\0" as *const u8 as *const libc::c_char,
2616 b"aof.c\0" as *const u8 as *const libc::c_char,
2617 392 as libc::c_int,
2618 );
2619 unreachable!();
2620 };
2621 let mut am: *mut aofManifest = zcalloc(
2622 core::mem::size_of::<aofManifest>() as libc::c_ulong,
2623 ) as *mut aofManifest;
2624 (*am).curr_base_file_seq = (*orig).curr_base_file_seq;
2625 (*am).curr_incr_file_seq = (*orig).curr_incr_file_seq;
2626 (*am).dirty = (*orig).dirty;
2627 if !((*orig).base_aof_info).is_null() {
2628 (*am).base_aof_info = aofInfoDup((*orig).base_aof_info);
2629 }
2630 (*am).incr_aof_list = listDup((*orig).incr_aof_list);
2631 (*am).history_aof_list = listDup((*orig).history_aof_list);
2632 if !((*am).incr_aof_list).is_null() {} else {
2633 _serverAssert(
2634 b"am->incr_aof_list != NULL\0" as *const u8 as *const libc::c_char,
2635 b"aof.c\0" as *const u8 as *const libc::c_char,
2636 405 as libc::c_int,
2637 );
2638 unreachable!();
2639 };
2640 if !((*am).history_aof_list).is_null() {} else {
2641 _serverAssert(
2642 b"am->history_aof_list != NULL\0" as *const u8 as *const libc::c_char,
2643 b"aof.c\0" as *const u8 as *const libc::c_char,
2644 406 as libc::c_int,
2645 );
2646 unreachable!();
2647 };
2648 return am;
2649}
2650#[no_mangle]
2651pub unsafe extern "C" fn aofManifestFreeAndUpdate(mut am: *mut aofManifest) {
2652 if !am.is_null() {} else {
2653 _serverAssert(
2654 b"am != NULL\0" as *const u8 as *const libc::c_char,
2655 b"aof.c\0" as *const u8 as *const libc::c_char,
2656 413 as libc::c_int,
2657 );
2658 unreachable!();
2659 };
2660 if !(server.aof_manifest).is_null() {
2661 aofManifestFree(server.aof_manifest);
2662 }
2663 server.aof_manifest = am;
2664}
2665#[no_mangle]
2666pub unsafe extern "C" fn getNewBaseFileNameAndMarkPreAsHistory(
2667 mut am: *mut aofManifest,
2668) -> sds {
2669 if !am.is_null() {} else {
2670 _serverAssert(
2671 b"am != NULL\0" as *const u8 as *const libc::c_char,
2672 b"aof.c\0" as *const u8 as *const libc::c_char,
2673 428 as libc::c_int,
2674 );
2675 unreachable!();
2676 };
2677 if !((*am).base_aof_info).is_null() {
2678 if (*(*am).base_aof_info).file_type as libc::c_uint
2679 == AOF_FILE_TYPE_BASE as libc::c_int as libc::c_uint
2680 {} else {
2681 _serverAssert(
2682 b"am->base_aof_info->file_type == AOF_FILE_TYPE_BASE\0" as *const u8
2683 as *const libc::c_char,
2684 b"aof.c\0" as *const u8 as *const libc::c_char,
2685 430 as libc::c_int,
2686 );
2687 unreachable!();
2688 };
2689 (*(*am).base_aof_info).file_type = AOF_FILE_TYPE_HIST;
2690 listAddNodeHead(
2691 (*am).history_aof_list,
2692 (*am).base_aof_info as *mut libc::c_void,
2693 );
2694 }
2695 let mut format_suffix: *mut libc::c_char = (if server.aof_use_rdb_preamble != 0 {
2696 b".rdb\0" as *const u8 as *const libc::c_char
2697 } else {
2698 b".aof\0" as *const u8 as *const libc::c_char
2699 }) as *mut libc::c_char;
2700 let mut ai: *mut aofInfo = aofInfoCreate();
2701 (*am).curr_base_file_seq += 1;
2702 (*ai)
2703 .file_name = sdscatprintf(
2704 sdsempty(),
2705 b"%s.%lld%s%s\0" as *const u8 as *const libc::c_char,
2706 server.aof_filename,
2707 (*am).curr_base_file_seq,
2708 b".base\0" as *const u8 as *const libc::c_char,
2709 format_suffix,
2710 );
2711 (*ai).file_seq = (*am).curr_base_file_seq;
2712 (*ai).file_type = AOF_FILE_TYPE_BASE;
2713 (*am).base_aof_info = ai;
2714 (*am).dirty = 1 as libc::c_int;
2715 return (*(*am).base_aof_info).file_name;
2716}
2717#[no_mangle]
2718pub unsafe extern "C" fn getNewIncrAofName(mut am: *mut aofManifest) -> sds {
2719 let mut ai: *mut aofInfo = aofInfoCreate();
2720 (*ai).file_type = AOF_FILE_TYPE_INCR;
2721 (*am).curr_incr_file_seq += 1;
2722 (*ai)
2723 .file_name = sdscatprintf(
2724 sdsempty(),
2725 b"%s.%lld%s%s\0" as *const u8 as *const libc::c_char,
2726 server.aof_filename,
2727 (*am).curr_incr_file_seq,
2728 b".incr\0" as *const u8 as *const libc::c_char,
2729 b".aof\0" as *const u8 as *const libc::c_char,
2730 );
2731 (*ai).file_seq = (*am).curr_incr_file_seq;
2732 listAddNodeTail((*am).incr_aof_list, ai as *mut libc::c_void);
2733 (*am).dirty = 1 as libc::c_int;
2734 return (*ai).file_name;
2735}
2736#[no_mangle]
2737pub unsafe extern "C" fn getTempIncrAofName() -> sds {
2738 return sdscatprintf(
2739 sdsempty(),
2740 b"%s%s%s\0" as *const u8 as *const libc::c_char,
2741 b"temp-\0" as *const u8 as *const libc::c_char,
2742 server.aof_filename,
2743 b".incr\0" as *const u8 as *const libc::c_char,
2744 );
2745}
2746#[no_mangle]
2747pub unsafe extern "C" fn getLastIncrAofName(mut am: *mut aofManifest) -> sds {
2748 if !am.is_null() {} else {
2749 _serverAssert(
2750 b"am != NULL\0" as *const u8 as *const libc::c_char,
2751 b"aof.c\0" as *const u8 as *const libc::c_char,
2752 474 as libc::c_int,
2753 );
2754 unreachable!();
2755 };
2756 if (*(*am).incr_aof_list).len == 0 {
2757 return getNewIncrAofName(am);
2758 }
2759 let mut lastnode: *mut listNode = listIndex(
2760 (*am).incr_aof_list,
2761 -(1 as libc::c_int) as libc::c_long,
2762 );
2763 let mut ai: *mut aofInfo = (*lastnode).value as *mut aofInfo;
2764 return (*ai).file_name;
2765}
2766#[no_mangle]
2767pub unsafe extern "C" fn markRewrittenIncrAofAsHistory(mut am: *mut aofManifest) {
2768 if !am.is_null() {} else {
2769 _serverAssert(
2770 b"am != NULL\0" as *const u8 as *const libc::c_char,
2771 b"aof.c\0" as *const u8 as *const libc::c_char,
2772 493 as libc::c_int,
2773 );
2774 unreachable!();
2775 };
2776 if (*(*am).incr_aof_list).len == 0 {
2777 return;
2778 }
2779 let mut ln: *mut listNode = 0 as *mut listNode;
2780 let mut li: listIter = listIter {
2781 next: 0 as *mut listNode,
2782 direction: 0,
2783 };
2784 listRewindTail((*am).incr_aof_list, &mut li);
2785 if server.aof_fd != -(1 as libc::c_int) {
2786 ln = listNext(&mut li);
2787 if !ln.is_null() {} else {
2788 _serverAssert(
2789 b"ln != NULL\0" as *const u8 as *const libc::c_char,
2790 b"aof.c\0" as *const u8 as *const libc::c_char,
2791 507 as libc::c_int,
2792 );
2793 unreachable!();
2794 };
2795 }
2796 loop {
2797 ln = listNext(&mut li);
2798 if ln.is_null() {
2799 break;
2800 }
2801 let mut ai: *mut aofInfo = (*ln).value as *mut aofInfo;
2802 if (*ai).file_type as libc::c_uint
2803 == AOF_FILE_TYPE_INCR as libc::c_int as libc::c_uint
2804 {} else {
2805 _serverAssert(
2806 b"ai->file_type == AOF_FILE_TYPE_INCR\0" as *const u8
2807 as *const libc::c_char,
2808 b"aof.c\0" as *const u8 as *const libc::c_char,
2809 513 as libc::c_int,
2810 );
2811 unreachable!();
2812 };
2813 let mut hai: *mut aofInfo = aofInfoDup(ai);
2814 (*hai).file_type = AOF_FILE_TYPE_HIST;
2815 listAddNodeHead((*am).history_aof_list, hai as *mut libc::c_void);
2816 listDelNode((*am).incr_aof_list, ln);
2817 }
2818 (*am).dirty = 1 as libc::c_int;
2819}
2820#[no_mangle]
2821pub unsafe extern "C" fn writeAofManifestFile(mut buf: sds) -> libc::c_int {
2822 let mut current_block: u64;
2823 let mut ret: libc::c_int = 0 as libc::c_int;
2824 let mut nwritten: ssize_t = 0;
2825 let mut len: libc::c_int = 0;
2826 let mut am_name: sds = getAofManifestFileName();
2827 let mut am_filepath: sds = makePath(server.aof_dirname, am_name);
2828 let mut tmp_am_name: sds = getTempAofManifestFileName();
2829 let mut tmp_am_filepath: sds = makePath(server.aof_dirname, tmp_am_name);
2830 let mut fd: libc::c_int = open(
2831 tmp_am_filepath as *const libc::c_char,
2832 0o1 as libc::c_int | 0o1000 as libc::c_int | 0o100 as libc::c_int,
2833 0o644 as libc::c_int,
2834 );
2835 if fd == -(1 as libc::c_int) {
2836 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
2837 _serverLog(
2838 3 as libc::c_int,
2839 b"Can't open the AOF manifest file %s: %s\0" as *const u8
2840 as *const libc::c_char,
2841 tmp_am_name,
2842 strerror(*__errno_location()),
2843 );
2844 }
2845 ret = -(1 as libc::c_int);
2846 } else {
2847 len = sdslen(buf) as libc::c_int;
2848 loop {
2849 if !(len != 0) {
2850 current_block = 6057473163062296781;
2851 break;
2852 }
2853 nwritten = write(fd, buf as *const libc::c_void, len as size_t);
2854 if nwritten < 0 as libc::c_int as libc::c_long {
2855 if *__errno_location() == 4 as libc::c_int {
2856 continue;
2857 }
2858 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
2859 _serverLog(
2860 3 as libc::c_int,
2861 b"Error trying to write the temporary AOF manifest file %s: %s\0"
2862 as *const u8 as *const libc::c_char,
2863 tmp_am_name,
2864 strerror(*__errno_location()),
2865 );
2866 }
2867 ret = -(1 as libc::c_int);
2868 current_block = 3442109089460671254;
2869 break;
2870 } else {
2871 len = (len as libc::c_long - nwritten) as libc::c_int;
2872 buf = buf.offset(nwritten as isize);
2873 }
2874 }
2875 match current_block {
2876 3442109089460671254 => {}
2877 _ => {
2878 if fdatasync(fd) == -(1 as libc::c_int) {
2879 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
2880 _serverLog(
2881 3 as libc::c_int,
2882 b"Fail to fsync the temp AOF file %s: %s.\0" as *const u8
2883 as *const libc::c_char,
2884 tmp_am_name,
2885 strerror(*__errno_location()),
2886 );
2887 }
2888 ret = -(1 as libc::c_int);
2889 } else if rename(
2890 tmp_am_filepath as *const libc::c_char,
2891 am_filepath as *const libc::c_char,
2892 ) != 0 as libc::c_int
2893 {
2894 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
2895 _serverLog(
2896 3 as libc::c_int,
2897 b"Error trying to rename the temporary AOF manifest file %s into %s: %s\0"
2898 as *const u8 as *const libc::c_char,
2899 tmp_am_name,
2900 am_name,
2901 strerror(*__errno_location()),
2902 );
2903 }
2904 ret = -(1 as libc::c_int);
2905 } else if fsyncFileDir(am_filepath as *const libc::c_char)
2906 == -(1 as libc::c_int)
2907 {
2908 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
2909 _serverLog(
2910 3 as libc::c_int,
2911 b"Fail to fsync AOF directory %s: %s.\0" as *const u8
2912 as *const libc::c_char,
2913 am_filepath,
2914 strerror(*__errno_location()),
2915 );
2916 }
2917 ret = -(1 as libc::c_int);
2918 }
2919 }
2920 }
2921 }
2922 if fd != -(1 as libc::c_int) {
2923 close(fd);
2924 }
2925 sdsfree(am_name);
2926 sdsfree(am_filepath);
2927 sdsfree(tmp_am_name);
2928 sdsfree(tmp_am_filepath);
2929 return ret;
2930}
2931#[no_mangle]
2932pub unsafe extern "C" fn persistAofManifest(mut am: *mut aofManifest) -> libc::c_int {
2933 if (*am).dirty == 0 as libc::c_int {
2934 return 0 as libc::c_int;
2935 }
2936 let mut amstr: sds = getAofManifestAsString(am);
2937 let mut ret: libc::c_int = writeAofManifestFile(amstr);
2938 sdsfree(amstr);
2939 if ret == 0 as libc::c_int {
2940 (*am).dirty = 0 as libc::c_int;
2941 }
2942 return ret;
2943}
2944#[no_mangle]
2945pub unsafe extern "C" fn aofUpgradePrepare(mut am: *mut aofManifest) {
2946 if aofFileExist(server.aof_filename) == 0 {} else {
2947 _serverAssert(
2948 b"!aofFileExist(server.aof_filename)\0" as *const u8 as *const libc::c_char,
2949 b"aof.c\0" as *const u8 as *const libc::c_char,
2950 621 as libc::c_int,
2951 );
2952 unreachable!();
2953 };
2954 if dirCreateIfMissing(server.aof_dirname) == -(1 as libc::c_int) {
2955 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
2956 _serverLog(
2957 3 as libc::c_int,
2958 b"Can't open or create append-only dir %s: %s\0" as *const u8
2959 as *const libc::c_char,
2960 server.aof_dirname,
2961 strerror(*__errno_location()),
2962 );
2963 }
2964 exit(1 as libc::c_int);
2965 }
2966 if !((*am).base_aof_info).is_null() {
2967 aofInfoFree((*am).base_aof_info);
2968 }
2969 let mut ai: *mut aofInfo = aofInfoCreate();
2970 (*ai).file_name = sdsnew(server.aof_filename);
2971 (*ai).file_seq = 1 as libc::c_int as libc::c_longlong;
2972 (*ai).file_type = AOF_FILE_TYPE_BASE;
2973 (*am).base_aof_info = ai;
2974 (*am).curr_base_file_seq = 1 as libc::c_int as libc::c_longlong;
2975 (*am).dirty = 1 as libc::c_int;
2976 if persistAofManifest(am) != 0 as libc::c_int {
2977 exit(1 as libc::c_int);
2978 }
2979 let mut aof_filepath: sds = makePath(server.aof_dirname, server.aof_filename);
2980 if rename(server.aof_filename, aof_filepath as *const libc::c_char)
2981 == -(1 as libc::c_int)
2982 {
2983 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
2984 _serverLog(
2985 3 as libc::c_int,
2986 b"Error trying to move the old AOF file %s into dir %s: %s\0"
2987 as *const u8 as *const libc::c_char,
2988 server.aof_filename,
2989 server.aof_dirname,
2990 strerror(*__errno_location()),
2991 );
2992 }
2993 sdsfree(aof_filepath);
2994 exit(1 as libc::c_int);
2995 }
2996 sdsfree(aof_filepath);
2997 if !((2 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
2998 _serverLog(
2999 2 as libc::c_int,
3000 b"Successfully migrated an old-style AOF file (%s) into the AOF directory (%s).\0"
3001 as *const u8 as *const libc::c_char,
3002 server.aof_filename,
3003 server.aof_dirname,
3004 );
3005 }
3006}
3007#[no_mangle]
3008pub unsafe extern "C" fn aofDelHistoryFiles() -> libc::c_int {
3009 if (server.aof_manifest).is_null() || server.aof_disable_auto_gc == 1 as libc::c_int
3010 || (*(*server.aof_manifest).history_aof_list).len == 0
3011 {
3012 return 0 as libc::c_int;
3013 }
3014 let mut ln: *mut listNode = 0 as *mut listNode;
3015 let mut li: listIter = listIter {
3016 next: 0 as *mut listNode,
3017 direction: 0,
3018 };
3019 listRewind((*server.aof_manifest).history_aof_list, &mut li);
3020 loop {
3021 ln = listNext(&mut li);
3022 if ln.is_null() {
3023 break;
3024 }
3025 let mut ai: *mut aofInfo = (*ln).value as *mut aofInfo;
3026 if (*ai).file_type as libc::c_uint
3027 == AOF_FILE_TYPE_HIST as libc::c_int as libc::c_uint
3028 {} else {
3029 _serverAssert(
3030 b"ai->file_type == AOF_FILE_TYPE_HIST\0" as *const u8
3031 as *const libc::c_char,
3032 b"aof.c\0" as *const u8 as *const libc::c_char,
3033 682 as libc::c_int,
3034 );
3035 unreachable!();
3036 };
3037 if !((2 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3038 _serverLog(
3039 2 as libc::c_int,
3040 b"Removing the history file %s in the background\0" as *const u8
3041 as *const libc::c_char,
3042 (*ai).file_name,
3043 );
3044 }
3045 let mut aof_filepath: sds = makePath(server.aof_dirname, (*ai).file_name);
3046 bg_unlink(aof_filepath as *const libc::c_char);
3047 sdsfree(aof_filepath);
3048 listDelNode((*server.aof_manifest).history_aof_list, ln);
3049 }
3050 (*server.aof_manifest).dirty = 1 as libc::c_int;
3051 return persistAofManifest(server.aof_manifest);
3052}
3053#[no_mangle]
3054pub unsafe extern "C" fn aofDelTempIncrAofFile() {
3055 let mut aof_filename: sds = getTempIncrAofName();
3056 let mut aof_filepath: sds = makePath(server.aof_dirname, aof_filename);
3057 if !((2 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3058 _serverLog(
3059 2 as libc::c_int,
3060 b"Removing the temp incr aof file %s in the background\0" as *const u8
3061 as *const libc::c_char,
3062 aof_filename,
3063 );
3064 }
3065 bg_unlink(aof_filepath as *const libc::c_char);
3066 sdsfree(aof_filepath);
3067 sdsfree(aof_filename);
3068}
3069#[no_mangle]
3070pub unsafe extern "C" fn aofOpenIfNeededOnServerStart() {
3071 if server.aof_state != 1 as libc::c_int {
3072 return;
3073 }
3074 if !(server.aof_manifest).is_null() {} else {
3075 _serverAssert(
3076 b"server.aof_manifest != NULL\0" as *const u8 as *const libc::c_char,
3077 b"aof.c\0" as *const u8 as *const libc::c_char,
3078 718 as libc::c_int,
3079 );
3080 unreachable!();
3081 };
3082 if server.aof_fd == -(1 as libc::c_int) {} else {
3083 _serverAssert(
3084 b"server.aof_fd == -1\0" as *const u8 as *const libc::c_char,
3085 b"aof.c\0" as *const u8 as *const libc::c_char,
3086 719 as libc::c_int,
3087 );
3088 unreachable!();
3089 };
3090 if dirCreateIfMissing(server.aof_dirname) == -(1 as libc::c_int) {
3091 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3092 _serverLog(
3093 3 as libc::c_int,
3094 b"Can't open or create append-only dir %s: %s\0" as *const u8
3095 as *const libc::c_char,
3096 server.aof_dirname,
3097 strerror(*__errno_location()),
3098 );
3099 }
3100 exit(1 as libc::c_int);
3101 }
3102 let mut incr_aof_len: size_t = (*(*server.aof_manifest).incr_aof_list).len;
3103 if ((*server.aof_manifest).base_aof_info).is_null() && incr_aof_len == 0 {
3104 let mut base_name: sds = getNewBaseFileNameAndMarkPreAsHistory(
3105 server.aof_manifest,
3106 );
3107 let mut base_filepath: sds = makePath(server.aof_dirname, base_name);
3108 if rewriteAppendOnlyFile(base_filepath) != 0 as libc::c_int {
3109 exit(1 as libc::c_int);
3110 }
3111 sdsfree(base_filepath);
3112 if !((2 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3113 _serverLog(
3114 2 as libc::c_int,
3115 b"Creating AOF base file %s on server start\0" as *const u8
3116 as *const libc::c_char,
3117 base_name,
3118 );
3119 }
3120 }
3121 let mut aof_name: sds = getLastIncrAofName(server.aof_manifest);
3122 let mut aof_filepath: sds = makePath(server.aof_dirname, aof_name);
3123 server
3124 .aof_fd = open(
3125 aof_filepath as *const libc::c_char,
3126 0o1 as libc::c_int | 0o2000 as libc::c_int | 0o100 as libc::c_int,
3127 0o644 as libc::c_int,
3128 );
3129 sdsfree(aof_filepath);
3130 if server.aof_fd == -(1 as libc::c_int) {
3131 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3132 _serverLog(
3133 3 as libc::c_int,
3134 b"Can't open the append-only file %s: %s\0" as *const u8
3135 as *const libc::c_char,
3136 aof_name,
3137 strerror(*__errno_location()),
3138 );
3139 }
3140 exit(1 as libc::c_int);
3141 }
3142 let mut ret: libc::c_int = persistAofManifest(server.aof_manifest);
3143 if ret != 0 as libc::c_int {
3144 exit(1 as libc::c_int);
3145 }
3146 server.aof_last_incr_size = getAppendOnlyFileSize(aof_name, 0 as *mut libc::c_int);
3147 if incr_aof_len != 0 {
3148 if !((2 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3149 _serverLog(
3150 2 as libc::c_int,
3151 b"Opening AOF incr file %s on server start\0" as *const u8
3152 as *const libc::c_char,
3153 aof_name,
3154 );
3155 }
3156 } else if !((2 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3157 _serverLog(
3158 2 as libc::c_int,
3159 b"Creating AOF incr file %s on server start\0" as *const u8
3160 as *const libc::c_char,
3161 aof_name,
3162 );
3163 }
3164}
3165#[no_mangle]
3166pub unsafe extern "C" fn aofFileExist(mut filename: *mut libc::c_char) -> libc::c_int {
3167 let mut file_path: sds = makePath(server.aof_dirname, filename);
3168 let mut ret: libc::c_int = fileExist(file_path);
3169 sdsfree(file_path);
3170 return ret;
3171}
3172#[no_mangle]
3173pub unsafe extern "C" fn openNewIncrAofForAppend() -> libc::c_int {
3174 let mut current_block: u64;
3175 if !(server.aof_manifest).is_null() {} else {
3176 _serverAssert(
3177 b"server.aof_manifest != NULL\0" as *const u8 as *const libc::c_char,
3178 b"aof.c\0" as *const u8 as *const libc::c_char,
3179 790 as libc::c_int,
3180 );
3181 unreachable!();
3182 };
3183 let mut newfd: libc::c_int = -(1 as libc::c_int);
3184 let mut temp_am: *mut aofManifest = 0 as *mut aofManifest;
3185 let mut new_aof_name: sds = 0 as sds;
3186 if server.aof_state == 0 as libc::c_int {
3187 return 0 as libc::c_int;
3188 }
3189 if server.aof_state == 2 as libc::c_int {
3190 new_aof_name = getTempIncrAofName();
3191 } else {
3192 temp_am = aofManifestDup(server.aof_manifest);
3193 new_aof_name = sdsdup(getNewIncrAofName(temp_am));
3194 }
3195 let mut new_aof_filepath: sds = makePath(server.aof_dirname, new_aof_name);
3196 newfd = open(
3197 new_aof_filepath as *const libc::c_char,
3198 0o1 as libc::c_int | 0o1000 as libc::c_int | 0o100 as libc::c_int,
3199 0o644 as libc::c_int,
3200 );
3201 sdsfree(new_aof_filepath);
3202 if newfd == -(1 as libc::c_int) {
3203 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3204 _serverLog(
3205 3 as libc::c_int,
3206 b"Can't open the append-only file %s: %s\0" as *const u8
3207 as *const libc::c_char,
3208 new_aof_name,
3209 strerror(*__errno_location()),
3210 );
3211 }
3212 } else {
3213 if !temp_am.is_null() {
3214 if persistAofManifest(temp_am) == -(1 as libc::c_int) {
3215 current_block = 9561948109637317291;
3216 } else {
3217 current_block = 5143058163439228106;
3218 }
3219 } else {
3220 current_block = 5143058163439228106;
3221 }
3222 match current_block {
3223 9561948109637317291 => {}
3224 _ => {
3225 if !((2 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3226 _serverLog(
3227 2 as libc::c_int,
3228 b"Creating AOF incr file %s on background rewrite\0" as *const u8
3229 as *const libc::c_char,
3230 new_aof_name,
3231 );
3232 }
3233 sdsfree(new_aof_name);
3234 if server.aof_fd != -(1 as libc::c_int) {
3235 aof_background_fsync_and_close(server.aof_fd);
3236 server.aof_fsync_offset = server.aof_current_size;
3237 server.aof_last_fsync = server.unixtime as time_t;
3238 }
3239 server.aof_fd = newfd;
3240 server.aof_last_incr_size = 0 as libc::c_int as off_t;
3241 if !temp_am.is_null() {
3242 aofManifestFreeAndUpdate(temp_am);
3243 }
3244 return 0 as libc::c_int;
3245 }
3246 }
3247 }
3248 if !new_aof_name.is_null() {
3249 sdsfree(new_aof_name);
3250 }
3251 if newfd != -(1 as libc::c_int) {
3252 close(newfd);
3253 }
3254 if !temp_am.is_null() {
3255 aofManifestFree(temp_am);
3256 }
3257 return -(1 as libc::c_int);
3258}
3259#[no_mangle]
3260pub unsafe extern "C" fn aofRewriteLimited() -> libc::c_int {
3261 static mut next_delay_minutes: libc::c_int = 0 as libc::c_int;
3262 static mut next_rewrite_time: time_t = 0 as libc::c_int as time_t;
3263 if server.stat_aofrw_consecutive_failures < 3 as libc::c_int as libc::c_longlong {
3264 next_delay_minutes = 0 as libc::c_int;
3265 next_rewrite_time = 0 as libc::c_int as time_t;
3266 return 0 as libc::c_int;
3267 }
3268 if next_rewrite_time != 0 as libc::c_int as libc::c_long {
3269 if (server.unixtime as libc::c_long) < next_rewrite_time {
3270 return 1 as libc::c_int
3271 } else {
3272 next_rewrite_time = 0 as libc::c_int as time_t;
3273 return 0 as libc::c_int;
3274 }
3275 }
3276 next_delay_minutes = if next_delay_minutes == 0 as libc::c_int {
3277 1 as libc::c_int
3278 } else {
3279 next_delay_minutes * 2 as libc::c_int
3280 };
3281 if next_delay_minutes > 60 as libc::c_int {
3282 next_delay_minutes = 60 as libc::c_int;
3283 }
3284 next_rewrite_time = (server.unixtime + next_delay_minutes * 60 as libc::c_int)
3285 as time_t;
3286 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3287 _serverLog(
3288 3 as libc::c_int,
3289 b"Background AOF rewrite has repeatedly failed and triggered the limit, will retry in %d minutes\0"
3290 as *const u8 as *const libc::c_char,
3291 next_delay_minutes,
3292 );
3293 }
3294 return 1 as libc::c_int;
3295}
3296#[no_mangle]
3297pub unsafe extern "C" fn aofFsyncInProgress() -> libc::c_int {
3298 return (bioPendingJobsOfType(1 as libc::c_int)
3299 != 0 as libc::c_int as libc::c_ulonglong) as libc::c_int;
3300}
3301#[no_mangle]
3302pub unsafe extern "C" fn aof_background_fsync(mut fd: libc::c_int) {
3303 bioCreateFsyncJob(fd);
3304}
3305#[no_mangle]
3306pub unsafe extern "C" fn aof_background_fsync_and_close(mut fd: libc::c_int) {
3307 bioCreateCloseJob(fd, 1 as libc::c_int);
3308}
3309#[no_mangle]
3310pub unsafe extern "C" fn killAppendOnlyChild() {
3311 let mut statloc: libc::c_int = 0;
3312 if server.child_type != 2 as libc::c_int {
3313 return;
3314 }
3315 if !((2 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3316 _serverLog(
3317 2 as libc::c_int,
3318 b"Killing running AOF rewrite child: %ld\0" as *const u8
3319 as *const libc::c_char,
3320 server.child_pid as libc::c_long,
3321 );
3322 }
3323 if kill(server.child_pid, 10 as libc::c_int) != -(1 as libc::c_int) {
3324 while waitpid(-(1 as libc::c_int), &mut statloc, 0 as libc::c_int)
3325 != server.child_pid
3326 {}
3327 }
3328 aofRemoveTempFile(server.child_pid);
3329 resetChildState();
3330 server.aof_rewrite_time_start = -(1 as libc::c_int) as time_t;
3331}
3332#[no_mangle]
3333pub unsafe extern "C" fn stopAppendOnly() {
3334 if server.aof_state != 0 as libc::c_int {} else {
3335 _serverAssert(
3336 b"server.aof_state != AOF_OFF\0" as *const u8 as *const libc::c_char,
3337 b"aof.c\0" as *const u8 as *const libc::c_char,
3338 950 as libc::c_int,
3339 );
3340 unreachable!();
3341 };
3342 flushAppendOnlyFile(1 as libc::c_int);
3343 if fdatasync(server.aof_fd) == -(1 as libc::c_int) {
3344 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3345 _serverLog(
3346 3 as libc::c_int,
3347 b"Fail to fsync the AOF file: %s\0" as *const u8 as *const libc::c_char,
3348 strerror(*__errno_location()),
3349 );
3350 }
3351 } else {
3352 server.aof_fsync_offset = server.aof_current_size;
3353 server.aof_last_fsync = server.unixtime as time_t;
3354 }
3355 close(server.aof_fd);
3356 server.aof_fd = -(1 as libc::c_int);
3357 server.aof_selected_db = -(1 as libc::c_int);
3358 server.aof_state = 0 as libc::c_int;
3359 server.aof_rewrite_scheduled = 0 as libc::c_int;
3360 server.aof_last_incr_size = 0 as libc::c_int as off_t;
3361 killAppendOnlyChild();
3362 sdsfree(server.aof_buf);
3363 server.aof_buf = sdsempty();
3364}
3365#[no_mangle]
3366pub unsafe extern "C" fn startAppendOnly() -> libc::c_int {
3367 if server.aof_state == 0 as libc::c_int {} else {
3368 _serverAssert(
3369 b"server.aof_state == AOF_OFF\0" as *const u8 as *const libc::c_char,
3370 b"aof.c\0" as *const u8 as *const libc::c_char,
3371 973 as libc::c_int,
3372 );
3373 unreachable!();
3374 };
3375 server.aof_state = 2 as libc::c_int;
3376 if hasActiveChildProcess() != 0 && server.child_type != 2 as libc::c_int {
3377 server.aof_rewrite_scheduled = 1 as libc::c_int;
3378 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3379 _serverLog(
3380 3 as libc::c_int,
3381 b"AOF was enabled but there is already another background operation. An AOF background was scheduled to start when possible.\0"
3382 as *const u8 as *const libc::c_char,
3383 );
3384 }
3385 } else if server.in_exec != 0 {
3386 server.aof_rewrite_scheduled = 1 as libc::c_int;
3387 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3388 _serverLog(
3389 3 as libc::c_int,
3390 b"AOF was enabled during a transaction. An AOF background was scheduled to start when possible.\0"
3391 as *const u8 as *const libc::c_char,
3392 );
3393 }
3394 } else {
3395 if server.child_type == 2 as libc::c_int {
3396 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3397 _serverLog(
3398 3 as libc::c_int,
3399 b"AOF was enabled but there is already an AOF rewriting in background. Stopping background AOF and starting a rewrite now.\0"
3400 as *const u8 as *const libc::c_char,
3401 );
3402 }
3403 killAppendOnlyChild();
3404 }
3405 if rewriteAppendOnlyFileBackground() == -(1 as libc::c_int) {
3406 server.aof_state = 0 as libc::c_int;
3407 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3408 _serverLog(
3409 3 as libc::c_int,
3410 b"Redis needs to enable the AOF but can't trigger a background AOF rewrite operation. Check the above logs for more info about the error.\0"
3411 as *const u8 as *const libc::c_char,
3412 );
3413 }
3414 return -(1 as libc::c_int);
3415 }
3416 }
3417 server.aof_last_fsync = server.unixtime as time_t;
3418 let mut aof_bio_fsync_status: libc::c_int = 0;
3419 aof_bio_fsync_status = core::intrinsics::atomic_load_relaxed(
3420 &mut server.aof_bio_fsync_status,
3421 );
3422 if aof_bio_fsync_status == -(1 as libc::c_int) {
3423 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3424 _serverLog(
3425 3 as libc::c_int,
3426 b"AOF reopen, just ignore the AOF fsync error in bio job\0" as *const u8
3427 as *const libc::c_char,
3428 );
3429 }
3430 core::intrinsics::atomic_store_relaxed(
3431 &mut server.aof_bio_fsync_status,
3432 0 as libc::c_int,
3433 );
3434 }
3435 if server.aof_last_write_status == -(1 as libc::c_int) {
3436 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3437 _serverLog(
3438 3 as libc::c_int,
3439 b"AOF reopen, just ignore the last error.\0" as *const u8
3440 as *const libc::c_char,
3441 );
3442 }
3443 server.aof_last_write_status = 0 as libc::c_int;
3444 }
3445 return 0 as libc::c_int;
3446}
3447#[no_mangle]
3448pub unsafe extern "C" fn aofWrite(
3449 mut fd: libc::c_int,
3450 mut buf: *const libc::c_char,
3451 mut len: size_t,
3452) -> ssize_t {
3453 let mut nwritten: ssize_t = 0 as libc::c_int as ssize_t;
3454 let mut totwritten: ssize_t = 0 as libc::c_int as ssize_t;
3455 while len != 0 {
3456 nwritten = write(fd, buf as *const libc::c_void, len);
3457 if nwritten < 0 as libc::c_int as libc::c_long {
3458 if *__errno_location() == 4 as libc::c_int {
3459 continue;
3460 }
3461 return if totwritten != 0 {
3462 totwritten
3463 } else {
3464 -(1 as libc::c_int) as libc::c_long
3465 };
3466 } else {
3467 len = (len as libc::c_ulong).wrapping_sub(nwritten as libc::c_ulong)
3468 as size_t as size_t;
3469 buf = buf.offset(nwritten as isize);
3470 totwritten += nwritten;
3471 }
3472 }
3473 return totwritten;
3474}
3475#[no_mangle]
3476pub unsafe extern "C" fn flushAppendOnlyFile(mut force: libc::c_int) {
3477 let mut nwritten: ssize_t = 0;
3478 let mut sync_in_progress: libc::c_int = 0 as libc::c_int;
3479 let mut latency: mstime_t = 0;
3480 if sdslen(server.aof_buf) == 0 as libc::c_int as libc::c_ulong {
3481 if !(server.aof_fsync == 2 as libc::c_int
3482 && server.aof_fsync_offset != server.aof_current_size
3483 && server.unixtime as libc::c_long > server.aof_last_fsync
3484 && {
3485 sync_in_progress = aofFsyncInProgress();
3486 sync_in_progress == 0
3487 })
3488 {
3489 return;
3490 }
3491 } else {
3492 if server.aof_fsync == 2 as libc::c_int {
3493 sync_in_progress = aofFsyncInProgress();
3494 }
3495 if server.aof_fsync == 2 as libc::c_int && force == 0 {
3496 if sync_in_progress != 0 {
3497 if server.aof_flush_postponed_start == 0 as libc::c_int as libc::c_long {
3498 server.aof_flush_postponed_start = server.unixtime as time_t;
3499 return;
3500 } else {
3501 if server.unixtime as libc::c_long - server.aof_flush_postponed_start
3502 < 2 as libc::c_int as libc::c_long
3503 {
3504 return;
3505 }
3506 }
3507 server.aof_delayed_fsync = (server.aof_delayed_fsync).wrapping_add(1);
3508 if !((2 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3509 _serverLog(
3510 2 as libc::c_int,
3511 b"Asynchronous AOF fsync is taking too long (disk is busy?). Writing the AOF buffer without waiting for fsync to complete, this may slow down Redis.\0"
3512 as *const u8 as *const libc::c_char,
3513 );
3514 }
3515 }
3516 }
3517 if server.aof_flush_sleep != 0 && sdslen(server.aof_buf) != 0 {
3518 usleep(server.aof_flush_sleep as __useconds_t);
3519 }
3520 if server.latency_monitor_threshold != 0 {
3521 latency = mstime();
3522 } else {
3523 latency = 0 as libc::c_int as mstime_t;
3524 }
3525 nwritten = aofWrite(
3526 server.aof_fd,
3527 server.aof_buf as *const libc::c_char,
3528 sdslen(server.aof_buf),
3529 );
3530 if server.latency_monitor_threshold != 0 {
3531 latency = mstime() - latency;
3532 }
3533 if sync_in_progress != 0 {
3534 if server.latency_monitor_threshold != 0
3535 && latency >= server.latency_monitor_threshold
3536 {
3537 latencyAddSample(
3538 b"aof-write-pending-fsync\0" as *const u8 as *const libc::c_char,
3539 latency,
3540 );
3541 }
3542 } else if hasActiveChildProcess() != 0 {
3543 if server.latency_monitor_threshold != 0
3544 && latency >= server.latency_monitor_threshold
3545 {
3546 latencyAddSample(
3547 b"aof-write-active-child\0" as *const u8 as *const libc::c_char,
3548 latency,
3549 );
3550 }
3551 } else if server.latency_monitor_threshold != 0
3552 && latency >= server.latency_monitor_threshold
3553 {
3554 latencyAddSample(
3555 b"aof-write-alone\0" as *const u8 as *const libc::c_char,
3556 latency,
3557 );
3558 }
3559 if server.latency_monitor_threshold != 0
3560 && latency >= server.latency_monitor_threshold
3561 {
3562 latencyAddSample(
3563 b"aof-write\0" as *const u8 as *const libc::c_char,
3564 latency,
3565 );
3566 }
3567 server.aof_flush_postponed_start = 0 as libc::c_int as time_t;
3568 if nwritten != sdslen(server.aof_buf) as ssize_t {
3569 static mut last_write_error_log: time_t = 0 as libc::c_int as time_t;
3570 let mut can_log: libc::c_int = 0 as libc::c_int;
3571 if server.unixtime as libc::c_long - last_write_error_log
3572 > 30 as libc::c_int as libc::c_long
3573 {
3574 can_log = 1 as libc::c_int;
3575 last_write_error_log = server.unixtime as time_t;
3576 }
3577 if nwritten == -(1 as libc::c_int) as libc::c_long {
3578 if can_log != 0 {
3579 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3580 _serverLog(
3581 3 as libc::c_int,
3582 b"Error writing to the AOF file: %s\0" as *const u8
3583 as *const libc::c_char,
3584 strerror(*__errno_location()),
3585 );
3586 }
3587 }
3588 server.aof_last_write_errno = *__errno_location();
3589 } else {
3590 if can_log != 0 {
3591 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3592 _serverLog(
3593 3 as libc::c_int,
3594 b"Short write while writing to the AOF file: (nwritten=%lld, expected=%lld)\0"
3595 as *const u8 as *const libc::c_char,
3596 nwritten as libc::c_longlong,
3597 sdslen(server.aof_buf) as libc::c_longlong,
3598 );
3599 }
3600 }
3601 if ftruncate(server.aof_fd, server.aof_last_incr_size)
3602 == -(1 as libc::c_int)
3603 {
3604 if can_log != 0 {
3605 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity)
3606 {
3607 _serverLog(
3608 3 as libc::c_int,
3609 b"Could not remove short write from the append-only file. Redis may refuse to load the AOF the next time it starts. ftruncate: %s\0"
3610 as *const u8 as *const libc::c_char,
3611 strerror(*__errno_location()),
3612 );
3613 }
3614 }
3615 } else {
3616 nwritten = -(1 as libc::c_int) as ssize_t;
3617 }
3618 server.aof_last_write_errno = 28 as libc::c_int;
3619 }
3620 if server.aof_fsync == 1 as libc::c_int {
3621 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3622 _serverLog(
3623 3 as libc::c_int,
3624 b"Can't recover from AOF write error when the AOF fsync policy is 'always'. Exiting...\0"
3625 as *const u8 as *const libc::c_char,
3626 );
3627 }
3628 exit(1 as libc::c_int);
3629 } else {
3630 server.aof_last_write_status = -(1 as libc::c_int);
3631 if nwritten > 0 as libc::c_int as libc::c_long {
3632 server.aof_current_size += nwritten;
3633 server.aof_last_incr_size += nwritten;
3634 sdsrange(server.aof_buf, nwritten, -(1 as libc::c_int) as ssize_t);
3635 }
3636 return;
3637 }
3638 } else {
3639 if server.aof_last_write_status == -(1 as libc::c_int) {
3640 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3641 _serverLog(
3642 3 as libc::c_int,
3643 b"AOF write error looks solved, Redis can write again.\0"
3644 as *const u8 as *const libc::c_char,
3645 );
3646 }
3647 server.aof_last_write_status = 0 as libc::c_int;
3648 }
3649 }
3650 server.aof_current_size += nwritten;
3651 server.aof_last_incr_size += nwritten;
3652 if (sdslen(server.aof_buf)).wrapping_add(sdsavail(server.aof_buf))
3653 < 4000 as libc::c_int as libc::c_ulong
3654 {
3655 sdsclear(server.aof_buf);
3656 } else {
3657 sdsfree(server.aof_buf);
3658 server.aof_buf = sdsempty();
3659 }
3660 }
3661 if server.aof_no_fsync_on_rewrite != 0 && hasActiveChildProcess() != 0 {
3662 return;
3663 }
3664 if server.aof_fsync == 1 as libc::c_int {
3665 if server.latency_monitor_threshold != 0 {
3666 latency = mstime();
3667 } else {
3668 latency = 0 as libc::c_int as mstime_t;
3669 }
3670 if fdatasync(server.aof_fd) == -(1 as libc::c_int) {
3671 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3672 _serverLog(
3673 3 as libc::c_int,
3674 b"Can't persist AOF for fsync error when the AOF fsync policy is 'always': %s. Exiting...\0"
3675 as *const u8 as *const libc::c_char,
3676 strerror(*__errno_location()),
3677 );
3678 }
3679 exit(1 as libc::c_int);
3680 }
3681 if server.latency_monitor_threshold != 0 {
3682 latency = mstime() - latency;
3683 }
3684 if server.latency_monitor_threshold != 0
3685 && latency >= server.latency_monitor_threshold
3686 {
3687 latencyAddSample(
3688 b"aof-fsync-always\0" as *const u8 as *const libc::c_char,
3689 latency,
3690 );
3691 }
3692 server.aof_fsync_offset = server.aof_current_size;
3693 server.aof_last_fsync = server.unixtime as time_t;
3694 } else if server.aof_fsync == 2 as libc::c_int
3695 && server.unixtime as libc::c_long > server.aof_last_fsync
3696 {
3697 if sync_in_progress == 0 {
3698 aof_background_fsync(server.aof_fd);
3699 server.aof_fsync_offset = server.aof_current_size;
3700 }
3701 server.aof_last_fsync = server.unixtime as time_t;
3702 }
3703}
3704#[no_mangle]
3705pub unsafe extern "C" fn catAppendOnlyGenericCommand(
3706 mut dst: sds,
3707 mut argc: libc::c_int,
3708 mut argv: *mut *mut robj,
3709) -> sds {
3710 let mut buf: [libc::c_char; 32] = [0; 32];
3711 let mut len: libc::c_int = 0;
3712 let mut j: libc::c_int = 0;
3713 let mut o: *mut robj = 0 as *mut robj;
3714 buf[0 as libc::c_int as usize] = '*' as i32 as libc::c_char;
3715 len = 1 as libc::c_int
3716 + ll2string(
3717 buf.as_mut_ptr().offset(1 as libc::c_int as isize),
3718 (core::mem::size_of::<[libc::c_char; 32]>() as libc::c_ulong)
3719 .wrapping_sub(1 as libc::c_int as libc::c_ulong),
3720 argc as libc::c_longlong,
3721 );
3722 let fresh0 = len;
3723 len = len + 1;
3724 buf[fresh0 as usize] = '\r' as i32 as libc::c_char;
3725 let fresh1 = len;
3726 len = len + 1;
3727 buf[fresh1 as usize] = '\n' as i32 as libc::c_char;
3728 dst = sdscatlen(dst, buf.as_mut_ptr() as *const libc::c_void, len as size_t);
3729 j = 0 as libc::c_int;
3730 while j < argc {
3731 o = getDecodedObject(*argv.offset(j as isize));
3732 buf[0 as libc::c_int as usize] = '$' as i32 as libc::c_char;
3733 len = 1 as libc::c_int
3734 + ll2string(
3735 buf.as_mut_ptr().offset(1 as libc::c_int as isize),
3736 (core::mem::size_of::<[libc::c_char; 32]>() as libc::c_ulong)
3737 .wrapping_sub(1 as libc::c_int as libc::c_ulong),
3738 sdslen((*o).ptr as sds) as libc::c_longlong,
3739 );
3740 let fresh2 = len;
3741 len = len + 1;
3742 buf[fresh2 as usize] = '\r' as i32 as libc::c_char;
3743 let fresh3 = len;
3744 len = len + 1;
3745 buf[fresh3 as usize] = '\n' as i32 as libc::c_char;
3746 dst = sdscatlen(dst, buf.as_mut_ptr() as *const libc::c_void, len as size_t);
3747 dst = sdscatlen(dst, (*o).ptr, sdslen((*o).ptr as sds));
3748 dst = sdscatlen(
3749 dst,
3750 b"\r\n\0" as *const u8 as *const libc::c_char as *const libc::c_void,
3751 2 as libc::c_int as size_t,
3752 );
3753 decrRefCount(o);
3754 j += 1;
3755 }
3756 return dst;
3757}
3758#[no_mangle]
3759pub unsafe extern "C" fn genAofTimestampAnnotationIfNeeded(
3760 mut force: libc::c_int,
3761) -> sds {
3762 let mut ts: sds = 0 as sds;
3763 if force != 0 || server.aof_cur_timestamp < server.unixtime as libc::c_long {
3764 server
3765 .aof_cur_timestamp = if force != 0 {
3766 time(0 as *mut time_t)
3767 } else {
3768 server.unixtime as libc::c_long
3769 };
3770 ts = sdscatfmt(
3771 sdsempty(),
3772 b"#TS:%I\r\n\0" as *const u8 as *const libc::c_char,
3773 server.aof_cur_timestamp,
3774 );
3775 if sdslen(ts) <= 1024 as libc::c_int as libc::c_ulong {} else {
3776 _serverAssert(
3777 b"sdslen(ts) <= AOF_ANNOTATION_LINE_MAX_LEN\0" as *const u8
3778 as *const libc::c_char,
3779 b"aof.c\0" as *const u8 as *const libc::c_char,
3780 1293 as libc::c_int,
3781 );
3782 unreachable!();
3783 };
3784 }
3785 return ts;
3786}
3787#[no_mangle]
3788pub unsafe extern "C" fn feedAppendOnlyFile(
3789 mut dictid: libc::c_int,
3790 mut argv: *mut *mut robj,
3791 mut argc: libc::c_int,
3792) {
3793 let mut buf: sds = sdsempty();
3794 if dictid >= 0 as libc::c_int && dictid < server.dbnum {} else {
3795 _serverAssert(
3796 b"dictid >= 0 && dictid < server.dbnum\0" as *const u8
3797 as *const libc::c_char,
3798 b"aof.c\0" as *const u8 as *const libc::c_char,
3799 1301 as libc::c_int,
3800 );
3801 unreachable!();
3802 };
3803 if server.aof_timestamp_enabled != 0 {
3804 let mut ts: sds = genAofTimestampAnnotationIfNeeded(0 as libc::c_int);
3805 if !ts.is_null() {
3806 buf = sdscatsds(buf, ts);
3807 sdsfree(ts);
3808 }
3809 }
3810 if dictid != server.aof_selected_db {
3811 let mut seldb: [libc::c_char; 64] = [0; 64];
3812 snprintf(
3813 seldb.as_mut_ptr(),
3814 core::mem::size_of::<[libc::c_char; 64]>() as libc::c_ulong,
3815 b"%d\0" as *const u8 as *const libc::c_char,
3816 dictid,
3817 );
3818 buf = sdscatprintf(
3819 buf,
3820 b"*2\r\n$6\r\nSELECT\r\n$%lu\r\n%s\r\n\0" as *const u8
3821 as *const libc::c_char,
3822 strlen(seldb.as_mut_ptr()),
3823 seldb.as_mut_ptr(),
3824 );
3825 server.aof_selected_db = dictid;
3826 }
3827 buf = catAppendOnlyGenericCommand(buf, argc, argv);
3828 if server.aof_state == 1 as libc::c_int
3829 || server.aof_state == 2 as libc::c_int && server.child_type == 2 as libc::c_int
3830 {
3831 server
3832 .aof_buf = sdscatlen(
3833 server.aof_buf,
3834 buf as *const libc::c_void,
3835 sdslen(buf),
3836 );
3837 }
3838 sdsfree(buf);
3839}
3840#[no_mangle]
3841pub unsafe extern "C" fn createAOFClient() -> *mut client {
3842 let mut c: *mut client = createClient(0 as *mut connection);
3843 (*c).id = 18446744073709551615 as libc::c_ulong;
3844 (*c).flags = ((1 as libc::c_ulonglong) << 41 as libc::c_int) as uint64_t;
3845 (*c).replstate = 6 as libc::c_int;
3846 return c;
3847}
3848#[no_mangle]
3849pub unsafe extern "C" fn loadSingleAppendOnlyFile(
3850 mut filename: *mut libc::c_char,
3851) -> libc::c_int {
3852 let mut current_block: u64;
3853 let mut fakeClient: *mut client = 0 as *mut client;
3854 let mut sb: stat = stat {
3855 st_dev: 0,
3856 st_ino: 0,
3857 st_mode: 0,
3858 st_nlink: 0,
3859 st_uid: 0,
3860 st_gid: 0,
3861 st_rdev: 0,
3862 __pad1: 0,
3863 st_size: 0,
3864 st_blksize: 0,
3865 __pad2: 0,
3866 st_blocks: 0,
3867 st_atim: timespec { tv_sec: 0, tv_nsec: 0 },
3868 st_mtim: timespec { tv_sec: 0, tv_nsec: 0 },
3869 st_ctim: timespec { tv_sec: 0, tv_nsec: 0 },
3870 __glibc_reserved: [0; 2],
3871 };
3872 let mut old_aof_state: libc::c_int = server.aof_state;
3873 let mut loops: libc::c_long = 0 as libc::c_int as libc::c_long;
3874 let mut valid_up_to: off_t = 0 as libc::c_int as off_t;
3875 let mut valid_before_multi: off_t = 0 as libc::c_int as off_t;
3876 let mut last_progress_report_size: off_t = 0 as libc::c_int as off_t;
3877 let mut ret: libc::c_int = 0 as libc::c_int;
3878 let mut aof_filepath: sds = makePath(server.aof_dirname, filename);
3879 let mut fp: *mut FILE = fopen(
3880 aof_filepath as *const libc::c_char,
3881 b"r\0" as *const u8 as *const libc::c_char,
3882 );
3883 if fp.is_null() {
3884 let mut en: libc::c_int = *__errno_location();
3885 if stat(aof_filepath as *const libc::c_char, &mut sb) == 0 as libc::c_int
3886 || *__errno_location() != 2 as libc::c_int
3887 {
3888 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3889 _serverLog(
3890 3 as libc::c_int,
3891 b"Fatal error: can't open the append log file %s for reading: %s\0"
3892 as *const u8 as *const libc::c_char,
3893 filename,
3894 strerror(en),
3895 );
3896 }
3897 sdsfree(aof_filepath);
3898 return 3 as libc::c_int;
3899 } else {
3900 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3901 _serverLog(
3902 3 as libc::c_int,
3903 b"The append log file %s doesn't exist: %s\0" as *const u8
3904 as *const libc::c_char,
3905 filename,
3906 strerror(*__errno_location()),
3907 );
3908 }
3909 sdsfree(aof_filepath);
3910 return 1 as libc::c_int;
3911 }
3912 }
3913 if !fp.is_null() && fstat(fileno(fp), &mut sb) != -(1 as libc::c_int)
3914 && sb.st_size == 0 as libc::c_int as libc::c_long
3915 {
3916 fclose(fp);
3917 sdsfree(aof_filepath);
3918 return 2 as libc::c_int;
3919 }
3920 server.aof_state = 0 as libc::c_int;
3921 let mut old_client: *mut client = server.current_client;
3922 server.current_client = createAOFClient();
3923 fakeClient = server.current_client;
3924 let mut sig: [libc::c_char; 5] = [0; 5];
3925 if fread(
3926 sig.as_mut_ptr() as *mut libc::c_void,
3927 1 as libc::c_int as libc::c_ulong,
3928 5 as libc::c_int as libc::c_ulong,
3929 fp,
3930 ) != 5 as libc::c_int as libc::c_ulong
3931 || memcmp(
3932 sig.as_mut_ptr() as *const libc::c_void,
3933 b"REDIS\0" as *const u8 as *const libc::c_char as *const libc::c_void,
3934 5 as libc::c_int as libc::c_ulong,
3935 ) != 0 as libc::c_int
3936 {
3937 if fseek(fp, 0 as libc::c_int as libc::c_long, 0 as libc::c_int)
3938 == -(1 as libc::c_int)
3939 {
3940 current_block = 8304579957269340979;
3941 } else {
3942 current_block = 2516253395664191498;
3943 }
3944 } else {
3945 let mut rdb: rio = rio {
3946 read: None,
3947 write: None,
3948 tell: None,
3949 flush: None,
3950 update_cksum: None,
3951 cksum: 0,
3952 flags: 0,
3953 processed_bytes: 0,
3954 max_processing_chunk: 0,
3955 io: C2RustUnnamed {
3956 buffer: C2RustUnnamed_3 {
3957 ptr: 0 as *mut libc::c_char,
3958 pos: 0,
3959 },
3960 },
3961 };
3962 let mut old_style: libc::c_int = (strcmp(filename, server.aof_filename) == 0)
3963 as libc::c_int;
3964 if old_style != 0 {
3965 if !((2 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3966 _serverLog(
3967 2 as libc::c_int,
3968 b"Reading RDB preamble from AOF file...\0" as *const u8
3969 as *const libc::c_char,
3970 );
3971 }
3972 } else if !((2 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3973 _serverLog(
3974 2 as libc::c_int,
3975 b"Reading RDB base file on AOF loading...\0" as *const u8
3976 as *const libc::c_char,
3977 );
3978 }
3979 if fseek(fp, 0 as libc::c_int as libc::c_long, 0 as libc::c_int)
3980 == -(1 as libc::c_int)
3981 {
3982 current_block = 8304579957269340979;
3983 } else {
3984 rioInitWithFile(&mut rdb, fp);
3985 if rdbLoadRio(
3986 &mut rdb,
3987 (1 as libc::c_int) << 0 as libc::c_int,
3988 0 as *mut rdbSaveInfo,
3989 ) != 0 as libc::c_int
3990 {
3991 if old_style != 0 {
3992 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
3993 _serverLog(
3994 3 as libc::c_int,
3995 b"Error reading the RDB preamble of the AOF file %s, AOF loading aborted\0"
3996 as *const u8 as *const libc::c_char,
3997 filename,
3998 );
3999 }
4000 } else if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity)
4001 {
4002 _serverLog(
4003 3 as libc::c_int,
4004 b"Error reading the RDB base file %s, AOF loading aborted\0"
4005 as *const u8 as *const libc::c_char,
4006 filename,
4007 );
4008 }
4009 current_block = 8304579957269340979;
4010 } else {
4011 loadingAbsProgress(ftello(fp));
4012 last_progress_report_size = ftello(fp);
4013 if old_style != 0 {
4014 if !((2 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
4015 _serverLog(
4016 2 as libc::c_int,
4017 b"Reading the remaining AOF tail...\0" as *const u8
4018 as *const libc::c_char,
4019 );
4020 }
4021 }
4022 current_block = 2516253395664191498;
4023 }
4024 }
4025 }
4026 '_readerr: loop {
4027 match current_block {
4028 2516253395664191498 => {
4029 let mut argc: libc::c_int = 0;
4030 let mut j: libc::c_int = 0;
4031 let mut len: libc::c_ulong = 0;
4032 let mut argv: *mut *mut robj = 0 as *mut *mut robj;
4033 let mut buf: [libc::c_char; 1024] = [0; 1024];
4034 let mut argsds: sds = 0 as *mut libc::c_char;
4035 let mut cmd: *mut redisCommand = 0 as *mut redisCommand;
4036 let fresh4 = loops;
4037 loops = loops + 1;
4038 if fresh4 % 1024 as libc::c_int as libc::c_long == 0 {
4039 let mut progress_delta: off_t = ftello(fp)
4040 - last_progress_report_size;
4041 loadingIncrProgress(progress_delta);
4042 last_progress_report_size += progress_delta;
4043 processEventsWhileBlocked();
4044 processModuleLoadingProgressEvent(1 as libc::c_int);
4045 }
4046 if (fgets(
4047 buf.as_mut_ptr(),
4048 core::mem::size_of::<[libc::c_char; 1024]>() as libc::c_ulong
4049 as libc::c_int,
4050 fp,
4051 ))
4052 .is_null()
4053 {
4054 if !(feof(fp) != 0) {
4055 current_block = 8304579957269340979;
4056 continue;
4057 }
4058 if (*fakeClient).flags
4059 & ((1 as libc::c_int) << 3 as libc::c_int) as libc::c_ulong != 0
4060 {
4061 current_block = 5265702136860997526;
4062 break;
4063 } else {
4064 current_block = 852400248170036051;
4065 break;
4066 }
4067 } else {
4068 if buf[0 as libc::c_int as usize] as libc::c_int == '#' as i32 {
4069 current_block = 2516253395664191498;
4070 continue;
4071 }
4072 if buf[0 as libc::c_int as usize] as libc::c_int != '*' as i32 {
4073 current_block = 9904301676592638684;
4074 break;
4075 }
4076 if buf[1 as libc::c_int as usize] as libc::c_int == '\0' as i32 {
4077 current_block = 8304579957269340979;
4078 continue;
4079 }
4080 argc = atoi(buf.as_mut_ptr().offset(1 as libc::c_int as isize));
4081 if argc < 1 as libc::c_int {
4082 current_block = 9904301676592638684;
4083 break;
4084 }
4085 if argc as size_t
4086 > (18446744073709551615 as libc::c_ulong)
4087 .wrapping_div(
4088 core::mem::size_of::<*mut robj>() as libc::c_ulong,
4089 )
4090 {
4091 current_block = 9904301676592638684;
4092 break;
4093 }
4094 argv = zmalloc(
4095 (core::mem::size_of::<*mut robj>() as libc::c_ulong)
4096 .wrapping_mul(argc as libc::c_ulong),
4097 ) as *mut *mut robj;
4098 (*fakeClient).argc = argc;
4099 (*fakeClient).argv = argv;
4100 (*fakeClient).argv_len = argc;
4101 j = 0 as libc::c_int;
4102 while j < argc {
4103 let mut readres: *mut libc::c_char = fgets(
4104 buf.as_mut_ptr(),
4105 core::mem::size_of::<[libc::c_char; 1024]>()
4106 as libc::c_ulong as libc::c_int,
4107 fp,
4108 );
4109 if readres.is_null()
4110 || buf[0 as libc::c_int as usize] as libc::c_int
4111 != '$' as i32
4112 {
4113 (*fakeClient).argc = j;
4114 freeClientArgv(fakeClient);
4115 if readres.is_null() {
4116 current_block = 8304579957269340979;
4117 continue '_readerr;
4118 } else {
4119 current_block = 9904301676592638684;
4120 break '_readerr;
4121 }
4122 } else {
4123 len = strtol(
4124 buf.as_mut_ptr().offset(1 as libc::c_int as isize),
4125 0 as *mut *mut libc::c_char,
4126 10 as libc::c_int,
4127 ) as libc::c_ulong;
4128 argsds = sdsnewlen(SDS_NOINIT as *const libc::c_void, len);
4129 if len != 0
4130 && fread(
4131 argsds as *mut libc::c_void,
4132 len,
4133 1 as libc::c_int as libc::c_ulong,
4134 fp,
4135 ) == 0 as libc::c_int as libc::c_ulong
4136 {
4137 sdsfree(argsds);
4138 (*fakeClient).argc = j;
4139 freeClientArgv(fakeClient);
4140 current_block = 8304579957269340979;
4141 continue '_readerr;
4142 } else {
4143 let ref mut fresh5 = *argv.offset(j as isize);
4144 *fresh5 = createObject(
4145 0 as libc::c_int,
4146 argsds as *mut libc::c_void,
4147 );
4148 if fread(
4149 buf.as_mut_ptr() as *mut libc::c_void,
4150 2 as libc::c_int as libc::c_ulong,
4151 1 as libc::c_int as libc::c_ulong,
4152 fp,
4153 ) == 0 as libc::c_int as libc::c_ulong
4154 {
4155 (*fakeClient).argc = j + 1 as libc::c_int;
4156 freeClientArgv(fakeClient);
4157 current_block = 8304579957269340979;
4158 continue '_readerr;
4159 } else {
4160 j += 1;
4161 }
4162 }
4163 }
4164 }
4165 cmd = lookupCommand(argv, argc);
4166 if cmd.is_null() {
4167 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity)
4168 {
4169 _serverLog(
4170 3 as libc::c_int,
4171 b"Unknown command '%s' reading the append only file %s\0"
4172 as *const u8 as *const libc::c_char,
4173 (**argv.offset(0 as libc::c_int as isize)).ptr
4174 as *mut libc::c_char,
4175 filename,
4176 );
4177 }
4178 freeClientArgv(fakeClient);
4179 ret = 4 as libc::c_int;
4180 current_block = 5212373964289612464;
4181 break;
4182 } else {
4183 if (*cmd).proc_0
4184 == Some(
4185 multiCommand as unsafe extern "C" fn(*mut client) -> (),
4186 )
4187 {
4188 valid_before_multi = valid_up_to;
4189 }
4190 (*fakeClient).lastcmd = cmd;
4191 (*fakeClient).cmd = (*fakeClient).lastcmd;
4192 if (*fakeClient).flags
4193 & ((1 as libc::c_int) << 3 as libc::c_int) as libc::c_ulong
4194 != 0
4195 && (*(*fakeClient).cmd).proc_0
4196 != Some(
4197 execCommand as unsafe extern "C" fn(*mut client) -> (),
4198 )
4199 {
4200 queueMultiCommand(fakeClient, (*cmd).flags);
4201 } else {
4202 ((*cmd).proc_0)
4203 .expect("non-null function pointer")(fakeClient);
4204 }
4205 if (*fakeClient).bufpos == 0 as libc::c_int
4206 && (*(*fakeClient).reply).len
4207 == 0 as libc::c_int as libc::c_ulong
4208 {} else {
4209 _serverAssert(
4210 b"fakeClient->bufpos == 0 && listLength(fakeClient->reply) == 0\0"
4211 as *const u8 as *const libc::c_char,
4212 b"aof.c\0" as *const u8 as *const libc::c_char,
4213 1540 as libc::c_int,
4214 );
4215 unreachable!();
4216 };
4217 if (*fakeClient).flags
4218 & ((1 as libc::c_int) << 4 as libc::c_int) as libc::c_ulong
4219 == 0 as libc::c_int as libc::c_ulong
4220 {} else {
4221 _serverAssert(
4222 b"(fakeClient->flags & CLIENT_BLOCKED) == 0\0" as *const u8
4223 as *const libc::c_char,
4224 b"aof.c\0" as *const u8 as *const libc::c_char,
4225 1543 as libc::c_int,
4226 );
4227 unreachable!();
4228 };
4229 freeClientArgv(fakeClient);
4230 if server.aof_load_truncated != 0 {
4231 valid_up_to = ftello(fp);
4232 }
4233 if server.key_load_delay != 0 {
4234 debugDelay(server.key_load_delay);
4235 }
4236 current_block = 2516253395664191498;
4237 }
4238 }
4239 }
4240 _ => {
4241 if !(feof(fp) == 0) {
4242 current_block = 9752757855149897415;
4243 break;
4244 }
4245 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
4246 _serverLog(
4247 3 as libc::c_int,
4248 b"Unrecoverable error reading the append only file %s: %s\0"
4249 as *const u8 as *const libc::c_char,
4250 filename,
4251 strerror(*__errno_location()),
4252 );
4253 }
4254 ret = 4 as libc::c_int;
4255 current_block = 5212373964289612464;
4256 break;
4257 }
4258 }
4259 }
4260 match current_block {
4261 5265702136860997526 => {
4262 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
4263 _serverLog(
4264 3 as libc::c_int,
4265 b"Revert incomplete MULTI/EXEC transaction in AOF file %s\0"
4266 as *const u8 as *const libc::c_char,
4267 filename,
4268 );
4269 }
4270 valid_up_to = valid_before_multi;
4271 current_block = 9752757855149897415;
4272 }
4273 9904301676592638684 => {
4274 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
4275 _serverLog(
4276 3 as libc::c_int,
4277 b"Bad file format reading the append only file %s: make a backup of your AOF file, then use ./redis-check-aof --fix <filename.manifest>\0"
4278 as *const u8 as *const libc::c_char,
4279 filename,
4280 );
4281 }
4282 ret = 4 as libc::c_int;
4283 current_block = 5212373964289612464;
4284 }
4285 _ => {}
4286 }
4287 match current_block {
4288 9752757855149897415 => {
4289 if server.aof_load_truncated != 0 {
4290 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
4291 _serverLog(
4292 3 as libc::c_int,
4293 b"!!! Warning: short read while loading the AOF file %s!!!\0"
4294 as *const u8 as *const libc::c_char,
4295 filename,
4296 );
4297 }
4298 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
4299 _serverLog(
4300 3 as libc::c_int,
4301 b"!!! Truncating the AOF %s at offset %llu !!!\0" as *const u8
4302 as *const libc::c_char,
4303 filename,
4304 valid_up_to as libc::c_ulonglong,
4305 );
4306 }
4307 if valid_up_to == -(1 as libc::c_int) as libc::c_long
4308 || truncate(aof_filepath as *const libc::c_char, valid_up_to)
4309 == -(1 as libc::c_int)
4310 {
4311 if valid_up_to == -(1 as libc::c_int) as libc::c_long {
4312 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity)
4313 {
4314 _serverLog(
4315 3 as libc::c_int,
4316 b"Last valid command offset is invalid\0" as *const u8
4317 as *const libc::c_char,
4318 );
4319 }
4320 } else if !((3 as libc::c_int & 0xff as libc::c_int)
4321 < server.verbosity)
4322 {
4323 _serverLog(
4324 3 as libc::c_int,
4325 b"Error truncating the AOF file %s: %s\0" as *const u8
4326 as *const libc::c_char,
4327 filename,
4328 strerror(*__errno_location()),
4329 );
4330 }
4331 current_block = 13810333397648094191;
4332 } else if server.aof_fd != -(1 as libc::c_int)
4333 && lseek(
4334 server.aof_fd,
4335 0 as libc::c_int as __off64_t,
4336 2 as libc::c_int,
4337 ) == -(1 as libc::c_int) as libc::c_long
4338 {
4339 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
4340 _serverLog(
4341 3 as libc::c_int,
4342 b"Can't seek the end of the AOF file %s: %s\0" as *const u8
4343 as *const libc::c_char,
4344 filename,
4345 strerror(*__errno_location()),
4346 );
4347 }
4348 current_block = 13810333397648094191;
4349 } else {
4350 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
4351 _serverLog(
4352 3 as libc::c_int,
4353 b"AOF %s loaded anyway because aof-load-truncated is enabled\0"
4354 as *const u8 as *const libc::c_char,
4355 filename,
4356 );
4357 }
4358 ret = 5 as libc::c_int;
4359 current_block = 852400248170036051;
4360 }
4361 } else {
4362 current_block = 13810333397648094191;
4363 }
4364 match current_block {
4365 852400248170036051 => {}
4366 _ => {
4367 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
4368 _serverLog(
4369 3 as libc::c_int,
4370 b"Unexpected end of file reading the append only file %s. You can: 1) Make a backup of your AOF file, then use ./redis-check-aof --fix <filename.manifest>. 2) Alternatively you can set the 'aof-load-truncated' configuration option to yes and restart the server.\0"
4371 as *const u8 as *const libc::c_char,
4372 filename,
4373 );
4374 }
4375 ret = 4 as libc::c_int;
4376 current_block = 5212373964289612464;
4377 }
4378 }
4379 }
4380 _ => {}
4381 }
4382 match current_block {
4383 852400248170036051 => {
4384 loadingIncrProgress(ftello(fp) - last_progress_report_size);
4385 server.aof_state = old_aof_state;
4386 }
4387 _ => {}
4388 }
4389 if !fakeClient.is_null() {
4390 freeClient(fakeClient);
4391 }
4392 server.current_client = old_client;
4393 fclose(fp);
4394 sdsfree(aof_filepath);
4395 return ret;
4396}
4397#[no_mangle]
4398pub unsafe extern "C" fn loadAppendOnlyFiles(mut am: *mut aofManifest) -> libc::c_int {
4399 let mut current_block: u64;
4400 if !am.is_null() {} else {
4401 _serverAssert(
4402 b"am != NULL\0" as *const u8 as *const libc::c_char,
4403 b"aof.c\0" as *const u8 as *const libc::c_char,
4404 1624 as libc::c_int,
4405 );
4406 unreachable!();
4407 };
4408 let mut status: libc::c_int = 0;
4409 let mut ret: libc::c_int = 0 as libc::c_int;
4410 let mut start: libc::c_longlong = 0;
4411 let mut total_size: off_t = 0 as libc::c_int as off_t;
4412 let mut base_size: off_t = 0 as libc::c_int as off_t;
4413 let mut aof_name: sds = 0 as *mut libc::c_char;
4414 let mut total_num: libc::c_int = 0;
4415 let mut aof_num: libc::c_int = 0 as libc::c_int;
4416 let mut last_file: libc::c_int = 0;
4417 if fileExist(server.aof_filename) != 0 {
4418 if dirExists(server.aof_dirname) == 0
4419 || ((*am).base_aof_info).is_null()
4420 && (*(*am).incr_aof_list).len == 0 as libc::c_int as libc::c_ulong
4421 || !((*am).base_aof_info).is_null()
4422 && (*(*am).incr_aof_list).len == 0 as libc::c_int as libc::c_ulong
4423 && strcmp(
4424 (*(*am).base_aof_info).file_name as *const libc::c_char,
4425 server.aof_filename,
4426 ) == 0 && aofFileExist(server.aof_filename) == 0
4427 {
4428 aofUpgradePrepare(am);
4429 }
4430 }
4431 if ((*am).base_aof_info).is_null()
4432 && (*(*am).incr_aof_list).len == 0 as libc::c_int as libc::c_ulong
4433 {
4434 return 1 as libc::c_int;
4435 }
4436 total_num = getBaseAndIncrAppendOnlyFilesNum(am);
4437 if total_num > 0 as libc::c_int {} else {
4438 _serverAssert(
4439 b"total_num > 0\0" as *const u8 as *const libc::c_char,
4440 b"aof.c\0" as *const u8 as *const libc::c_char,
4441 1655 as libc::c_int,
4442 );
4443 unreachable!();
4444 };
4445 total_size = getBaseAndIncrAppendOnlyFilesSize(am, &mut status);
4446 if status != 0 as libc::c_int {
4447 if status == 1 as libc::c_int {
4448 status = 4 as libc::c_int;
4449 }
4450 return status;
4451 } else {
4452 if total_size == 0 as libc::c_int as libc::c_long {
4453 return 2 as libc::c_int;
4454 }
4455 }
4456 startLoading(
4457 total_size as size_t,
4458 (1 as libc::c_int) << 0 as libc::c_int,
4459 0 as libc::c_int,
4460 );
4461 if !((*am).base_aof_info).is_null() {
4462 if (*(*am).base_aof_info).file_type as libc::c_uint
4463 == AOF_FILE_TYPE_BASE as libc::c_int as libc::c_uint
4464 {} else {
4465 _serverAssert(
4466 b"am->base_aof_info->file_type == AOF_FILE_TYPE_BASE\0" as *const u8
4467 as *const libc::c_char,
4468 b"aof.c\0" as *const u8 as *const libc::c_char,
4469 1673 as libc::c_int,
4470 );
4471 unreachable!();
4472 };
4473 aof_name = (*(*am).base_aof_info).file_name;
4474 updateLoadingFileName(aof_name);
4475 base_size = getAppendOnlyFileSize(aof_name, 0 as *mut libc::c_int);
4476 aof_num += 1;
4477 last_file = (aof_num == total_num) as libc::c_int;
4478 start = ustime();
4479 ret = loadSingleAppendOnlyFile(aof_name);
4480 if ret == 0 as libc::c_int || ret == 5 as libc::c_int && last_file != 0 {
4481 if !((2 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
4482 _serverLog(
4483 2 as libc::c_int,
4484 b"DB loaded from base file %s: %.3f seconds\0" as *const u8
4485 as *const libc::c_char,
4486 aof_name,
4487 ((ustime() - start) as libc::c_float
4488 / 1000000 as libc::c_int as libc::c_float) as libc::c_double,
4489 );
4490 }
4491 }
4492 if ret == 5 as libc::c_int && last_file == 0 {
4493 ret = 4 as libc::c_int;
4494 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
4495 _serverLog(
4496 3 as libc::c_int,
4497 b"Fatal error: the truncated file is not the last file\0"
4498 as *const u8 as *const libc::c_char,
4499 );
4500 }
4501 }
4502 if ret == 3 as libc::c_int || ret == 4 as libc::c_int {
4503 current_block = 2717692205864117062;
4504 } else {
4505 current_block = 9520865839495247062;
4506 }
4507 } else {
4508 current_block = 9520865839495247062;
4509 }
4510 match current_block {
4511 9520865839495247062 => {
4512 if (*(*am).incr_aof_list).len != 0 {
4513 let mut ln: *mut listNode = 0 as *mut listNode;
4514 let mut li: listIter = listIter {
4515 next: 0 as *mut listNode,
4516 direction: 0,
4517 };
4518 listRewind((*am).incr_aof_list, &mut li);
4519 loop {
4520 ln = listNext(&mut li);
4521 if ln.is_null() {
4522 current_block = 6072622540298447352;
4523 break;
4524 }
4525 let mut ai: *mut aofInfo = (*ln).value as *mut aofInfo;
4526 if (*ai).file_type as libc::c_uint
4527 == AOF_FILE_TYPE_INCR as libc::c_int as libc::c_uint
4528 {} else {
4529 _serverAssert(
4530 b"ai->file_type == AOF_FILE_TYPE_INCR\0" as *const u8
4531 as *const libc::c_char,
4532 b"aof.c\0" as *const u8 as *const libc::c_char,
4533 1704 as libc::c_int,
4534 );
4535 unreachable!();
4536 };
4537 aof_name = (*ai).file_name;
4538 updateLoadingFileName(aof_name);
4539 aof_num += 1;
4540 last_file = (aof_num == total_num) as libc::c_int;
4541 start = ustime();
4542 ret = loadSingleAppendOnlyFile(aof_name);
4543 if ret == 0 as libc::c_int
4544 || ret == 5 as libc::c_int && last_file != 0
4545 {
4546 if !((2 as libc::c_int & 0xff as libc::c_int) < server.verbosity)
4547 {
4548 _serverLog(
4549 2 as libc::c_int,
4550 b"DB loaded from incr file %s: %.3f seconds\0" as *const u8
4551 as *const libc::c_char,
4552 aof_name,
4553 ((ustime() - start) as libc::c_float
4554 / 1000000 as libc::c_int as libc::c_float) as libc::c_double,
4555 );
4556 }
4557 }
4558 if ret == 2 as libc::c_int {
4559 ret = 0 as libc::c_int;
4560 }
4561 if ret == 5 as libc::c_int && last_file == 0 {
4562 ret = 4 as libc::c_int;
4563 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity)
4564 {
4565 _serverLog(
4566 3 as libc::c_int,
4567 b"Fatal error: the truncated file is not the last file\0"
4568 as *const u8 as *const libc::c_char,
4569 );
4570 }
4571 }
4572 if ret == 3 as libc::c_int || ret == 4 as libc::c_int {
4573 current_block = 2717692205864117062;
4574 break;
4575 }
4576 }
4577 } else {
4578 current_block = 6072622540298447352;
4579 }
4580 match current_block {
4581 2717692205864117062 => {}
4582 _ => {
4583 server.aof_current_size = total_size;
4584 server.aof_rewrite_base_size = base_size;
4585 server.aof_fsync_offset = server.aof_current_size;
4586 }
4587 }
4588 }
4589 _ => {}
4590 }
4591 stopLoading((ret == 0 as libc::c_int || ret == 5 as libc::c_int) as libc::c_int);
4592 return ret;
4593}
4594#[no_mangle]
4595pub unsafe extern "C" fn rioWriteBulkObject(
4596 mut r: *mut rio,
4597 mut obj: *mut robj,
4598) -> libc::c_int {
4599 if (*obj).encoding() as libc::c_int == 1 as libc::c_int {
4600 return rioWriteBulkLongLong(r, (*obj).ptr as libc::c_long as libc::c_longlong)
4601 as libc::c_int
4602 } else {
4603 if (*obj).encoding() as libc::c_int == 0 as libc::c_int
4604 || (*obj).encoding() as libc::c_int == 8 as libc::c_int
4605 {
4606 return rioWriteBulkString(
4607 r,
4608 (*obj).ptr as *const libc::c_char,
4609 sdslen((*obj).ptr as sds),
4610 ) as libc::c_int
4611 } else {
4612 _serverPanic(
4613 b"aof.c\0" as *const u8 as *const libc::c_char,
4614 1763 as libc::c_int,
4615 b"Unknown string encoding\0" as *const u8 as *const libc::c_char,
4616 );
4617 unreachable!();
4618 }
4619 }
4620 panic!("Reached end of non-void function without returning");
4621}
4622#[no_mangle]
4623pub unsafe extern "C" fn rewriteListObject(
4624 mut r: *mut rio,
4625 mut key: *mut robj,
4626 mut o: *mut robj,
4627) -> libc::c_int {
4628 let mut count: libc::c_longlong = 0 as libc::c_int as libc::c_longlong;
4629 let mut items: libc::c_longlong = listTypeLength(o) as libc::c_longlong;
4630 if (*o).encoding() as libc::c_int == 9 as libc::c_int {
4631 let mut list: *mut quicklist = (*o).ptr as *mut quicklist;
4632 let mut li: *mut quicklistIter = quicklistGetIterator(list, 0 as libc::c_int);
4633 let mut entry: quicklistEntry = quicklistEntry {
4634 quicklist: 0 as *const quicklist,
4635 node: 0 as *mut quicklistNode,
4636 zi: 0 as *mut libc::c_uchar,
4637 value: 0 as *mut libc::c_uchar,
4638 longval: 0,
4639 sz: 0,
4640 offset: 0,
4641 };
4642 while quicklistNext(li, &mut entry) != 0 {
4643 if count == 0 as libc::c_int as libc::c_longlong {
4644 let mut cmd_items: libc::c_int = (if items
4645 > 64 as libc::c_int as libc::c_longlong
4646 {
4647 64 as libc::c_int as libc::c_longlong
4648 } else {
4649 items
4650 }) as libc::c_int;
4651 if rioWriteBulkCount(
4652 r,
4653 '*' as i32 as libc::c_char,
4654 (2 as libc::c_int + cmd_items) as libc::c_long,
4655 ) == 0
4656 || rioWriteBulkString(
4657 r,
4658 b"RPUSH\0" as *const u8 as *const libc::c_char,
4659 5 as libc::c_int as size_t,
4660 ) == 0 || rioWriteBulkObject(r, key) == 0
4661 {
4662 quicklistReleaseIterator(li);
4663 return 0 as libc::c_int;
4664 }
4665 }
4666 if !(entry.value).is_null() {
4667 if rioWriteBulkString(r, entry.value as *mut libc::c_char, entry.sz) == 0
4668 {
4669 quicklistReleaseIterator(li);
4670 return 0 as libc::c_int;
4671 }
4672 } else if rioWriteBulkLongLong(r, entry.longval) == 0 {
4673 quicklistReleaseIterator(li);
4674 return 0 as libc::c_int;
4675 }
4676 count += 1;
4677 if count == 64 as libc::c_int as libc::c_longlong {
4678 count = 0 as libc::c_int as libc::c_longlong;
4679 }
4680 items -= 1;
4681 }
4682 quicklistReleaseIterator(li);
4683 } else {
4684 _serverPanic(
4685 b"aof.c\0" as *const u8 as *const libc::c_char,
4686 1806 as libc::c_int,
4687 b"Unknown list encoding\0" as *const u8 as *const libc::c_char,
4688 );
4689 unreachable!();
4690 }
4691 return 1 as libc::c_int;
4692}
4693#[no_mangle]
4694pub unsafe extern "C" fn rewriteSetObject(
4695 mut r: *mut rio,
4696 mut key: *mut robj,
4697 mut o: *mut robj,
4698) -> libc::c_int {
4699 let mut count: libc::c_longlong = 0 as libc::c_int as libc::c_longlong;
4700 let mut items: libc::c_longlong = setTypeSize(o) as libc::c_longlong;
4701 if (*o).encoding() as libc::c_int == 6 as libc::c_int {
4702 let mut ii: libc::c_int = 0 as libc::c_int;
4703 let mut llval: int64_t = 0;
4704 loop {
4705 let fresh6 = ii;
4706 ii = ii + 1;
4707 if !(intsetGet((*o).ptr as *mut intset, fresh6 as uint32_t, &mut llval) != 0)
4708 {
4709 break;
4710 }
4711 if count == 0 as libc::c_int as libc::c_longlong {
4712 let mut cmd_items: libc::c_int = (if items
4713 > 64 as libc::c_int as libc::c_longlong
4714 {
4715 64 as libc::c_int as libc::c_longlong
4716 } else {
4717 items
4718 }) as libc::c_int;
4719 if rioWriteBulkCount(
4720 r,
4721 '*' as i32 as libc::c_char,
4722 (2 as libc::c_int + cmd_items) as libc::c_long,
4723 ) == 0
4724 || rioWriteBulkString(
4725 r,
4726 b"SADD\0" as *const u8 as *const libc::c_char,
4727 4 as libc::c_int as size_t,
4728 ) == 0 || rioWriteBulkObject(r, key) == 0
4729 {
4730 return 0 as libc::c_int;
4731 }
4732 }
4733 if rioWriteBulkLongLong(r, llval as libc::c_longlong) == 0 {
4734 return 0 as libc::c_int;
4735 }
4736 count += 1;
4737 if count == 64 as libc::c_int as libc::c_longlong {
4738 count = 0 as libc::c_int as libc::c_longlong;
4739 }
4740 items -= 1;
4741 }
4742 } else if (*o).encoding() as libc::c_int == 2 as libc::c_int {
4743 let mut di: *mut dictIterator = dictGetIterator((*o).ptr as *mut dict);
4744 let mut de: *mut dictEntry = 0 as *mut dictEntry;
4745 loop {
4746 de = dictNext(di);
4747 if de.is_null() {
4748 break;
4749 }
4750 let mut ele: sds = (*de).key as sds;
4751 if count == 0 as libc::c_int as libc::c_longlong {
4752 let mut cmd_items_0: libc::c_int = (if items
4753 > 64 as libc::c_int as libc::c_longlong
4754 {
4755 64 as libc::c_int as libc::c_longlong
4756 } else {
4757 items
4758 }) as libc::c_int;
4759 if rioWriteBulkCount(
4760 r,
4761 '*' as i32 as libc::c_char,
4762 (2 as libc::c_int + cmd_items_0) as libc::c_long,
4763 ) == 0
4764 || rioWriteBulkString(
4765 r,
4766 b"SADD\0" as *const u8 as *const libc::c_char,
4767 4 as libc::c_int as size_t,
4768 ) == 0 || rioWriteBulkObject(r, key) == 0
4769 {
4770 dictReleaseIterator(di);
4771 return 0 as libc::c_int;
4772 }
4773 }
4774 if rioWriteBulkString(r, ele as *const libc::c_char, sdslen(ele)) == 0 {
4775 dictReleaseIterator(di);
4776 return 0 as libc::c_int;
4777 }
4778 count += 1;
4779 if count == 64 as libc::c_int as libc::c_longlong {
4780 count = 0 as libc::c_int as libc::c_longlong;
4781 }
4782 items -= 1;
4783 }
4784 dictReleaseIterator(di);
4785 } else {
4786 _serverPanic(
4787 b"aof.c\0" as *const u8 as *const libc::c_char,
4788 1863 as libc::c_int,
4789 b"Unknown set encoding\0" as *const u8 as *const libc::c_char,
4790 );
4791 unreachable!();
4792 }
4793 return 1 as libc::c_int;
4794}
4795#[no_mangle]
4796pub unsafe extern "C" fn rewriteSortedSetObject(
4797 mut r: *mut rio,
4798 mut key: *mut robj,
4799 mut o: *mut robj,
4800) -> libc::c_int {
4801 let mut count: libc::c_longlong = 0 as libc::c_int as libc::c_longlong;
4802 let mut items: libc::c_longlong = zsetLength(o) as libc::c_longlong;
4803 if (*o).encoding() as libc::c_int == 11 as libc::c_int {
4804 let mut zl: *mut libc::c_uchar = (*o).ptr as *mut libc::c_uchar;
4805 let mut eptr: *mut libc::c_uchar = 0 as *mut libc::c_uchar;
4806 let mut sptr: *mut libc::c_uchar = 0 as *mut libc::c_uchar;
4807 let mut vstr: *mut libc::c_uchar = 0 as *mut libc::c_uchar;
4808 let mut vlen: libc::c_uint = 0;
4809 let mut vll: libc::c_longlong = 0;
4810 let mut score: libc::c_double = 0.;
4811 eptr = lpSeek(zl, 0 as libc::c_int as libc::c_long);
4812 if !eptr.is_null() {} else {
4813 _serverAssert(
4814 b"eptr != NULL\0" as *const u8 as *const libc::c_char,
4815 b"aof.c\0" as *const u8 as *const libc::c_char,
4816 1882 as libc::c_int,
4817 );
4818 unreachable!();
4819 };
4820 sptr = lpNext(zl, eptr);
4821 if !sptr.is_null() {} else {
4822 _serverAssert(
4823 b"sptr != NULL\0" as *const u8 as *const libc::c_char,
4824 b"aof.c\0" as *const u8 as *const libc::c_char,
4825 1884 as libc::c_int,
4826 );
4827 unreachable!();
4828 };
4829 while !eptr.is_null() {
4830 vstr = lpGetValue(eptr, &mut vlen, &mut vll);
4831 score = zzlGetScore(sptr);
4832 if count == 0 as libc::c_int as libc::c_longlong {
4833 let mut cmd_items: libc::c_int = (if items
4834 > 64 as libc::c_int as libc::c_longlong
4835 {
4836 64 as libc::c_int as libc::c_longlong
4837 } else {
4838 items
4839 }) as libc::c_int;
4840 if rioWriteBulkCount(
4841 r,
4842 '*' as i32 as libc::c_char,
4843 (2 as libc::c_int + cmd_items * 2 as libc::c_int) as libc::c_long,
4844 ) == 0
4845 || rioWriteBulkString(
4846 r,
4847 b"ZADD\0" as *const u8 as *const libc::c_char,
4848 4 as libc::c_int as size_t,
4849 ) == 0 || rioWriteBulkObject(r, key) == 0
4850 {
4851 return 0 as libc::c_int;
4852 }
4853 }
4854 if rioWriteBulkDouble(r, score) == 0 {
4855 return 0 as libc::c_int;
4856 }
4857 if !vstr.is_null() {
4858 if rioWriteBulkString(r, vstr as *mut libc::c_char, vlen as size_t) == 0
4859 {
4860 return 0 as libc::c_int;
4861 }
4862 } else if rioWriteBulkLongLong(r, vll) == 0 {
4863 return 0 as libc::c_int
4864 }
4865 zzlNext(zl, &mut eptr, &mut sptr);
4866 count += 1;
4867 if count == 64 as libc::c_int as libc::c_longlong {
4868 count = 0 as libc::c_int as libc::c_longlong;
4869 }
4870 items -= 1;
4871 }
4872 } else if (*o).encoding() as libc::c_int == 7 as libc::c_int {
4873 let mut zs: *mut zset = (*o).ptr as *mut zset;
4874 let mut di: *mut dictIterator = dictGetIterator((*zs).dict);
4875 let mut de: *mut dictEntry = 0 as *mut dictEntry;
4876 loop {
4877 de = dictNext(di);
4878 if de.is_null() {
4879 break;
4880 }
4881 let mut ele: sds = (*de).key as sds;
4882 let mut score_0: *mut libc::c_double = (*de).v.val as *mut libc::c_double;
4883 if count == 0 as libc::c_int as libc::c_longlong {
4884 let mut cmd_items_0: libc::c_int = (if items
4885 > 64 as libc::c_int as libc::c_longlong
4886 {
4887 64 as libc::c_int as libc::c_longlong
4888 } else {
4889 items
4890 }) as libc::c_int;
4891 if rioWriteBulkCount(
4892 r,
4893 '*' as i32 as libc::c_char,
4894 (2 as libc::c_int + cmd_items_0 * 2 as libc::c_int) as libc::c_long,
4895 ) == 0
4896 || rioWriteBulkString(
4897 r,
4898 b"ZADD\0" as *const u8 as *const libc::c_char,
4899 4 as libc::c_int as size_t,
4900 ) == 0 || rioWriteBulkObject(r, key) == 0
4901 {
4902 dictReleaseIterator(di);
4903 return 0 as libc::c_int;
4904 }
4905 }
4906 if rioWriteBulkDouble(r, *score_0) == 0
4907 || rioWriteBulkString(r, ele as *const libc::c_char, sdslen(ele)) == 0
4908 {
4909 dictReleaseIterator(di);
4910 return 0 as libc::c_int;
4911 }
4912 count += 1;
4913 if count == 64 as libc::c_int as libc::c_longlong {
4914 count = 0 as libc::c_int as libc::c_longlong;
4915 }
4916 items -= 1;
4917 }
4918 dictReleaseIterator(di);
4919 } else {
4920 _serverPanic(
4921 b"aof.c\0" as *const u8 as *const libc::c_char,
4922 1943 as libc::c_int,
4923 b"Unknown sorted zset encoding\0" as *const u8 as *const libc::c_char,
4924 );
4925 unreachable!();
4926 }
4927 return 1 as libc::c_int;
4928}
4929unsafe extern "C" fn rioWriteHashIteratorCursor(
4930 mut r: *mut rio,
4931 mut hi: *mut hashTypeIterator,
4932 mut what: libc::c_int,
4933) -> libc::c_int {
4934 if (*hi).encoding == 11 as libc::c_int {
4935 let mut vstr: *mut libc::c_uchar = 0 as *mut libc::c_uchar;
4936 let mut vlen: libc::c_uint = (2147483647 as libc::c_int as libc::c_uint)
4937 .wrapping_mul(2 as libc::c_uint)
4938 .wrapping_add(1 as libc::c_uint);
4939 let mut vll: libc::c_longlong = 9223372036854775807 as libc::c_longlong;
4940 hashTypeCurrentFromListpack(hi, what, &mut vstr, &mut vlen, &mut vll);
4941 if !vstr.is_null() {
4942 return rioWriteBulkString(r, vstr as *mut libc::c_char, vlen as size_t)
4943 as libc::c_int
4944 } else {
4945 return rioWriteBulkLongLong(r, vll) as libc::c_int
4946 }
4947 } else {
4948 if (*hi).encoding == 2 as libc::c_int {
4949 let mut value: sds = hashTypeCurrentFromHashTable(hi, what);
4950 return rioWriteBulkString(r, value as *const libc::c_char, sdslen(value))
4951 as libc::c_int;
4952 }
4953 }
4954 _serverPanic(
4955 b"aof.c\0" as *const u8 as *const libc::c_char,
4956 1970 as libc::c_int,
4957 b"Unknown hash encoding\0" as *const u8 as *const libc::c_char,
4958 );
4959 unreachable!();
4960 return 0 as libc::c_int;
4961}
4962#[no_mangle]
4963pub unsafe extern "C" fn rewriteHashObject(
4964 mut r: *mut rio,
4965 mut key: *mut robj,
4966 mut o: *mut robj,
4967) -> libc::c_int {
4968 let mut hi: *mut hashTypeIterator = 0 as *mut hashTypeIterator;
4969 let mut count: libc::c_longlong = 0 as libc::c_int as libc::c_longlong;
4970 let mut items: libc::c_longlong = hashTypeLength(o) as libc::c_longlong;
4971 hi = hashTypeInitIterator(o);
4972 while hashTypeNext(hi) != -(1 as libc::c_int) {
4973 if count == 0 as libc::c_int as libc::c_longlong {
4974 let mut cmd_items: libc::c_int = (if items
4975 > 64 as libc::c_int as libc::c_longlong
4976 {
4977 64 as libc::c_int as libc::c_longlong
4978 } else {
4979 items
4980 }) as libc::c_int;
4981 if rioWriteBulkCount(
4982 r,
4983 '*' as i32 as libc::c_char,
4984 (2 as libc::c_int + cmd_items * 2 as libc::c_int) as libc::c_long,
4985 ) == 0
4986 || rioWriteBulkString(
4987 r,
4988 b"HMSET\0" as *const u8 as *const libc::c_char,
4989 5 as libc::c_int as size_t,
4990 ) == 0 || rioWriteBulkObject(r, key) == 0
4991 {
4992 hashTypeReleaseIterator(hi);
4993 return 0 as libc::c_int;
4994 }
4995 }
4996 if rioWriteHashIteratorCursor(r, hi, 1 as libc::c_int) == 0
4997 || rioWriteHashIteratorCursor(r, hi, 2 as libc::c_int) == 0
4998 {
4999 hashTypeReleaseIterator(hi);
5000 return 0 as libc::c_int;
5001 }
5002 count += 1;
5003 if count == 64 as libc::c_int as libc::c_longlong {
5004 count = 0 as libc::c_int as libc::c_longlong;
5005 }
5006 items -= 1;
5007 }
5008 hashTypeReleaseIterator(hi);
5009 return 1 as libc::c_int;
5010}
5011#[no_mangle]
5012pub unsafe extern "C" fn rioWriteBulkStreamID(
5013 mut r: *mut rio,
5014 mut id: *mut streamID,
5015) -> libc::c_int {
5016 let mut retval: libc::c_int = 0;
5017 let mut replyid: sds = sdscatfmt(
5018 sdsempty(),
5019 b"%U-%U\0" as *const u8 as *const libc::c_char,
5020 (*id).ms,
5021 (*id).seq,
5022 );
5023 retval = rioWriteBulkString(r, replyid as *const libc::c_char, sdslen(replyid))
5024 as libc::c_int;
5025 sdsfree(replyid);
5026 return retval;
5027}
5028#[no_mangle]
5029pub unsafe extern "C" fn rioWriteStreamPendingEntry(
5030 mut r: *mut rio,
5031 mut key: *mut robj,
5032 mut groupname: *const libc::c_char,
5033 mut groupname_len: size_t,
5034 mut consumer: *mut streamConsumer,
5035 mut rawid: *mut libc::c_uchar,
5036 mut nack: *mut streamNACK,
5037) -> libc::c_int {
5038 let mut id: streamID = streamID { ms: 0, seq: 0 };
5039 streamDecodeID(rawid as *mut libc::c_void, &mut id);
5040 if rioWriteBulkCount(
5041 r,
5042 '*' as i32 as libc::c_char,
5043 12 as libc::c_int as libc::c_long,
5044 ) == 0 as libc::c_int as libc::c_ulong
5045 {
5046 return 0 as libc::c_int;
5047 }
5048 if rioWriteBulkString(
5049 r,
5050 b"XCLAIM\0" as *const u8 as *const libc::c_char,
5051 6 as libc::c_int as size_t,
5052 ) == 0 as libc::c_int as libc::c_ulong
5053 {
5054 return 0 as libc::c_int;
5055 }
5056 if rioWriteBulkObject(r, key) == 0 as libc::c_int {
5057 return 0 as libc::c_int;
5058 }
5059 if rioWriteBulkString(r, groupname, groupname_len)
5060 == 0 as libc::c_int as libc::c_ulong
5061 {
5062 return 0 as libc::c_int;
5063 }
5064 if rioWriteBulkString(
5065 r,
5066 (*consumer).name as *const libc::c_char,
5067 sdslen((*consumer).name),
5068 ) == 0 as libc::c_int as libc::c_ulong
5069 {
5070 return 0 as libc::c_int;
5071 }
5072 if rioWriteBulkString(
5073 r,
5074 b"0\0" as *const u8 as *const libc::c_char,
5075 1 as libc::c_int as size_t,
5076 ) == 0 as libc::c_int as libc::c_ulong
5077 {
5078 return 0 as libc::c_int;
5079 }
5080 if rioWriteBulkStreamID(r, &mut id) == 0 as libc::c_int {
5081 return 0 as libc::c_int;
5082 }
5083 if rioWriteBulkString(
5084 r,
5085 b"TIME\0" as *const u8 as *const libc::c_char,
5086 4 as libc::c_int as size_t,
5087 ) == 0 as libc::c_int as libc::c_ulong
5088 {
5089 return 0 as libc::c_int;
5090 }
5091 if rioWriteBulkLongLong(r, (*nack).delivery_time)
5092 == 0 as libc::c_int as libc::c_ulong
5093 {
5094 return 0 as libc::c_int;
5095 }
5096 if rioWriteBulkString(
5097 r,
5098 b"RETRYCOUNT\0" as *const u8 as *const libc::c_char,
5099 10 as libc::c_int as size_t,
5100 ) == 0 as libc::c_int as libc::c_ulong
5101 {
5102 return 0 as libc::c_int;
5103 }
5104 if rioWriteBulkLongLong(r, (*nack).delivery_count as libc::c_longlong)
5105 == 0 as libc::c_int as libc::c_ulong
5106 {
5107 return 0 as libc::c_int;
5108 }
5109 if rioWriteBulkString(
5110 r,
5111 b"JUSTID\0" as *const u8 as *const libc::c_char,
5112 6 as libc::c_int as size_t,
5113 ) == 0 as libc::c_int as libc::c_ulong
5114 {
5115 return 0 as libc::c_int;
5116 }
5117 if rioWriteBulkString(
5118 r,
5119 b"FORCE\0" as *const u8 as *const libc::c_char,
5120 5 as libc::c_int as size_t,
5121 ) == 0 as libc::c_int as libc::c_ulong
5122 {
5123 return 0 as libc::c_int;
5124 }
5125 return 1 as libc::c_int;
5126}
5127#[no_mangle]
5128pub unsafe extern "C" fn rioWriteStreamEmptyConsumer(
5129 mut r: *mut rio,
5130 mut key: *mut robj,
5131 mut groupname: *const libc::c_char,
5132 mut groupname_len: size_t,
5133 mut consumer: *mut streamConsumer,
5134) -> libc::c_int {
5135 if rioWriteBulkCount(r, '*' as i32 as libc::c_char, 5 as libc::c_int as libc::c_long)
5136 == 0 as libc::c_int as libc::c_ulong
5137 {
5138 return 0 as libc::c_int;
5139 }
5140 if rioWriteBulkString(
5141 r,
5142 b"XGROUP\0" as *const u8 as *const libc::c_char,
5143 6 as libc::c_int as size_t,
5144 ) == 0 as libc::c_int as libc::c_ulong
5145 {
5146 return 0 as libc::c_int;
5147 }
5148 if rioWriteBulkString(
5149 r,
5150 b"CREATECONSUMER\0" as *const u8 as *const libc::c_char,
5151 14 as libc::c_int as size_t,
5152 ) == 0 as libc::c_int as libc::c_ulong
5153 {
5154 return 0 as libc::c_int;
5155 }
5156 if rioWriteBulkObject(r, key) == 0 as libc::c_int {
5157 return 0 as libc::c_int;
5158 }
5159 if rioWriteBulkString(r, groupname, groupname_len)
5160 == 0 as libc::c_int as libc::c_ulong
5161 {
5162 return 0 as libc::c_int;
5163 }
5164 if rioWriteBulkString(
5165 r,
5166 (*consumer).name as *const libc::c_char,
5167 sdslen((*consumer).name),
5168 ) == 0 as libc::c_int as libc::c_ulong
5169 {
5170 return 0 as libc::c_int;
5171 }
5172 return 1 as libc::c_int;
5173}
5174#[no_mangle]
5175pub unsafe extern "C" fn rewriteStreamObject(
5176 mut r: *mut rio,
5177 mut key: *mut robj,
5178 mut o: *mut robj,
5179) -> libc::c_int {
5180 let mut s: *mut stream = (*o).ptr as *mut stream;
5181 let mut si: streamIterator = streamIterator {
5182 stream: 0 as *mut stream,
5183 master_id: streamID { ms: 0, seq: 0 },
5184 master_fields_count: 0,
5185 master_fields_start: 0 as *mut libc::c_uchar,
5186 master_fields_ptr: 0 as *mut libc::c_uchar,
5187 entry_flags: 0,
5188 rev: 0,
5189 skip_tombstones: 0,
5190 start_key: [0; 2],
5191 end_key: [0; 2],
5192 ri: raxIterator {
5193 flags: 0,
5194 rt: 0 as *mut rax,
5195 key: 0 as *mut libc::c_uchar,
5196 data: 0 as *mut libc::c_void,
5197 key_len: 0,
5198 key_max: 0,
5199 key_static_string: [0; 128],
5200 node: 0 as *mut raxNode,
5201 stack: raxStack {
5202 stack: 0 as *mut *mut libc::c_void,
5203 items: 0,
5204 maxitems: 0,
5205 static_items: [0 as *mut libc::c_void; 32],
5206 oom: 0,
5207 },
5208 node_cb: None,
5209 },
5210 lp: 0 as *mut libc::c_uchar,
5211 lp_ele: 0 as *mut libc::c_uchar,
5212 lp_flags: 0 as *mut libc::c_uchar,
5213 field_buf: [0; 21],
5214 value_buf: [0; 21],
5215 };
5216 streamIteratorStart(
5217 &mut si,
5218 s,
5219 0 as *mut streamID,
5220 0 as *mut streamID,
5221 0 as libc::c_int,
5222 );
5223 let mut id: streamID = streamID { ms: 0, seq: 0 };
5224 let mut numfields: int64_t = 0;
5225 if (*s).length != 0 {
5226 while streamIteratorGetID(&mut si, &mut id, &mut numfields) != 0 {
5227 if rioWriteBulkCount(
5228 r,
5229 '*' as i32 as libc::c_char,
5230 3 as libc::c_int as libc::c_long
5231 + numfields * 2 as libc::c_int as libc::c_long,
5232 ) == 0
5233 || rioWriteBulkString(
5234 r,
5235 b"XADD\0" as *const u8 as *const libc::c_char,
5236 4 as libc::c_int as size_t,
5237 ) == 0 || rioWriteBulkObject(r, key) == 0
5238 || rioWriteBulkStreamID(r, &mut id) == 0
5239 {
5240 streamIteratorStop(&mut si);
5241 return 0 as libc::c_int;
5242 }
5243 loop {
5244 let fresh7 = numfields;
5245 numfields = numfields - 1;
5246 if !(fresh7 != 0) {
5247 break;
5248 }
5249 let mut field: *mut libc::c_uchar = 0 as *mut libc::c_uchar;
5250 let mut value: *mut libc::c_uchar = 0 as *mut libc::c_uchar;
5251 let mut field_len: int64_t = 0;
5252 let mut value_len: int64_t = 0;
5253 streamIteratorGetField(
5254 &mut si,
5255 &mut field,
5256 &mut value,
5257 &mut field_len,
5258 &mut value_len,
5259 );
5260 if rioWriteBulkString(r, field as *mut libc::c_char, field_len as size_t)
5261 == 0
5262 || rioWriteBulkString(
5263 r,
5264 value as *mut libc::c_char,
5265 value_len as size_t,
5266 ) == 0
5267 {
5268 streamIteratorStop(&mut si);
5269 return 0 as libc::c_int;
5270 }
5271 }
5272 }
5273 } else {
5274 id.ms = 0 as libc::c_int as uint64_t;
5275 id.seq = 1 as libc::c_int as uint64_t;
5276 if rioWriteBulkCount(
5277 r,
5278 '*' as i32 as libc::c_char,
5279 7 as libc::c_int as libc::c_long,
5280 ) == 0
5281 || rioWriteBulkString(
5282 r,
5283 b"XADD\0" as *const u8 as *const libc::c_char,
5284 4 as libc::c_int as size_t,
5285 ) == 0 || rioWriteBulkObject(r, key) == 0
5286 || rioWriteBulkString(
5287 r,
5288 b"MAXLEN\0" as *const u8 as *const libc::c_char,
5289 6 as libc::c_int as size_t,
5290 ) == 0
5291 || rioWriteBulkString(
5292 r,
5293 b"0\0" as *const u8 as *const libc::c_char,
5294 1 as libc::c_int as size_t,
5295 ) == 0 || rioWriteBulkStreamID(r, &mut id) == 0
5296 || rioWriteBulkString(
5297 r,
5298 b"x\0" as *const u8 as *const libc::c_char,
5299 1 as libc::c_int as size_t,
5300 ) == 0
5301 || rioWriteBulkString(
5302 r,
5303 b"y\0" as *const u8 as *const libc::c_char,
5304 1 as libc::c_int as size_t,
5305 ) == 0
5306 {
5307 streamIteratorStop(&mut si);
5308 return 0 as libc::c_int;
5309 }
5310 }
5311 if rioWriteBulkCount(r, '*' as i32 as libc::c_char, 7 as libc::c_int as libc::c_long)
5312 == 0
5313 || rioWriteBulkString(
5314 r,
5315 b"XSETID\0" as *const u8 as *const libc::c_char,
5316 6 as libc::c_int as size_t,
5317 ) == 0 || rioWriteBulkObject(r, key) == 0
5318 || rioWriteBulkStreamID(r, &mut (*s).last_id) == 0
5319 || rioWriteBulkString(
5320 r,
5321 b"ENTRIESADDED\0" as *const u8 as *const libc::c_char,
5322 12 as libc::c_int as size_t,
5323 ) == 0 || rioWriteBulkLongLong(r, (*s).entries_added as libc::c_longlong) == 0
5324 || rioWriteBulkString(
5325 r,
5326 b"MAXDELETEDID\0" as *const u8 as *const libc::c_char,
5327 12 as libc::c_int as size_t,
5328 ) == 0 || rioWriteBulkStreamID(r, &mut (*s).max_deleted_entry_id) == 0
5329 {
5330 streamIteratorStop(&mut si);
5331 return 0 as libc::c_int;
5332 }
5333 if !((*s).cgroups).is_null() {
5334 let mut ri: raxIterator = raxIterator {
5335 flags: 0,
5336 rt: 0 as *mut rax,
5337 key: 0 as *mut libc::c_uchar,
5338 data: 0 as *mut libc::c_void,
5339 key_len: 0,
5340 key_max: 0,
5341 key_static_string: [0; 128],
5342 node: 0 as *mut raxNode,
5343 stack: raxStack {
5344 stack: 0 as *mut *mut libc::c_void,
5345 items: 0,
5346 maxitems: 0,
5347 static_items: [0 as *mut libc::c_void; 32],
5348 oom: 0,
5349 },
5350 node_cb: None,
5351 };
5352 raxStart(&mut ri, (*s).cgroups);
5353 raxSeek(
5354 &mut ri,
5355 b"^\0" as *const u8 as *const libc::c_char,
5356 0 as *mut libc::c_uchar,
5357 0 as libc::c_int as size_t,
5358 );
5359 while raxNext(&mut ri) != 0 {
5360 let mut group: *mut streamCG = ri.data as *mut streamCG;
5361 if rioWriteBulkCount(
5362 r,
5363 '*' as i32 as libc::c_char,
5364 7 as libc::c_int as libc::c_long,
5365 ) == 0
5366 || rioWriteBulkString(
5367 r,
5368 b"XGROUP\0" as *const u8 as *const libc::c_char,
5369 6 as libc::c_int as size_t,
5370 ) == 0
5371 || rioWriteBulkString(
5372 r,
5373 b"CREATE\0" as *const u8 as *const libc::c_char,
5374 6 as libc::c_int as size_t,
5375 ) == 0 || rioWriteBulkObject(r, key) == 0
5376 || rioWriteBulkString(r, ri.key as *mut libc::c_char, ri.key_len) == 0
5377 || rioWriteBulkStreamID(r, &mut (*group).last_id) == 0
5378 || rioWriteBulkString(
5379 r,
5380 b"ENTRIESREAD\0" as *const u8 as *const libc::c_char,
5381 11 as libc::c_int as size_t,
5382 ) == 0 || rioWriteBulkLongLong(r, (*group).entries_read) == 0
5383 {
5384 raxStop(&mut ri);
5385 streamIteratorStop(&mut si);
5386 return 0 as libc::c_int;
5387 }
5388 let mut ri_cons: raxIterator = raxIterator {
5389 flags: 0,
5390 rt: 0 as *mut rax,
5391 key: 0 as *mut libc::c_uchar,
5392 data: 0 as *mut libc::c_void,
5393 key_len: 0,
5394 key_max: 0,
5395 key_static_string: [0; 128],
5396 node: 0 as *mut raxNode,
5397 stack: raxStack {
5398 stack: 0 as *mut *mut libc::c_void,
5399 items: 0,
5400 maxitems: 0,
5401 static_items: [0 as *mut libc::c_void; 32],
5402 oom: 0,
5403 },
5404 node_cb: None,
5405 };
5406 raxStart(&mut ri_cons, (*group).consumers);
5407 raxSeek(
5408 &mut ri_cons,
5409 b"^\0" as *const u8 as *const libc::c_char,
5410 0 as *mut libc::c_uchar,
5411 0 as libc::c_int as size_t,
5412 );
5413 while raxNext(&mut ri_cons) != 0 {
5414 let mut consumer: *mut streamConsumer = ri_cons.data
5415 as *mut streamConsumer;
5416 if raxSize((*consumer).pel) == 0 as libc::c_int as libc::c_ulong {
5417 if rioWriteStreamEmptyConsumer(
5418 r,
5419 key,
5420 ri.key as *mut libc::c_char,
5421 ri.key_len,
5422 consumer,
5423 ) == 0 as libc::c_int
5424 {
5425 raxStop(&mut ri_cons);
5426 raxStop(&mut ri);
5427 streamIteratorStop(&mut si);
5428 return 0 as libc::c_int;
5429 }
5430 } else {
5431 let mut ri_pel: raxIterator = raxIterator {
5432 flags: 0,
5433 rt: 0 as *mut rax,
5434 key: 0 as *mut libc::c_uchar,
5435 data: 0 as *mut libc::c_void,
5436 key_len: 0,
5437 key_max: 0,
5438 key_static_string: [0; 128],
5439 node: 0 as *mut raxNode,
5440 stack: raxStack {
5441 stack: 0 as *mut *mut libc::c_void,
5442 items: 0,
5443 maxitems: 0,
5444 static_items: [0 as *mut libc::c_void; 32],
5445 oom: 0,
5446 },
5447 node_cb: None,
5448 };
5449 raxStart(&mut ri_pel, (*consumer).pel);
5450 raxSeek(
5451 &mut ri_pel,
5452 b"^\0" as *const u8 as *const libc::c_char,
5453 0 as *mut libc::c_uchar,
5454 0 as libc::c_int as size_t,
5455 );
5456 while raxNext(&mut ri_pel) != 0 {
5457 let mut nack: *mut streamNACK = ri_pel.data as *mut streamNACK;
5458 if rioWriteStreamPendingEntry(
5459 r,
5460 key,
5461 ri.key as *mut libc::c_char,
5462 ri.key_len,
5463 consumer,
5464 ri_pel.key,
5465 nack,
5466 ) == 0 as libc::c_int
5467 {
5468 raxStop(&mut ri_pel);
5469 raxStop(&mut ri_cons);
5470 raxStop(&mut ri);
5471 streamIteratorStop(&mut si);
5472 return 0 as libc::c_int;
5473 }
5474 }
5475 raxStop(&mut ri_pel);
5476 }
5477 }
5478 raxStop(&mut ri_cons);
5479 }
5480 raxStop(&mut ri);
5481 }
5482 streamIteratorStop(&mut si);
5483 return 1 as libc::c_int;
5484}
5485#[no_mangle]
5486pub unsafe extern "C" fn rewriteModuleObject(
5487 mut r: *mut rio,
5488 mut key: *mut robj,
5489 mut o: *mut robj,
5490 mut dbid: libc::c_int,
5491) -> libc::c_int {
5492 let mut io: RedisModuleIO = RedisModuleIO {
5493 bytes: 0,
5494 rio: 0 as *mut rio,
5495 type_0: 0 as *mut moduleType,
5496 error: 0,
5497 ver: 0,
5498 ctx: 0 as *mut RedisModuleCtx,
5499 key: 0 as *mut redisObject,
5500 dbid: 0,
5501 };
5502 let mut mv: *mut moduleValue = (*o).ptr as *mut moduleValue;
5503 let mut mt: *mut moduleType = (*mv).type_0;
5504 io.rio = r;
5505 io.type_0 = mt;
5506 io.bytes = 0 as libc::c_int as size_t;
5507 io.error = 0 as libc::c_int;
5508 io.ver = 0 as libc::c_int;
5509 io.key = key;
5510 io.dbid = dbid;
5511 io.ctx = 0 as *mut RedisModuleCtx;
5512 ((*mt).aof_rewrite).expect("non-null function pointer")(&mut io, key, (*mv).value);
5513 if !(io.ctx).is_null() {
5514 moduleFreeContext(io.ctx);
5515 zfree(io.ctx as *mut libc::c_void);
5516 }
5517 return if io.error != 0 { 0 as libc::c_int } else { 1 as libc::c_int };
5518}
5519unsafe extern "C" fn rewriteFunctions(mut aof: *mut rio) -> libc::c_int {
5520 let mut current_block: u64;
5521 let mut functions: *mut dict = functionsLibGet();
5522 let mut iter: *mut dictIterator = dictGetIterator(functions);
5523 let mut entry: *mut dictEntry = 0 as *mut dictEntry;
5524 loop {
5525 entry = dictNext(iter);
5526 if entry.is_null() {
5527 current_block = 6483416627284290920;
5528 break;
5529 }
5530 let mut li: *mut functionLibInfo = (*entry).v.val as *mut functionLibInfo;
5531 if rioWrite(
5532 aof,
5533 b"*3\r\n\0" as *const u8 as *const libc::c_char as *const libc::c_void,
5534 4 as libc::c_int as size_t,
5535 ) == 0 as libc::c_int as libc::c_ulong
5536 {
5537 current_block = 11212911460225021231;
5538 break;
5539 }
5540 let mut functionload: [u8; 25] = UnsafeCell::new([
5541 b'$', b'8', b'\r', b'\n', b'F', b'U', b'N', b'C', b'T', b'I', b'O', b'N',
5542 b'\r', b'\n', b'$', b'4', b'\r', b'\n', b'L', b'O', b'A', b'D', b'\r', b'\n', b'\0'
5543 ]).into_inner();
5544 if rioWrite(
5545 aof,
5546 functionload.as_mut_ptr() as *const libc::c_void,
5547 (core::mem::size_of::<[libc::c_char; 25]>() as libc::c_ulong)
5548 .wrapping_sub(1 as libc::c_int as libc::c_ulong),
5549 ) == 0 as libc::c_int as libc::c_ulong
5550 {
5551 current_block = 11212911460225021231;
5552 break;
5553 }
5554 if rioWriteBulkString(aof, (*li).code as *const libc::c_char, sdslen((*li).code))
5555 == 0 as libc::c_int as libc::c_ulong
5556 {
5557 current_block = 11212911460225021231;
5558 break;
5559 }
5560 }
5561 match current_block {
5562 11212911460225021231 => {
5563 dictReleaseIterator(iter);
5564 return 0 as libc::c_int;
5565 }
5566 _ => {
5567 dictReleaseIterator(iter);
5568 return 1 as libc::c_int;
5569 }
5570 };
5571}
5572#[no_mangle]
5573pub unsafe extern "C" fn rewriteAppendOnlyFileRio(mut aof: *mut rio) -> libc::c_int {
5574 let mut current_block: u64;
5575 let mut di: *mut dictIterator = 0 as *mut dictIterator;
5576 let mut de: *mut dictEntry = 0 as *mut dictEntry;
5577 let mut j: libc::c_int = 0;
5578 let mut key_count: libc::c_long = 0 as libc::c_int as libc::c_long;
5579 let mut updated_time: libc::c_longlong = 0 as libc::c_int as libc::c_longlong;
5580 if server.aof_timestamp_enabled != 0 {
5581 let mut ts: sds = genAofTimestampAnnotationIfNeeded(1 as libc::c_int);
5582 if rioWrite(aof, ts as *const libc::c_void, sdslen(ts))
5583 == 0 as libc::c_int as libc::c_ulong
5584 {
5585 sdsfree(ts);
5586 current_block = 12222187880575376610;
5587 } else {
5588 sdsfree(ts);
5589 current_block = 15619007995458559411;
5590 }
5591 } else {
5592 current_block = 15619007995458559411;
5593 }
5594 match current_block {
5595 15619007995458559411 => {
5596 if !(rewriteFunctions(aof) == 0 as libc::c_int) {
5597 j = 0 as libc::c_int;
5598 's_39: loop {
5599 if !(j < server.dbnum) {
5600 current_block = 8835654301469918283;
5601 break;
5602 }
5603 let mut selectcmd: UnsafeCell<[libc::c_char; 17]> = UnsafeCell::new([
5604 b'*'.try_into().unwrap(), b'2'.try_into().unwrap(), b'\r'.try_into().unwrap(), b'\n'.try_into().unwrap(), b'$'.try_into().unwrap(), b'6'.try_into().unwrap(), b'\r'.try_into().unwrap(), b'\n'.try_into().unwrap(), b'S'.try_into().unwrap(), b'E'.try_into().unwrap(), b'L'.try_into().unwrap(),
5605 b'E'.try_into().unwrap(), b'C'.try_into().unwrap(), b'T'.try_into().unwrap(), b'\r'.try_into().unwrap(), b'\n'.try_into().unwrap(), b'\0'.try_into().unwrap(),
5606 ]);
5607 let mut db: *mut redisDb = (server.db).offset(j as isize);
5608 let mut d: *mut dict = (*db).dict;
5609 if !(((*d).ht_used[0 as libc::c_int as usize])
5610 .wrapping_add((*d).ht_used[1 as libc::c_int as usize])
5611 == 0 as libc::c_int as libc::c_ulong)
5612 {
5613 di = dictGetSafeIterator(d);
5614 if rioWrite(
5615 aof,
5616 selectcmd.get() as *const libc::c_void,
5617 (core::mem::size_of::<[libc::c_char; 17]>()
5618 as libc::c_ulong)
5619 .wrapping_sub(1 as libc::c_int as libc::c_ulong),
5620 ) == 0 as libc::c_int as libc::c_ulong
5621 {
5622 current_block = 12222187880575376610;
5623 break;
5624 }
5625 if rioWriteBulkLongLong(aof, j as libc::c_longlong)
5626 == 0 as libc::c_int as libc::c_ulong
5627 {
5628 current_block = 12222187880575376610;
5629 break;
5630 }
5631 loop {
5632 de = dictNext(di);
5633 if de.is_null() {
5634 break;
5635 }
5636 let mut keystr: sds = 0 as *mut libc::c_char;
5637 let mut key: robj = robj {
5638 type_0_encoding_lru: [0; 4],
5639 refcount: 0,
5640 ptr: 0 as *mut libc::c_void,
5641 };
5642 let mut o: *mut robj = 0 as *mut robj;
5643 let mut expiretime: libc::c_longlong = 0;
5644 let mut aof_bytes_before_key: size_t = (*aof)
5645 .processed_bytes;
5646 keystr = (*de).key as sds;
5647 o = (*de).v.val as *mut robj;
5648 key.refcount = 2147483647 as libc::c_int - 1 as libc::c_int;
5649 key.set_type_0(0 as libc::c_int as libc::c_uint);
5650 key.set_encoding(0 as libc::c_int as libc::c_uint);
5651 key.ptr = keystr as *mut libc::c_void;
5652 expiretime = getExpire(db, &mut key);
5653 if (*o).type_0() as libc::c_int == 0 as libc::c_int {
5654 let mut cmd: [libc::c_char; 14] = *unsafe {
5655 std::cell::UnsafeCell::new(b"*3\r\n$3\r\nSET\r\n\0").get()
5656 as *mut [libc::c_char; 14]
5657 };
5658 if rioWrite(
5659 aof,
5660 cmd.as_mut_ptr() as *const libc::c_void,
5661 (core::mem::size_of::<[libc::c_char; 14]>()
5662 as libc::c_ulong)
5663 .wrapping_sub(1 as libc::c_int as libc::c_ulong),
5664 ) == 0 as libc::c_int as libc::c_ulong
5665 {
5666 current_block = 12222187880575376610;
5667 break 's_39;
5668 }
5669 if rioWriteBulkObject(aof, &mut key) == 0 as libc::c_int {
5670 current_block = 12222187880575376610;
5671 break 's_39;
5672 }
5673 if rioWriteBulkObject(aof, o) == 0 as libc::c_int {
5674 current_block = 12222187880575376610;
5675 break 's_39;
5676 }
5677 } else if (*o).type_0() as libc::c_int == 1 as libc::c_int {
5678 if rewriteListObject(aof, &mut key, o) == 0 as libc::c_int {
5679 current_block = 12222187880575376610;
5680 break 's_39;
5681 }
5682 } else if (*o).type_0() as libc::c_int == 2 as libc::c_int {
5683 if rewriteSetObject(aof, &mut key, o) == 0 as libc::c_int {
5684 current_block = 12222187880575376610;
5685 break 's_39;
5686 }
5687 } else if (*o).type_0() as libc::c_int == 3 as libc::c_int {
5688 if rewriteSortedSetObject(aof, &mut key, o)
5689 == 0 as libc::c_int
5690 {
5691 current_block = 12222187880575376610;
5692 break 's_39;
5693 }
5694 } else if (*o).type_0() as libc::c_int == 4 as libc::c_int {
5695 if rewriteHashObject(aof, &mut key, o) == 0 as libc::c_int {
5696 current_block = 12222187880575376610;
5697 break 's_39;
5698 }
5699 } else if (*o).type_0() as libc::c_int == 6 as libc::c_int {
5700 if rewriteStreamObject(aof, &mut key, o) == 0 as libc::c_int
5701 {
5702 current_block = 12222187880575376610;
5703 break 's_39;
5704 }
5705 } else if (*o).type_0() as libc::c_int == 5 as libc::c_int {
5706 if rewriteModuleObject(aof, &mut key, o, j)
5707 == 0 as libc::c_int
5708 {
5709 current_block = 12222187880575376610;
5710 break 's_39;
5711 }
5712 } else {
5713 _serverPanic(
5714 b"aof.c\0" as *const u8 as *const libc::c_char,
5715 2298 as libc::c_int,
5716 b"Unknown object type\0" as *const u8 as *const libc::c_char,
5717 );
5718 unreachable!();
5719 }
5720 let mut dump_size: size_t = ((*aof).processed_bytes)
5721 .wrapping_sub(aof_bytes_before_key);
5722 if server.in_fork_child != 0 {
5723 dismissObject(o, dump_size);
5724 }
5725 if expiretime != -(1 as libc::c_int) as libc::c_longlong {
5726 let mut cmd_0: [libc::c_char; 14] = *unsafe {
5727 std::cell::UnsafeCell::new(b"*3\r\n$3\r\nSET\r\n\0").get()
5728 as *mut [libc::c_char; 14]
5729 };
5730 if rioWrite(
5731 aof,
5732 cmd_0.as_mut_ptr() as *const libc::c_void,
5733 (core::mem::size_of::<[libc::c_char; 20]>()
5734 as libc::c_ulong)
5735 .wrapping_sub(1 as libc::c_int as libc::c_ulong),
5736 ) == 0 as libc::c_int as libc::c_ulong
5737 {
5738 current_block = 12222187880575376610;
5739 break 's_39;
5740 }
5741 if rioWriteBulkObject(aof, &mut key) == 0 as libc::c_int {
5742 current_block = 12222187880575376610;
5743 break 's_39;
5744 }
5745 if rioWriteBulkLongLong(aof, expiretime)
5746 == 0 as libc::c_int as libc::c_ulong
5747 {
5748 current_block = 12222187880575376610;
5749 break 's_39;
5750 }
5751 }
5752 let fresh8 = key_count;
5753 key_count = key_count + 1;
5754 if fresh8 & 1023 as libc::c_int as libc::c_long
5755 == 0 as libc::c_int as libc::c_long
5756 {
5757 let mut now: libc::c_longlong = mstime();
5758 if now - updated_time
5759 >= 1000 as libc::c_int as libc::c_longlong
5760 {
5761 sendChildInfo(
5762 CHILD_INFO_TYPE_CURRENT_INFO,
5763 key_count as size_t,
5764 b"AOF rewrite\0" as *const u8 as *const libc::c_char
5765 as *mut libc::c_char,
5766 );
5767 updated_time = now;
5768 }
5769 }
5770 if server.rdb_key_save_delay != 0 {
5771 debugDelay(server.rdb_key_save_delay);
5772 }
5773 }
5774 dictReleaseIterator(di);
5775 di = 0 as *mut dictIterator;
5776 }
5777 j += 1;
5778 }
5779 match current_block {
5780 12222187880575376610 => {}
5781 _ => return 0 as libc::c_int,
5782 }
5783 }
5784 }
5785 _ => {}
5786 }
5787 if !di.is_null() {
5788 dictReleaseIterator(di);
5789 }
5790 return -(1 as libc::c_int);
5791}
5792#[no_mangle]
5793pub unsafe extern "C" fn rewriteAppendOnlyFile(
5794 mut filename: *mut libc::c_char,
5795) -> libc::c_int {
5796 let mut current_block: u64;
5797 let mut aof: rio = rio {
5798 read: None,
5799 write: None,
5800 tell: None,
5801 flush: None,
5802 update_cksum: None,
5803 cksum: 0,
5804 flags: 0,
5805 processed_bytes: 0,
5806 max_processing_chunk: 0,
5807 io: C2RustUnnamed {
5808 buffer: C2RustUnnamed_3 {
5809 ptr: 0 as *mut libc::c_char,
5810 pos: 0,
5811 },
5812 },
5813 };
5814 let mut fp: *mut FILE = 0 as *mut FILE;
5815 let mut tmpfile: [libc::c_char; 256] = [0; 256];
5816 snprintf(
5817 tmpfile.as_mut_ptr(),
5818 256 as libc::c_int as libc::c_ulong,
5819 b"temp-rewriteaof-%d.aof\0" as *const u8 as *const libc::c_char,
5820 getpid(),
5821 );
5822 fp = fopen(tmpfile.as_mut_ptr(), b"w\0" as *const u8 as *const libc::c_char);
5823 if fp.is_null() {
5824 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
5825 _serverLog(
5826 3 as libc::c_int,
5827 b"Opening the temp file for AOF rewrite in rewriteAppendOnlyFile(): %s\0"
5828 as *const u8 as *const libc::c_char,
5829 strerror(*__errno_location()),
5830 );
5831 }
5832 return -(1 as libc::c_int);
5833 }
5834 rioInitWithFile(&mut aof, fp);
5835 if server.aof_rewrite_incremental_fsync != 0 {
5836 rioSetAutoSync(
5837 &mut aof,
5838 (1024 as libc::c_int * 1024 as libc::c_int * 4 as libc::c_int) as off_t,
5839 );
5840 }
5841 startSaving((1 as libc::c_int) << 0 as libc::c_int);
5842 if server.aof_use_rdb_preamble != 0 {
5843 let mut error: libc::c_int = 0;
5844 if rdbSaveRio(
5845 0 as libc::c_int,
5846 &mut aof,
5847 &mut error,
5848 (1 as libc::c_int) << 0 as libc::c_int,
5849 0 as *mut rdbSaveInfo,
5850 ) == -(1 as libc::c_int)
5851 {
5852 *__errno_location() = error;
5853 current_block = 18217938798896821909;
5854 } else {
5855 current_block = 1054647088692577877;
5856 }
5857 } else if rewriteAppendOnlyFileRio(&mut aof) == -(1 as libc::c_int) {
5858 current_block = 18217938798896821909;
5859 } else {
5860 current_block = 1054647088692577877;
5861 }
5862 match current_block {
5863 1054647088692577877 => {
5864 if !(fflush(fp) != 0) {
5865 if !(fsync(fileno(fp)) != 0) {
5866 if fclose(fp) != 0 {
5867 fp = 0 as *mut FILE;
5868 } else {
5869 fp = 0 as *mut FILE;
5870 if rename(tmpfile.as_mut_ptr(), filename) == -(1 as libc::c_int)
5871 {
5872 if !((3 as libc::c_int & 0xff as libc::c_int)
5873 < server.verbosity)
5874 {
5875 _serverLog(
5876 3 as libc::c_int,
5877 b"Error moving temp append only file on the final destination: %s\0"
5878 as *const u8 as *const libc::c_char,
5879 strerror(*__errno_location()),
5880 );
5881 }
5882 unlink(tmpfile.as_mut_ptr());
5883 stopSaving(0 as libc::c_int);
5884 return -(1 as libc::c_int);
5885 }
5886 stopSaving(1 as libc::c_int);
5887 return 0 as libc::c_int;
5888 }
5889 }
5890 }
5891 }
5892 _ => {}
5893 }
5894 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
5895 _serverLog(
5896 3 as libc::c_int,
5897 b"Write error writing append only file on disk: %s\0" as *const u8
5898 as *const libc::c_char,
5899 strerror(*__errno_location()),
5900 );
5901 }
5902 if !fp.is_null() {
5903 fclose(fp);
5904 }
5905 unlink(tmpfile.as_mut_ptr());
5906 stopSaving(0 as libc::c_int);
5907 return -(1 as libc::c_int);
5908}
5909#[no_mangle]
5910pub unsafe extern "C" fn rewriteAppendOnlyFileBackground() -> libc::c_int {
5911 let mut childpid: pid_t = 0;
5912 if hasActiveChildProcess() != 0 {
5913 return -(1 as libc::c_int);
5914 }
5915 if dirCreateIfMissing(server.aof_dirname) == -(1 as libc::c_int) {
5916 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
5917 _serverLog(
5918 3 as libc::c_int,
5919 b"Can't open or create append-only dir %s: %s\0" as *const u8
5920 as *const libc::c_char,
5921 server.aof_dirname,
5922 strerror(*__errno_location()),
5923 );
5924 }
5925 server.aof_lastbgrewrite_status = -(1 as libc::c_int);
5926 return -(1 as libc::c_int);
5927 }
5928 server.aof_selected_db = -(1 as libc::c_int);
5929 flushAppendOnlyFile(1 as libc::c_int);
5930 if openNewIncrAofForAppend() != 0 as libc::c_int {
5931 server.aof_lastbgrewrite_status = -(1 as libc::c_int);
5932 return -(1 as libc::c_int);
5933 }
5934 server.stat_aof_rewrites += 1;
5935 childpid = redisFork(2 as libc::c_int);
5936 if childpid == 0 as libc::c_int {
5937 let mut tmpfile: [libc::c_char; 256] = [0; 256];
5938 redisSetProcTitle(
5939 b"redis-aof-rewrite\0" as *const u8 as *const libc::c_char
5940 as *mut libc::c_char,
5941 );
5942 redisSetCpuAffinity(server.aof_rewrite_cpulist);
5943 snprintf(
5944 tmpfile.as_mut_ptr(),
5945 256 as libc::c_int as libc::c_ulong,
5946 b"temp-rewriteaof-bg-%d.aof\0" as *const u8 as *const libc::c_char,
5947 getpid(),
5948 );
5949 if rewriteAppendOnlyFile(tmpfile.as_mut_ptr()) == 0 as libc::c_int {
5950 if !((2 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
5951 _serverLog(
5952 2 as libc::c_int,
5953 b"Successfully created the temporary AOF base file %s\0" as *const u8
5954 as *const libc::c_char,
5955 tmpfile.as_mut_ptr(),
5956 );
5957 }
5958 sendChildCowInfo(
5959 CHILD_INFO_TYPE_AOF_COW_SIZE,
5960 b"AOF rewrite\0" as *const u8 as *const libc::c_char as *mut libc::c_char,
5961 );
5962 exitFromChild(0 as libc::c_int);
5963 } else {
5964 exitFromChild(1 as libc::c_int);
5965 }
5966 } else {
5967 if childpid == -(1 as libc::c_int) {
5968 server.aof_lastbgrewrite_status = -(1 as libc::c_int);
5969 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
5970 _serverLog(
5971 3 as libc::c_int,
5972 b"Can't rewrite append only file in background: fork: %s\0"
5973 as *const u8 as *const libc::c_char,
5974 strerror(*__errno_location()),
5975 );
5976 }
5977 return -(1 as libc::c_int);
5978 }
5979 if !((2 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
5980 _serverLog(
5981 2 as libc::c_int,
5982 b"Background append only file rewriting started by pid %ld\0"
5983 as *const u8 as *const libc::c_char,
5984 childpid as libc::c_long,
5985 );
5986 }
5987 server.aof_rewrite_scheduled = 0 as libc::c_int;
5988 server.aof_rewrite_time_start = time(0 as *mut time_t);
5989 return 0 as libc::c_int;
5990 }
5991 return 0 as libc::c_int;
5992}
5993#[no_mangle]
5994pub unsafe extern "C" fn bgrewriteaofCommand(mut c: *mut client) {
5995 if server.child_type == 2 as libc::c_int {
5996 addReplyError(
5997 c,
5998 b"Background append only file rewriting already in progress\0" as *const u8
5999 as *const libc::c_char,
6000 );
6001 } else if hasActiveChildProcess() != 0 || server.in_exec != 0 {
6002 server.aof_rewrite_scheduled = 1 as libc::c_int;
6003 server.stat_aofrw_consecutive_failures = 0 as libc::c_int as libc::c_longlong;
6004 addReplyStatus(
6005 c,
6006 b"Background append only file rewriting scheduled\0" as *const u8
6007 as *const libc::c_char,
6008 );
6009 } else if rewriteAppendOnlyFileBackground() == 0 as libc::c_int {
6010 addReplyStatus(
6011 c,
6012 b"Background append only file rewriting started\0" as *const u8
6013 as *const libc::c_char,
6014 );
6015 } else {
6016 addReplyError(
6017 c,
6018 b"Can't execute an AOF background rewriting. Please check the server logs for more information.\0"
6019 as *const u8 as *const libc::c_char,
6020 );
6021 };
6022}
6023#[no_mangle]
6024pub unsafe extern "C" fn aofRemoveTempFile(mut childpid: pid_t) {
6025 let mut tmpfile: [libc::c_char; 256] = [0; 256];
6026 snprintf(
6027 tmpfile.as_mut_ptr(),
6028 256 as libc::c_int as libc::c_ulong,
6029 b"temp-rewriteaof-bg-%d.aof\0" as *const u8 as *const libc::c_char,
6030 childpid,
6031 );
6032 bg_unlink(tmpfile.as_mut_ptr());
6033 snprintf(
6034 tmpfile.as_mut_ptr(),
6035 256 as libc::c_int as libc::c_ulong,
6036 b"temp-rewriteaof-%d.aof\0" as *const u8 as *const libc::c_char,
6037 childpid,
6038 );
6039 bg_unlink(tmpfile.as_mut_ptr());
6040}
6041#[no_mangle]
6042pub unsafe extern "C" fn getAppendOnlyFileSize(
6043 mut filename: sds,
6044 mut status: *mut libc::c_int,
6045) -> off_t {
6046 let mut sb: stat = stat {
6047 st_dev: 0,
6048 st_ino: 0,
6049 st_mode: 0,
6050 st_nlink: 0,
6051 st_uid: 0,
6052 st_gid: 0,
6053 st_rdev: 0,
6054 __pad1: 0,
6055 st_size: 0,
6056 st_blksize: 0,
6057 __pad2: 0,
6058 st_blocks: 0,
6059 st_atim: timespec { tv_sec: 0, tv_nsec: 0 },
6060 st_mtim: timespec { tv_sec: 0, tv_nsec: 0 },
6061 st_ctim: timespec { tv_sec: 0, tv_nsec: 0 },
6062 __glibc_reserved: [0; 2],
6063 };
6064 let mut size: off_t = 0;
6065 let mut latency: mstime_t = 0;
6066 let mut aof_filepath: sds = makePath(server.aof_dirname, filename);
6067 if server.latency_monitor_threshold != 0 {
6068 latency = mstime();
6069 } else {
6070 latency = 0 as libc::c_int as mstime_t;
6071 }
6072 if stat(aof_filepath as *const libc::c_char, &mut sb) == -(1 as libc::c_int) {
6073 if !status.is_null() {
6074 *status = if *__errno_location() == 2 as libc::c_int {
6075 1 as libc::c_int
6076 } else {
6077 3 as libc::c_int
6078 };
6079 }
6080 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
6081 _serverLog(
6082 3 as libc::c_int,
6083 b"Unable to obtain the AOF file %s length. stat: %s\0" as *const u8
6084 as *const libc::c_char,
6085 filename,
6086 strerror(*__errno_location()),
6087 );
6088 }
6089 size = 0 as libc::c_int as off_t;
6090 } else {
6091 if !status.is_null() {
6092 *status = 0 as libc::c_int;
6093 }
6094 size = sb.st_size;
6095 }
6096 if server.latency_monitor_threshold != 0 {
6097 latency = mstime() - latency;
6098 }
6099 if server.latency_monitor_threshold != 0
6100 && latency >= server.latency_monitor_threshold
6101 {
6102 latencyAddSample(b"aof-fstat\0" as *const u8 as *const libc::c_char, latency);
6103 }
6104 sdsfree(aof_filepath);
6105 return size;
6106}
6107#[no_mangle]
6108pub unsafe extern "C" fn getBaseAndIncrAppendOnlyFilesSize(
6109 mut am: *mut aofManifest,
6110 mut status: *mut libc::c_int,
6111) -> off_t {
6112 let mut size: off_t = 0 as libc::c_int as off_t;
6113 let mut ln: *mut listNode = 0 as *mut listNode;
6114 let mut li: listIter = listIter {
6115 next: 0 as *mut listNode,
6116 direction: 0,
6117 };
6118 if !((*am).base_aof_info).is_null() {
6119 if (*(*am).base_aof_info).file_type as libc::c_uint
6120 == AOF_FILE_TYPE_BASE as libc::c_int as libc::c_uint
6121 {} else {
6122 _serverAssert(
6123 b"am->base_aof_info->file_type == AOF_FILE_TYPE_BASE\0" as *const u8
6124 as *const libc::c_char,
6125 b"aof.c\0" as *const u8 as *const libc::c_char,
6126 2536 as libc::c_int,
6127 );
6128 unreachable!();
6129 };
6130 size += getAppendOnlyFileSize((*(*am).base_aof_info).file_name, status);
6131 if *status != 0 as libc::c_int {
6132 return 0 as libc::c_int as off_t;
6133 }
6134 }
6135 listRewind((*am).incr_aof_list, &mut li);
6136 loop {
6137 ln = listNext(&mut li);
6138 if ln.is_null() {
6139 break;
6140 }
6141 let mut ai: *mut aofInfo = (*ln).value as *mut aofInfo;
6142 if (*ai).file_type as libc::c_uint
6143 == AOF_FILE_TYPE_INCR as libc::c_int as libc::c_uint
6144 {} else {
6145 _serverAssert(
6146 b"ai->file_type == AOF_FILE_TYPE_INCR\0" as *const u8
6147 as *const libc::c_char,
6148 b"aof.c\0" as *const u8 as *const libc::c_char,
6149 2545 as libc::c_int,
6150 );
6151 unreachable!();
6152 };
6153 size += getAppendOnlyFileSize((*ai).file_name, status);
6154 if *status != 0 as libc::c_int {
6155 return 0 as libc::c_int as off_t;
6156 }
6157 }
6158 return size;
6159}
6160#[no_mangle]
6161pub unsafe extern "C" fn getBaseAndIncrAppendOnlyFilesNum(
6162 mut am: *mut aofManifest,
6163) -> libc::c_int {
6164 let mut num: libc::c_int = 0 as libc::c_int;
6165 if !((*am).base_aof_info).is_null() {
6166 num += 1;
6167 }
6168 if !((*am).incr_aof_list).is_null() {
6169 num = (num as libc::c_ulong).wrapping_add((*(*am).incr_aof_list).len)
6170 as libc::c_int as libc::c_int;
6171 }
6172 return num;
6173}
6174#[no_mangle]
6175pub unsafe extern "C" fn backgroundRewriteDoneHandler(
6176 mut exitcode: libc::c_int,
6177 mut bysignal: libc::c_int,
6178) {
6179 let mut current_block: u64;
6180 if bysignal == 0 && exitcode == 0 as libc::c_int {
6181 let mut tmpfile: [libc::c_char; 256] = [0; 256];
6182 let mut now: libc::c_longlong = ustime();
6183 let mut new_base_filepath: sds = 0 as sds;
6184 let mut new_incr_filepath: sds = 0 as sds;
6185 let mut temp_am: *mut aofManifest = 0 as *mut aofManifest;
6186 let mut latency: mstime_t = 0;
6187 if !((2 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
6188 _serverLog(
6189 2 as libc::c_int,
6190 b"Background AOF rewrite terminated with success\0" as *const u8
6191 as *const libc::c_char,
6192 );
6193 }
6194 snprintf(
6195 tmpfile.as_mut_ptr(),
6196 256 as libc::c_int as libc::c_ulong,
6197 b"temp-rewriteaof-bg-%d.aof\0" as *const u8 as *const libc::c_char,
6198 server.child_pid,
6199 );
6200 if !(server.aof_manifest).is_null() {} else {
6201 _serverAssert(
6202 b"server.aof_manifest != NULL\0" as *const u8 as *const libc::c_char,
6203 b"aof.c\0" as *const u8 as *const libc::c_char,
6204 2577 as libc::c_int,
6205 );
6206 unreachable!();
6207 };
6208 temp_am = aofManifestDup(server.aof_manifest);
6209 let mut new_base_filename: sds = getNewBaseFileNameAndMarkPreAsHistory(temp_am);
6210 if !new_base_filename.is_null() {} else {
6211 _serverAssert(
6212 b"new_base_filename != NULL\0" as *const u8 as *const libc::c_char,
6213 b"aof.c\0" as *const u8 as *const libc::c_char,
6214 2585 as libc::c_int,
6215 );
6216 unreachable!();
6217 };
6218 new_base_filepath = makePath(server.aof_dirname, new_base_filename);
6219 if server.latency_monitor_threshold != 0 {
6220 latency = mstime();
6221 } else {
6222 latency = 0 as libc::c_int as mstime_t;
6223 }
6224 if rename(tmpfile.as_mut_ptr(), new_base_filepath as *const libc::c_char)
6225 == -(1 as libc::c_int)
6226 {
6227 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
6228 _serverLog(
6229 3 as libc::c_int,
6230 b"Error trying to rename the temporary AOF base file %s into %s: %s\0"
6231 as *const u8 as *const libc::c_char,
6232 tmpfile.as_mut_ptr(),
6233 new_base_filepath,
6234 strerror(*__errno_location()),
6235 );
6236 }
6237 aofManifestFree(temp_am);
6238 sdsfree(new_base_filepath);
6239 server.aof_lastbgrewrite_status = -(1 as libc::c_int);
6240 server.stat_aofrw_consecutive_failures += 1;
6241 } else {
6242 if server.latency_monitor_threshold != 0 {
6243 latency = mstime() - latency;
6244 }
6245 if server.latency_monitor_threshold != 0
6246 && latency >= server.latency_monitor_threshold
6247 {
6248 latencyAddSample(
6249 b"aof-rename\0" as *const u8 as *const libc::c_char,
6250 latency,
6251 );
6252 }
6253 if !((2 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
6254 _serverLog(
6255 2 as libc::c_int,
6256 b"Successfully renamed the temporary AOF base file %s into %s\0"
6257 as *const u8 as *const libc::c_char,
6258 tmpfile.as_mut_ptr(),
6259 new_base_filename,
6260 );
6261 }
6262 if server.aof_state == 2 as libc::c_int {
6263 let mut temp_incr_aof_name: sds = getTempIncrAofName();
6264 let mut temp_incr_filepath: sds = makePath(
6265 server.aof_dirname,
6266 temp_incr_aof_name,
6267 );
6268 let mut new_incr_filename: sds = getNewIncrAofName(temp_am);
6269 new_incr_filepath = makePath(server.aof_dirname, new_incr_filename);
6270 if server.latency_monitor_threshold != 0 {
6271 latency = mstime();
6272 } else {
6273 latency = 0 as libc::c_int as mstime_t;
6274 }
6275 if rename(
6276 temp_incr_filepath as *const libc::c_char,
6277 new_incr_filepath as *const libc::c_char,
6278 ) == -(1 as libc::c_int)
6279 {
6280 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
6281 _serverLog(
6282 3 as libc::c_int,
6283 b"Error trying to rename the temporary AOF incr file %s into %s: %s\0"
6284 as *const u8 as *const libc::c_char,
6285 temp_incr_filepath,
6286 new_incr_filepath,
6287 strerror(*__errno_location()),
6288 );
6289 }
6290 bg_unlink(new_base_filepath as *const libc::c_char);
6291 sdsfree(new_base_filepath);
6292 aofManifestFree(temp_am);
6293 sdsfree(temp_incr_filepath);
6294 sdsfree(new_incr_filepath);
6295 sdsfree(temp_incr_aof_name);
6296 server.aof_lastbgrewrite_status = -(1 as libc::c_int);
6297 server.stat_aofrw_consecutive_failures += 1;
6298 current_block = 14400478195970198768;
6299 } else {
6300 if server.latency_monitor_threshold != 0 {
6301 latency = mstime() - latency;
6302 }
6303 if server.latency_monitor_threshold != 0
6304 && latency >= server.latency_monitor_threshold
6305 {
6306 latencyAddSample(
6307 b"aof-rename\0" as *const u8 as *const libc::c_char,
6308 latency,
6309 );
6310 }
6311 if !((2 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
6312 _serverLog(
6313 2 as libc::c_int,
6314 b"Successfully renamed the temporary AOF incr file %s into %s\0"
6315 as *const u8 as *const libc::c_char,
6316 temp_incr_aof_name,
6317 new_incr_filename,
6318 );
6319 }
6320 sdsfree(temp_incr_filepath);
6321 sdsfree(temp_incr_aof_name);
6322 current_block = 5235537862154438448;
6323 }
6324 } else {
6325 current_block = 5235537862154438448;
6326 }
6327 match current_block {
6328 14400478195970198768 => {}
6329 _ => {
6330 markRewrittenIncrAofAsHistory(temp_am);
6331 if persistAofManifest(temp_am) == -(1 as libc::c_int) {
6332 bg_unlink(new_base_filepath as *const libc::c_char);
6333 aofManifestFree(temp_am);
6334 sdsfree(new_base_filepath);
6335 if !new_incr_filepath.is_null() {
6336 bg_unlink(new_incr_filepath as *const libc::c_char);
6337 sdsfree(new_incr_filepath);
6338 }
6339 server.aof_lastbgrewrite_status = -(1 as libc::c_int);
6340 server.stat_aofrw_consecutive_failures += 1;
6341 } else {
6342 sdsfree(new_base_filepath);
6343 if !new_incr_filepath.is_null() {
6344 sdsfree(new_incr_filepath);
6345 }
6346 aofManifestFreeAndUpdate(temp_am);
6347 if server.aof_fd != -(1 as libc::c_int) {
6348 server.aof_selected_db = -(1 as libc::c_int);
6349 server
6350 .aof_current_size = getAppendOnlyFileSize(
6351 new_base_filename,
6352 0 as *mut libc::c_int,
6353 ) + server.aof_last_incr_size;
6354 server.aof_rewrite_base_size = server.aof_current_size;
6355 server.aof_fsync_offset = server.aof_current_size;
6356 server.aof_last_fsync = server.unixtime as time_t;
6357 }
6358 aofDelHistoryFiles();
6359 server.aof_lastbgrewrite_status = 0 as libc::c_int;
6360 server
6361 .stat_aofrw_consecutive_failures = 0 as libc::c_int
6362 as libc::c_longlong;
6363 if !((2 as libc::c_int & 0xff as libc::c_int) < server.verbosity)
6364 {
6365 _serverLog(
6366 2 as libc::c_int,
6367 b"Background AOF rewrite finished successfully\0"
6368 as *const u8 as *const libc::c_char,
6369 );
6370 }
6371 if server.aof_state == 2 as libc::c_int {
6372 server.aof_state = 1 as libc::c_int;
6373 }
6374 if !((1 as libc::c_int & 0xff as libc::c_int) < server.verbosity)
6375 {
6376 _serverLog(
6377 1 as libc::c_int,
6378 b"Background AOF rewrite signal handler took %lldus\0"
6379 as *const u8 as *const libc::c_char,
6380 ustime() - now,
6381 );
6382 }
6383 }
6384 }
6385 }
6386 }
6387 } else if bysignal == 0 && exitcode != 0 as libc::c_int {
6388 server.aof_lastbgrewrite_status = -(1 as libc::c_int);
6389 server.stat_aofrw_consecutive_failures += 1;
6390 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
6391 _serverLog(
6392 3 as libc::c_int,
6393 b"Background AOF rewrite terminated with error\0" as *const u8
6394 as *const libc::c_char,
6395 );
6396 }
6397 } else {
6398 if bysignal != 10 as libc::c_int {
6399 server.aof_lastbgrewrite_status = -(1 as libc::c_int);
6400 server.stat_aofrw_consecutive_failures += 1;
6401 }
6402 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
6403 _serverLog(
6404 3 as libc::c_int,
6405 b"Background AOF rewrite terminated by signal %d\0" as *const u8
6406 as *const libc::c_char,
6407 bysignal,
6408 );
6409 }
6410 }
6411 aofRemoveTempFile(server.child_pid);
6412 if server.aof_state == 2 as libc::c_int {
6413 sdsfree(server.aof_buf);
6414 server.aof_buf = sdsempty();
6415 aofDelTempIncrAofFile();
6416 }
6417 server
6418 .aof_rewrite_time_last = time(0 as *mut time_t) - server.aof_rewrite_time_start;
6419 server.aof_rewrite_time_start = -(1 as libc::c_int) as time_t;
6420 if server.aof_state == 2 as libc::c_int {
6421 server.aof_rewrite_scheduled = 1 as libc::c_int;
6422 }
6423}