1extern crate c2rust_bitfields;
2extern crate libc;
3extern crate core;
4extern "C" {
5 pub type RedisModuleCommand;
6 pub type clusterSlotToKeyMapping;
7 pub type clusterState;
8 fn dictDelete(d: *mut dict, key: *const libc::c_void) -> libc::c_int;
9 fn dictAdd(
10 d: *mut dict,
11 key: *mut libc::c_void,
12 val: *mut libc::c_void,
13 ) -> libc::c_int;
14 fn dictFind(d: *mut dict, key: *const libc::c_void) -> *mut dictEntry;
15 fn dictFetchValue(d: *mut dict, key: *const libc::c_void) -> *mut libc::c_void;
16 fn dictGetSafeIterator(d: *mut dict) -> *mut dictIterator;
17 fn dictNext(iter: *mut dictIterator) -> *mut dictEntry;
18 fn dictReleaseIterator(iter: *mut dictIterator);
19 fn listCreate() -> *mut list;
20 fn listAddNodeTail(list: *mut list, value: *mut libc::c_void) -> *mut list;
21 fn listDelNode(list: *mut list, node: *mut listNode);
22 fn listNext(iter: *mut listIter) -> *mut listNode;
23 fn listSearchKey(list: *mut list, key: *mut libc::c_void) -> *mut listNode;
24 fn listRewind(list: *mut list, li: *mut listIter);
25 fn zmalloc(size: size_t) -> *mut libc::c_void;
26 fn zrealloc(ptr: *mut libc::c_void, size: size_t) -> *mut libc::c_void;
27 fn zfree(ptr: *mut libc::c_void);
28 static mut server: redisServer;
29 static mut shared: sharedObjectsStruct;
30 fn addReply(c: *mut client, obj: *mut robj);
31 fn addReplyErrorObject(c: *mut client, err: *mut robj);
32 fn addReplyError(c: *mut client, err: *const libc::c_char);
33 fn addReplyArrayLen(c: *mut client, length: libc::c_long);
34 fn addReplyErrorFormat(c: *mut client, fmt: *const libc::c_char, _: ...);
35 fn decrRefCount(o: *mut robj);
36 fn _serverAssertWithInfo(
37 c: *const client,
38 o: *const robj,
39 estr: *const libc::c_char,
40 file: *const libc::c_char,
41 line: libc::c_int,
42 );
43 fn equalStringObjects(a: *mut robj, b: *mut robj) -> libc::c_int;
44 fn keyIsExpired(db: *mut redisDb, key: *mut robj) -> libc::c_int;
45 fn replicationFeedMonitors(
46 c: *mut client,
47 monitors: *mut list,
48 dictid: libc::c_int,
49 argv: *mut *mut robj,
50 argc: libc::c_int,
51 );
52 fn incrRefCount(o: *mut robj);
53 fn ACLCheckAllPerm(c: *mut client, idxptr: *mut libc::c_int) -> libc::c_int;
54 fn addACLLogEntry(
55 c: *mut client,
56 reason: libc::c_int,
57 context: libc::c_int,
58 argpos: libc::c_int,
59 username: sds,
60 object: sds,
61 );
62 fn call(c: *mut client, flags: libc::c_int);
63 fn _serverAssert(
64 estr: *const libc::c_char,
65 file: *const libc::c_char,
66 line: libc::c_int,
67 );
68}
69pub type __int16_t = libc::c_short;
70pub type __int32_t = libc::c_int;
71pub type __uint32_t = libc::c_uint;
72pub type __int64_t = libc::c_long;
73pub type __uint64_t = libc::c_ulong;
74pub type __uint_least64_t = __uint64_t;
75pub type __mode_t = libc::c_uint;
76pub type __off64_t = libc::c_long;
77pub type __pid_t = libc::c_int;
78pub type __time_t = libc::c_long;
79pub type __ssize_t = libc::c_long;
80pub type __sig_atomic_t = libc::c_int;
81pub type size_t = libc::c_ulong;
82#[derive(Copy, Clone)]
83#[repr(C)]
84pub struct iovec {
85 pub iov_base: *mut libc::c_void,
86 pub iov_len: size_t,
87}
88pub type mode_t = __mode_t;
89pub type off_t = __off64_t;
90pub type pid_t = __pid_t;
91pub type ssize_t = __ssize_t;
92pub type time_t = __time_t;
93pub type int16_t = __int16_t;
94pub type int32_t = __int32_t;
95pub type int64_t = __int64_t;
96pub type pthread_t = libc::c_ulong;
97pub type uint32_t = __uint32_t;
98pub type uint64_t = __uint64_t;
99pub type uint_least64_t = __uint_least64_t;
100pub type sds = *mut libc::c_char;
101#[derive(Copy, Clone)]
102#[repr(C)]
103pub struct aeEventLoop {
104 pub maxfd: libc::c_int,
105 pub setsize: libc::c_int,
106 pub timeEventNextId: libc::c_longlong,
107 pub events: *mut aeFileEvent,
108 pub fired: *mut aeFiredEvent,
109 pub timeEventHead: *mut aeTimeEvent,
110 pub stop: libc::c_int,
111 pub apidata: *mut libc::c_void,
112 pub beforesleep: Option::<aeBeforeSleepProc>,
113 pub aftersleep: Option::<aeBeforeSleepProc>,
114 pub flags: libc::c_int,
115}
116pub type aeBeforeSleepProc = unsafe extern "C" fn(*mut aeEventLoop) -> ();
117#[derive(Copy, Clone)]
118#[repr(C)]
119pub struct aeTimeEvent {
120 pub id: libc::c_longlong,
121 pub when: monotime,
122 pub timeProc: Option::<aeTimeProc>,
123 pub finalizerProc: Option::<aeEventFinalizerProc>,
124 pub clientData: *mut libc::c_void,
125 pub prev: *mut aeTimeEvent,
126 pub next: *mut aeTimeEvent,
127 pub refcount: libc::c_int,
128}
129pub type aeEventFinalizerProc = unsafe extern "C" fn(
130 *mut aeEventLoop,
131 *mut libc::c_void,
132) -> ();
133pub type aeTimeProc = unsafe extern "C" fn(
134 *mut aeEventLoop,
135 libc::c_longlong,
136 *mut libc::c_void,
137) -> libc::c_int;
138pub type monotime = uint64_t;
139#[derive(Copy, Clone)]
140#[repr(C)]
141pub struct aeFiredEvent {
142 pub fd: libc::c_int,
143 pub mask: libc::c_int,
144}
145#[derive(Copy, Clone)]
146#[repr(C)]
147pub struct aeFileEvent {
148 pub mask: libc::c_int,
149 pub rfileProc: Option::<aeFileProc>,
150 pub wfileProc: Option::<aeFileProc>,
151 pub clientData: *mut libc::c_void,
152}
153pub type aeFileProc = unsafe extern "C" fn(
154 *mut aeEventLoop,
155 libc::c_int,
156 *mut libc::c_void,
157 libc::c_int,
158) -> ();
159#[derive(Copy, Clone)]
160#[repr(C)]
161pub struct connection {
162 pub type_0: *mut ConnectionType,
163 pub state: ConnectionState,
164 pub flags: libc::c_short,
165 pub refs: libc::c_short,
166 pub last_errno: libc::c_int,
167 pub private_data: *mut libc::c_void,
168 pub conn_handler: ConnectionCallbackFunc,
169 pub write_handler: ConnectionCallbackFunc,
170 pub read_handler: ConnectionCallbackFunc,
171 pub fd: libc::c_int,
172}
173pub type ConnectionCallbackFunc = Option::<unsafe extern "C" fn(*mut connection) -> ()>;
174pub type ConnectionState = libc::c_uint;
175pub const CONN_STATE_ERROR: ConnectionState = 5;
176pub const CONN_STATE_CLOSED: ConnectionState = 4;
177pub const CONN_STATE_CONNECTED: ConnectionState = 3;
178pub const CONN_STATE_ACCEPTING: ConnectionState = 2;
179pub const CONN_STATE_CONNECTING: ConnectionState = 1;
180pub const CONN_STATE_NONE: ConnectionState = 0;
181#[derive(Copy, Clone)]
182#[repr(C)]
183pub struct ConnectionType {
184 pub ae_handler: Option::<
185 unsafe extern "C" fn(
186 *mut aeEventLoop,
187 libc::c_int,
188 *mut libc::c_void,
189 libc::c_int,
190 ) -> (),
191 >,
192 pub connect: Option::<
193 unsafe extern "C" fn(
194 *mut connection,
195 *const libc::c_char,
196 libc::c_int,
197 *const libc::c_char,
198 ConnectionCallbackFunc,
199 ) -> libc::c_int,
200 >,
201 pub write: Option::<
202 unsafe extern "C" fn(*mut connection, *const libc::c_void, size_t) -> libc::c_int,
203 >,
204 pub writev: Option::<
205 unsafe extern "C" fn(*mut connection, *const iovec, libc::c_int) -> libc::c_int,
206 >,
207 pub read: Option::<
208 unsafe extern "C" fn(*mut connection, *mut libc::c_void, size_t) -> libc::c_int,
209 >,
210 pub close: Option::<unsafe extern "C" fn(*mut connection) -> ()>,
211 pub accept: Option::<
212 unsafe extern "C" fn(*mut connection, ConnectionCallbackFunc) -> libc::c_int,
213 >,
214 pub set_write_handler: Option::<
215 unsafe extern "C" fn(
216 *mut connection,
217 ConnectionCallbackFunc,
218 libc::c_int,
219 ) -> libc::c_int,
220 >,
221 pub set_read_handler: Option::<
222 unsafe extern "C" fn(*mut connection, ConnectionCallbackFunc) -> libc::c_int,
223 >,
224 pub get_last_error: Option::<
225 unsafe extern "C" fn(*mut connection) -> *const libc::c_char,
226 >,
227 pub blocking_connect: Option::<
228 unsafe extern "C" fn(
229 *mut connection,
230 *const libc::c_char,
231 libc::c_int,
232 libc::c_longlong,
233 ) -> libc::c_int,
234 >,
235 pub sync_write: Option::<
236 unsafe extern "C" fn(
237 *mut connection,
238 *mut libc::c_char,
239 ssize_t,
240 libc::c_longlong,
241 ) -> ssize_t,
242 >,
243 pub sync_read: Option::<
244 unsafe extern "C" fn(
245 *mut connection,
246 *mut libc::c_char,
247 ssize_t,
248 libc::c_longlong,
249 ) -> ssize_t,
250 >,
251 pub sync_readline: Option::<
252 unsafe extern "C" fn(
253 *mut connection,
254 *mut libc::c_char,
255 ssize_t,
256 libc::c_longlong,
257 ) -> ssize_t,
258 >,
259 pub get_type: Option::<unsafe extern "C" fn(*mut connection) -> libc::c_int>,
260}
261#[derive(Copy, Clone,c2rust_bitfields::BitfieldStruct)]
262#[repr(C)]
263pub struct redisObject {
264 #[bitfield(name = "type_0", ty = "libc::c_uint", bits = "0..=3")]
265 #[bitfield(name = "encoding", ty = "libc::c_uint", bits = "4..=7")]
266 #[bitfield(name = "lru", ty = "libc::c_uint", bits = "8..=31")]
267 pub type_0_encoding_lru: [u8; 4],
268 pub refcount: libc::c_int,
269 pub ptr: *mut libc::c_void,
270}
271pub type atomic_int = libc::c_int;
272pub type atomic_uint = libc::c_uint;
273pub type atomic_llong = libc::c_longlong;
274pub type sig_atomic_t = __sig_atomic_t;
275#[derive(Copy, Clone)]
276#[repr(C)]
277pub struct hdr_histogram {
278 pub lowest_discernible_value: int64_t,
279 pub highest_trackable_value: int64_t,
280 pub unit_magnitude: int32_t,
281 pub significant_figures: int32_t,
282 pub sub_bucket_half_count_magnitude: int32_t,
283 pub sub_bucket_half_count: int32_t,
284 pub sub_bucket_mask: int64_t,
285 pub sub_bucket_count: int32_t,
286 pub bucket_count: int32_t,
287 pub min_value: int64_t,
288 pub max_value: int64_t,
289 pub normalizing_index_offset: int32_t,
290 pub conversion_ratio: libc::c_double,
291 pub counts_len: int32_t,
292 pub total_count: int64_t,
293 pub counts: *mut int64_t,
294}
295pub type mstime_t = libc::c_longlong;
296pub type ustime_t = libc::c_longlong;
297#[derive(Copy, Clone)]
298#[repr(C)]
299pub struct dictEntry {
300 pub key: *mut libc::c_void,
301 pub v: C2RustUnnamed,
302 pub next: *mut dictEntry,
303 pub metadata: [*mut libc::c_void; 0],
304}
305#[derive(Copy, Clone)]
306#[repr(C)]
307pub union C2RustUnnamed {
308 pub val: *mut libc::c_void,
309 pub u64_0: uint64_t,
310 pub s64: int64_t,
311 pub d: libc::c_double,
312}
313#[derive(Copy, Clone)]
314#[repr(C)]
315pub struct dict {
316 pub type_0: *mut dictType,
317 pub ht_table: [*mut *mut dictEntry; 2],
318 pub ht_used: [libc::c_ulong; 2],
319 pub rehashidx: libc::c_long,
320 pub pauserehash: int16_t,
321 pub ht_size_exp: [libc::c_schar; 2],
322}
323#[derive(Copy, Clone)]
324#[repr(C)]
325pub struct dictType {
326 pub hashFunction: Option::<unsafe extern "C" fn(*const libc::c_void) -> uint64_t>,
327 pub keyDup: Option::<
328 unsafe extern "C" fn(*mut dict, *const libc::c_void) -> *mut libc::c_void,
329 >,
330 pub valDup: Option::<
331 unsafe extern "C" fn(*mut dict, *const libc::c_void) -> *mut libc::c_void,
332 >,
333 pub keyCompare: Option::<
334 unsafe extern "C" fn(
335 *mut dict,
336 *const libc::c_void,
337 *const libc::c_void,
338 ) -> libc::c_int,
339 >,
340 pub keyDestructor: Option::<
341 unsafe extern "C" fn(*mut dict, *mut libc::c_void) -> (),
342 >,
343 pub valDestructor: Option::<
344 unsafe extern "C" fn(*mut dict, *mut libc::c_void) -> (),
345 >,
346 pub expandAllowed: Option::<
347 unsafe extern "C" fn(size_t, libc::c_double) -> libc::c_int,
348 >,
349 pub dictEntryMetadataBytes: Option::<unsafe extern "C" fn(*mut dict) -> size_t>,
350}
351#[derive(Copy, Clone)]
352#[repr(C)]
353pub struct dictIterator {
354 pub d: *mut dict,
355 pub index: libc::c_long,
356 pub table: libc::c_int,
357 pub safe: libc::c_int,
358 pub entry: *mut dictEntry,
359 pub nextEntry: *mut dictEntry,
360 pub fingerprint: libc::c_ulonglong,
361}
362#[derive(Copy, Clone)]
363#[repr(C)]
364pub struct listNode {
365 pub prev: *mut listNode,
366 pub next: *mut listNode,
367 pub value: *mut libc::c_void,
368}
369#[derive(Copy, Clone)]
370#[repr(C)]
371pub struct listIter {
372 pub next: *mut listNode,
373 pub direction: libc::c_int,
374}
375#[derive(Copy, Clone)]
376#[repr(C)]
377pub struct list {
378 pub head: *mut listNode,
379 pub tail: *mut listNode,
380 pub dup: Option::<unsafe extern "C" fn(*mut libc::c_void) -> *mut libc::c_void>,
381 pub free: Option::<unsafe extern "C" fn(*mut libc::c_void) -> ()>,
382 pub match_0: Option::<
383 unsafe extern "C" fn(*mut libc::c_void, *mut libc::c_void) -> libc::c_int,
384 >,
385 pub len: libc::c_ulong,
386}
387#[derive(Copy, Clone,c2rust_bitfields::BitfieldStruct)]
388#[repr(C)]
389pub struct raxNode {
390 #[bitfield(name = "iskey", ty = "uint32_t", bits = "0..=0")]
391 #[bitfield(name = "isnull", ty = "uint32_t", bits = "1..=1")]
392 #[bitfield(name = "iscompr", ty = "uint32_t", bits = "2..=2")]
393 #[bitfield(name = "size", ty = "uint32_t", bits = "3..=31")]
394 pub iskey_isnull_iscompr_size: [u8; 4],
395 pub data: [libc::c_uchar; 0],
396}
397#[derive(Copy, Clone)]
398#[repr(C)]
399pub struct rax {
400 pub head: *mut raxNode,
401 pub numele: uint64_t,
402 pub numnodes: uint64_t,
403}
404pub type pause_type = libc::c_uint;
405pub const CLIENT_PAUSE_ALL: pause_type = 2;
406pub const CLIENT_PAUSE_WRITE: pause_type = 1;
407pub const CLIENT_PAUSE_OFF: pause_type = 0;
408#[derive(Copy, Clone)]
409#[repr(C)]
410pub struct pause_event {
411 pub type_0: pause_type,
412 pub end: mstime_t,
413}
414pub type robj = redisObject;
415pub type RedisModuleUserChangedFunc = Option::<
416 unsafe extern "C" fn(uint64_t, *mut libc::c_void) -> (),
417>;
418#[derive(Copy, Clone)]
419#[repr(C)]
420pub struct redisDb {
421 pub dict: *mut dict,
422 pub expires: *mut dict,
423 pub blocking_keys: *mut dict,
424 pub ready_keys: *mut dict,
425 pub watched_keys: *mut dict,
426 pub id: libc::c_int,
427 pub avg_ttl: libc::c_longlong,
428 pub expires_cursor: libc::c_ulong,
429 pub defrag_later: *mut list,
430 pub slots_to_keys: *mut clusterSlotToKeyMapping,
431}
432#[derive(Copy, Clone)]
433#[repr(C)]
434pub struct multiCmd {
435 pub argv: *mut *mut robj,
436 pub argv_len: libc::c_int,
437 pub argc: libc::c_int,
438 pub cmd: *mut redisCommand,
439}
440#[derive(Copy, Clone)]
441#[repr(C)]
442pub struct redisCommand {
443 pub declared_name: *const libc::c_char,
444 pub summary: *const libc::c_char,
445 pub complexity: *const libc::c_char,
446 pub since: *const libc::c_char,
447 pub doc_flags: libc::c_int,
448 pub replaced_by: *const libc::c_char,
449 pub deprecated_since: *const libc::c_char,
450 pub group: redisCommandGroup,
451 pub history: *mut commandHistory,
452 pub tips: *mut *const libc::c_char,
453 pub proc_0: Option::<redisCommandProc>,
454 pub arity: libc::c_int,
455 pub flags: uint64_t,
456 pub acl_categories: uint64_t,
457 pub key_specs_static: [keySpec; 4],
458 pub getkeys_proc: Option::<redisGetKeysProc>,
459 pub subcommands: *mut redisCommand,
460 pub args: *mut redisCommandArg,
461 pub microseconds: libc::c_longlong,
462 pub calls: libc::c_longlong,
463 pub rejected_calls: libc::c_longlong,
464 pub failed_calls: libc::c_longlong,
465 pub id: libc::c_int,
466 pub fullname: sds,
467 pub latency_histogram: *mut hdr_histogram,
468 pub key_specs: *mut keySpec,
469 pub legacy_range_key_spec: keySpec,
470 pub num_args: libc::c_int,
471 pub num_history: libc::c_int,
472 pub num_tips: libc::c_int,
473 pub key_specs_num: libc::c_int,
474 pub key_specs_max: libc::c_int,
475 pub subcommands_dict: *mut dict,
476 pub parent: *mut redisCommand,
477 pub module_cmd: *mut RedisModuleCommand,
478}
479#[derive(Copy, Clone)]
480#[repr(C)]
481pub struct keySpec {
482 pub notes: *const libc::c_char,
483 pub flags: uint64_t,
484 pub begin_search_type: kspec_bs_type,
485 pub bs: C2RustUnnamed_3,
486 pub find_keys_type: kspec_fk_type,
487 pub fk: C2RustUnnamed_0,
488}
489#[derive(Copy, Clone)]
490#[repr(C)]
491pub union C2RustUnnamed_0 {
492 pub range: C2RustUnnamed_2,
493 pub keynum: C2RustUnnamed_1,
494}
495#[derive(Copy, Clone)]
496#[repr(C)]
497pub struct C2RustUnnamed_1 {
498 pub keynumidx: libc::c_int,
499 pub firstkey: libc::c_int,
500 pub keystep: libc::c_int,
501}
502#[derive(Copy, Clone)]
503#[repr(C)]
504pub struct C2RustUnnamed_2 {
505 pub lastkey: libc::c_int,
506 pub keystep: libc::c_int,
507 pub limit: libc::c_int,
508}
509pub type kspec_fk_type = libc::c_uint;
510pub const KSPEC_FK_KEYNUM: kspec_fk_type = 3;
511pub const KSPEC_FK_RANGE: kspec_fk_type = 2;
512pub const KSPEC_FK_UNKNOWN: kspec_fk_type = 1;
513pub const KSPEC_FK_INVALID: kspec_fk_type = 0;
514#[derive(Copy, Clone)]
515#[repr(C)]
516pub union C2RustUnnamed_3 {
517 pub index: C2RustUnnamed_5,
518 pub keyword: C2RustUnnamed_4,
519}
520#[derive(Copy, Clone)]
521#[repr(C)]
522pub struct C2RustUnnamed_4 {
523 pub keyword: *const libc::c_char,
524 pub startfrom: libc::c_int,
525}
526#[derive(Copy, Clone)]
527#[repr(C)]
528pub struct C2RustUnnamed_5 {
529 pub pos: libc::c_int,
530}
531pub type kspec_bs_type = libc::c_uint;
532pub const KSPEC_BS_KEYWORD: kspec_bs_type = 3;
533pub const KSPEC_BS_INDEX: kspec_bs_type = 2;
534pub const KSPEC_BS_UNKNOWN: kspec_bs_type = 1;
535pub const KSPEC_BS_INVALID: kspec_bs_type = 0;
536#[derive(Copy, Clone)]
537#[repr(C)]
538pub struct redisCommandArg {
539 pub name: *const libc::c_char,
540 pub type_0: redisCommandArgType,
541 pub key_spec_index: libc::c_int,
542 pub token: *const libc::c_char,
543 pub summary: *const libc::c_char,
544 pub since: *const libc::c_char,
545 pub flags: libc::c_int,
546 pub deprecated_since: *const libc::c_char,
547 pub subargs: *mut redisCommandArg,
548 pub num_args: libc::c_int,
549}
550pub type redisCommandArgType = libc::c_uint;
551pub const ARG_TYPE_BLOCK: redisCommandArgType = 8;
552pub const ARG_TYPE_ONEOF: redisCommandArgType = 7;
553pub const ARG_TYPE_PURE_TOKEN: redisCommandArgType = 6;
554pub const ARG_TYPE_UNIX_TIME: redisCommandArgType = 5;
555pub const ARG_TYPE_PATTERN: redisCommandArgType = 4;
556pub const ARG_TYPE_KEY: redisCommandArgType = 3;
557pub const ARG_TYPE_DOUBLE: redisCommandArgType = 2;
558pub const ARG_TYPE_INTEGER: redisCommandArgType = 1;
559pub const ARG_TYPE_STRING: redisCommandArgType = 0;
560pub type redisGetKeysProc = unsafe extern "C" fn(
561 *mut redisCommand,
562 *mut *mut robj,
563 libc::c_int,
564 *mut getKeysResult,
565) -> libc::c_int;
566#[derive(Copy, Clone)]
567#[repr(C)]
568pub struct getKeysResult {
569 pub keysbuf: [keyReference; 256],
570 pub keys: *mut keyReference,
571 pub numkeys: libc::c_int,
572 pub size: libc::c_int,
573}
574#[derive(Copy, Clone)]
575#[repr(C)]
576pub struct keyReference {
577 pub pos: libc::c_int,
578 pub flags: libc::c_int,
579}
580pub type redisCommandProc = unsafe extern "C" fn(*mut client) -> ();
581#[derive(Copy, Clone)]
582#[repr(C)]
583pub struct client {
584 pub id: uint64_t,
585 pub flags: uint64_t,
586 pub conn: *mut connection,
587 pub resp: libc::c_int,
588 pub db: *mut redisDb,
589 pub name: *mut robj,
590 pub querybuf: sds,
591 pub qb_pos: size_t,
592 pub querybuf_peak: size_t,
593 pub argc: libc::c_int,
594 pub argv: *mut *mut robj,
595 pub argv_len: libc::c_int,
596 pub original_argc: libc::c_int,
597 pub original_argv: *mut *mut robj,
598 pub argv_len_sum: size_t,
599 pub cmd: *mut redisCommand,
600 pub lastcmd: *mut redisCommand,
601 pub realcmd: *mut redisCommand,
602 pub user: *mut user,
603 pub reqtype: libc::c_int,
604 pub multibulklen: libc::c_int,
605 pub bulklen: libc::c_long,
606 pub reply: *mut list,
607 pub reply_bytes: libc::c_ulonglong,
608 pub deferred_reply_errors: *mut list,
609 pub sentlen: size_t,
610 pub ctime: time_t,
611 pub duration: libc::c_long,
612 pub slot: libc::c_int,
613 pub cur_script: *mut dictEntry,
614 pub lastinteraction: time_t,
615 pub obuf_soft_limit_reached_time: time_t,
616 pub authenticated: libc::c_int,
617 pub replstate: libc::c_int,
618 pub repl_start_cmd_stream_on_ack: libc::c_int,
619 pub repldbfd: libc::c_int,
620 pub repldboff: off_t,
621 pub repldbsize: off_t,
622 pub replpreamble: sds,
623 pub read_reploff: libc::c_longlong,
624 pub reploff: libc::c_longlong,
625 pub repl_applied: libc::c_longlong,
626 pub repl_ack_off: libc::c_longlong,
627 pub repl_ack_time: libc::c_longlong,
628 pub repl_last_partial_write: libc::c_longlong,
629 pub psync_initial_offset: libc::c_longlong,
630 pub replid: [libc::c_char; 41],
631 pub slave_listening_port: libc::c_int,
632 pub slave_addr: *mut libc::c_char,
633 pub slave_capa: libc::c_int,
634 pub slave_req: libc::c_int,
635 pub mstate: multiState,
636 pub btype: libc::c_int,
637 pub bpop: blockingState,
638 pub woff: libc::c_longlong,
639 pub watched_keys: *mut list,
640 pub pubsub_channels: *mut dict,
641 pub pubsub_patterns: *mut list,
642 pub pubsubshard_channels: *mut dict,
643 pub peerid: sds,
644 pub sockname: sds,
645 pub client_list_node: *mut listNode,
646 pub postponed_list_node: *mut listNode,
647 pub pending_read_list_node: *mut listNode,
648 pub auth_callback: RedisModuleUserChangedFunc,
649 pub auth_callback_privdata: *mut libc::c_void,
650 pub auth_module: *mut libc::c_void,
651 pub client_tracking_redirection: uint64_t,
652 pub client_tracking_prefixes: *mut rax,
653 pub last_memory_usage: size_t,
654 pub last_memory_type: libc::c_int,
655 pub mem_usage_bucket_node: *mut listNode,
656 pub mem_usage_bucket: *mut clientMemUsageBucket,
657 pub ref_repl_buf_node: *mut listNode,
658 pub ref_block_pos: size_t,
659 pub buf_peak: size_t,
660 pub buf_peak_last_reset_time: mstime_t,
661 pub bufpos: libc::c_int,
662 pub buf_usable_size: size_t,
663 pub buf: *mut libc::c_char,
664}
665#[derive(Copy, Clone)]
666#[repr(C)]
667pub struct clientMemUsageBucket {
668 pub clients: *mut list,
669 pub mem_usage_sum: size_t,
670}
671#[derive(Copy, Clone)]
672#[repr(C)]
673pub struct blockingState {
674 pub count: libc::c_long,
675 pub timeout: mstime_t,
676 pub keys: *mut dict,
677 pub target: *mut robj,
678 pub blockpos: blockPos,
679 pub xread_count: size_t,
680 pub xread_group: *mut robj,
681 pub xread_consumer: *mut robj,
682 pub xread_group_noack: libc::c_int,
683 pub numreplicas: libc::c_int,
684 pub reploffset: libc::c_longlong,
685 pub module_blocked_handle: *mut libc::c_void,
686}
687#[derive(Copy, Clone)]
688#[repr(C)]
689pub struct blockPos {
690 pub wherefrom: libc::c_int,
691 pub whereto: libc::c_int,
692}
693#[derive(Copy, Clone)]
694#[repr(C)]
695pub struct multiState {
696 pub commands: *mut multiCmd,
697 pub count: libc::c_int,
698 pub cmd_flags: libc::c_int,
699 pub cmd_inv_flags: libc::c_int,
700 pub argv_len_sums: size_t,
701 pub alloc_count: libc::c_int,
702}
703#[derive(Copy, Clone)]
704#[repr(C)]
705pub struct user {
706 pub name: sds,
707 pub flags: uint32_t,
708 pub passwords: *mut list,
709 pub selectors: *mut list,
710 pub acl_string: *mut robj,
711}
712#[derive(Copy, Clone)]
713#[repr(C)]
714pub struct commandHistory {
715 pub since: *const libc::c_char,
716 pub changes: *const libc::c_char,
717}
718pub type redisCommandGroup = libc::c_uint;
719pub const COMMAND_GROUP_MODULE: redisCommandGroup = 17;
720pub const COMMAND_GROUP_BITMAP: redisCommandGroup = 16;
721pub const COMMAND_GROUP_STREAM: redisCommandGroup = 15;
722pub const COMMAND_GROUP_GEO: redisCommandGroup = 14;
723pub const COMMAND_GROUP_SENTINEL: redisCommandGroup = 13;
724pub const COMMAND_GROUP_CLUSTER: redisCommandGroup = 12;
725pub const COMMAND_GROUP_HYPERLOGLOG: redisCommandGroup = 11;
726pub const COMMAND_GROUP_SCRIPTING: redisCommandGroup = 10;
727pub const COMMAND_GROUP_SERVER: redisCommandGroup = 9;
728pub const COMMAND_GROUP_CONNECTION: redisCommandGroup = 8;
729pub const COMMAND_GROUP_TRANSACTIONS: redisCommandGroup = 7;
730pub const COMMAND_GROUP_PUBSUB: redisCommandGroup = 6;
731pub const COMMAND_GROUP_HASH: redisCommandGroup = 5;
732pub const COMMAND_GROUP_SORTED_SET: redisCommandGroup = 4;
733pub const COMMAND_GROUP_SET: redisCommandGroup = 3;
734pub const COMMAND_GROUP_LIST: redisCommandGroup = 2;
735pub const COMMAND_GROUP_STRING: redisCommandGroup = 1;
736pub const COMMAND_GROUP_GENERIC: redisCommandGroup = 0;
737#[derive(Copy, Clone)]
738#[repr(C)]
739pub struct replBacklog {
740 pub ref_repl_buf_node: *mut listNode,
741 pub unindexed_count: size_t,
742 pub blocks_index: *mut rax,
743 pub histlen: libc::c_longlong,
744 pub offset: libc::c_longlong,
745}
746#[derive(Copy, Clone)]
747#[repr(C)]
748pub struct saveparam {
749 pub seconds: time_t,
750 pub changes: libc::c_int,
751}
752#[derive(Copy, Clone)]
753#[repr(C)]
754pub struct sentinelConfig {
755 pub pre_monitor_cfg: *mut list,
756 pub monitor_cfg: *mut list,
757 pub post_monitor_cfg: *mut list,
758}
759#[derive(Copy, Clone)]
760#[repr(C)]
761pub struct sharedObjectsStruct {
762 pub crlf: *mut robj,
763 pub ok: *mut robj,
764 pub err: *mut robj,
765 pub emptybulk: *mut robj,
766 pub czero: *mut robj,
767 pub cone: *mut robj,
768 pub pong: *mut robj,
769 pub space: *mut robj,
770 pub queued: *mut robj,
771 pub null: [*mut robj; 4],
772 pub nullarray: [*mut robj; 4],
773 pub emptymap: [*mut robj; 4],
774 pub emptyset: [*mut robj; 4],
775 pub emptyarray: *mut robj,
776 pub wrongtypeerr: *mut robj,
777 pub nokeyerr: *mut robj,
778 pub syntaxerr: *mut robj,
779 pub sameobjecterr: *mut robj,
780 pub outofrangeerr: *mut robj,
781 pub noscripterr: *mut robj,
782 pub loadingerr: *mut robj,
783 pub slowevalerr: *mut robj,
784 pub slowscripterr: *mut robj,
785 pub slowmoduleerr: *mut robj,
786 pub bgsaveerr: *mut robj,
787 pub masterdownerr: *mut robj,
788 pub roslaveerr: *mut robj,
789 pub execaborterr: *mut robj,
790 pub noautherr: *mut robj,
791 pub noreplicaserr: *mut robj,
792 pub busykeyerr: *mut robj,
793 pub oomerr: *mut robj,
794 pub plus: *mut robj,
795 pub messagebulk: *mut robj,
796 pub pmessagebulk: *mut robj,
797 pub subscribebulk: *mut robj,
798 pub unsubscribebulk: *mut robj,
799 pub psubscribebulk: *mut robj,
800 pub punsubscribebulk: *mut robj,
801 pub del: *mut robj,
802 pub unlink: *mut robj,
803 pub rpop: *mut robj,
804 pub lpop: *mut robj,
805 pub lpush: *mut robj,
806 pub rpoplpush: *mut robj,
807 pub lmove: *mut robj,
808 pub blmove: *mut robj,
809 pub zpopmin: *mut robj,
810 pub zpopmax: *mut robj,
811 pub emptyscan: *mut robj,
812 pub multi: *mut robj,
813 pub exec: *mut robj,
814 pub left: *mut robj,
815 pub right: *mut robj,
816 pub hset: *mut robj,
817 pub srem: *mut robj,
818 pub xgroup: *mut robj,
819 pub xclaim: *mut robj,
820 pub script: *mut robj,
821 pub replconf: *mut robj,
822 pub eval: *mut robj,
823 pub persist: *mut robj,
824 pub set: *mut robj,
825 pub pexpireat: *mut robj,
826 pub pexpire: *mut robj,
827 pub time: *mut robj,
828 pub pxat: *mut robj,
829 pub absttl: *mut robj,
830 pub retrycount: *mut robj,
831 pub force: *mut robj,
832 pub justid: *mut robj,
833 pub entriesread: *mut robj,
834 pub lastid: *mut robj,
835 pub ping: *mut robj,
836 pub setid: *mut robj,
837 pub keepttl: *mut robj,
838 pub load: *mut robj,
839 pub createconsumer: *mut robj,
840 pub getack: *mut robj,
841 pub special_asterick: *mut robj,
842 pub special_equals: *mut robj,
843 pub default_username: *mut robj,
844 pub redacted: *mut robj,
845 pub ssubscribebulk: *mut robj,
846 pub sunsubscribebulk: *mut robj,
847 pub smessagebulk: *mut robj,
848 pub select: [*mut robj; 10],
849 pub integers: [*mut robj; 10000],
850 pub mbulkhdr: [*mut robj; 32],
851 pub bulkhdr: [*mut robj; 32],
852 pub maphdr: [*mut robj; 32],
853 pub sethdr: [*mut robj; 32],
854 pub minstring: sds,
855 pub maxstring: sds,
856}
857#[derive(Copy, Clone)]
858#[repr(C)]
859pub struct clientBufferLimitsConfig {
860 pub hard_limit_bytes: libc::c_ulonglong,
861 pub soft_limit_bytes: libc::c_ulonglong,
862 pub soft_limit_seconds: time_t,
863}
864#[derive(Copy, Clone)]
865#[repr(C)]
866pub struct redisOp {
867 pub argv: *mut *mut robj,
868 pub argc: libc::c_int,
869 pub dbid: libc::c_int,
870 pub target: libc::c_int,
871}
872#[derive(Copy, Clone)]
873#[repr(C)]
874pub struct redisOpArray {
875 pub ops: *mut redisOp,
876 pub numops: libc::c_int,
877 pub capacity: libc::c_int,
878}
879#[derive(Copy, Clone)]
880#[repr(C)]
881pub struct malloc_stats {
882 pub zmalloc_used: size_t,
883 pub process_rss: size_t,
884 pub allocator_allocated: size_t,
885 pub allocator_active: size_t,
886 pub allocator_resident: size_t,
887}
888#[derive(Copy, Clone)]
889#[repr(C)]
890pub struct socketFds {
891 pub fd: [libc::c_int; 16],
892 pub count: libc::c_int,
893}
894#[derive(Copy, Clone)]
895#[repr(C)]
896pub struct redisTLSContextConfig {
897 pub cert_file: *mut libc::c_char,
898 pub key_file: *mut libc::c_char,
899 pub key_file_pass: *mut libc::c_char,
900 pub client_cert_file: *mut libc::c_char,
901 pub client_key_file: *mut libc::c_char,
902 pub client_key_file_pass: *mut libc::c_char,
903 pub dh_params_file: *mut libc::c_char,
904 pub ca_cert_file: *mut libc::c_char,
905 pub ca_cert_dir: *mut libc::c_char,
906 pub protocols: *mut libc::c_char,
907 pub ciphers: *mut libc::c_char,
908 pub ciphersuites: *mut libc::c_char,
909 pub prefer_server_ciphers: libc::c_int,
910 pub session_caching: libc::c_int,
911 pub session_cache_size: libc::c_int,
912 pub session_cache_timeout: libc::c_int,
913}
914pub type aof_file_type = libc::c_uint;
915pub const AOF_FILE_TYPE_INCR: aof_file_type = 105;
916pub const AOF_FILE_TYPE_HIST: aof_file_type = 104;
917pub const AOF_FILE_TYPE_BASE: aof_file_type = 98;
918#[derive(Copy, Clone)]
919#[repr(C)]
920pub struct aofInfo {
921 pub file_name: sds,
922 pub file_seq: libc::c_longlong,
923 pub file_type: aof_file_type,
924}
925#[derive(Copy, Clone)]
926#[repr(C)]
927pub struct aofManifest {
928 pub base_aof_info: *mut aofInfo,
929 pub incr_aof_list: *mut list,
930 pub history_aof_list: *mut list,
931 pub curr_base_file_seq: libc::c_longlong,
932 pub curr_incr_file_seq: libc::c_longlong,
933 pub dirty: libc::c_int,
934}
935#[derive(Copy, Clone)]
936#[repr(C)]
937pub struct redisServer {
938 pub pid: pid_t,
939 pub main_thread_id: pthread_t,
940 pub configfile: *mut libc::c_char,
941 pub executable: *mut libc::c_char,
942 pub exec_argv: *mut *mut libc::c_char,
943 pub dynamic_hz: libc::c_int,
944 pub config_hz: libc::c_int,
945 pub umask: mode_t,
946 pub hz: libc::c_int,
947 pub in_fork_child: libc::c_int,
948 pub db: *mut redisDb,
949 pub commands: *mut dict,
950 pub orig_commands: *mut dict,
951 pub el: *mut aeEventLoop,
952 pub errors: *mut rax,
953 pub lruclock: atomic_uint,
954 pub shutdown_asap: sig_atomic_t,
955 pub shutdown_mstime: mstime_t,
956 pub last_sig_received: libc::c_int,
957 pub shutdown_flags: libc::c_int,
958 pub activerehashing: libc::c_int,
959 pub active_defrag_running: libc::c_int,
960 pub pidfile: *mut libc::c_char,
961 pub arch_bits: libc::c_int,
962 pub cronloops: libc::c_int,
963 pub runid: [libc::c_char; 41],
964 pub sentinel_mode: libc::c_int,
965 pub initial_memory_usage: size_t,
966 pub always_show_logo: libc::c_int,
967 pub in_exec: libc::c_int,
968 pub busy_module_yield_flags: libc::c_int,
969 pub busy_module_yield_reply: *const libc::c_char,
970 pub core_propagates: libc::c_int,
971 pub propagate_no_multi: libc::c_int,
972 pub module_ctx_nesting: libc::c_int,
973 pub ignore_warnings: *mut libc::c_char,
974 pub client_pause_in_transaction: libc::c_int,
975 pub thp_enabled: libc::c_int,
976 pub page_size: size_t,
977 pub moduleapi: *mut dict,
978 pub sharedapi: *mut dict,
979 pub module_configs_queue: *mut dict,
980 pub loadmodule_queue: *mut list,
981 pub module_pipe: [libc::c_int; 2],
982 pub child_pid: pid_t,
983 pub child_type: libc::c_int,
984 pub port: libc::c_int,
985 pub tls_port: libc::c_int,
986 pub tcp_backlog: libc::c_int,
987 pub bindaddr: [*mut libc::c_char; 16],
988 pub bindaddr_count: libc::c_int,
989 pub bind_source_addr: *mut libc::c_char,
990 pub unixsocket: *mut libc::c_char,
991 pub unixsocketperm: libc::c_uint,
992 pub ipfd: socketFds,
993 pub tlsfd: socketFds,
994 pub sofd: libc::c_int,
995 pub socket_mark_id: uint32_t,
996 pub cfd: socketFds,
997 pub clients: *mut list,
998 pub clients_to_close: *mut list,
999 pub clients_pending_write: *mut list,
1000 pub clients_pending_read: *mut list,
1001 pub slaves: *mut list,
1002 pub monitors: *mut list,
1003 pub current_client: *mut client,
1004 pub client_mem_usage_buckets: *mut clientMemUsageBucket,
1005 pub clients_timeout_table: *mut rax,
1006 pub fixed_time_expire: libc::c_long,
1007 pub in_nested_call: libc::c_int,
1008 pub clients_index: *mut rax,
1009 pub client_pause_type: pause_type,
1010 pub postponed_clients: *mut list,
1011 pub client_pause_end_time: mstime_t,
1012 pub client_pause_per_purpose: [*mut pause_event; 3],
1013 pub neterr: [libc::c_char; 256],
1014 pub migrate_cached_sockets: *mut dict,
1015 pub next_client_id: uint_least64_t,
1016 pub protected_mode: libc::c_int,
1017 pub io_threads_num: libc::c_int,
1018 pub io_threads_do_reads: libc::c_int,
1019 pub io_threads_active: libc::c_int,
1020 pub events_processed_while_blocked: libc::c_longlong,
1021 pub enable_protected_configs: libc::c_int,
1022 pub enable_debug_cmd: libc::c_int,
1023 pub enable_module_cmd: libc::c_int,
1024 pub loading: sig_atomic_t,
1025 pub async_loading: sig_atomic_t,
1026 pub loading_total_bytes: off_t,
1027 pub loading_rdb_used_mem: off_t,
1028 pub loading_loaded_bytes: off_t,
1029 pub loading_start_time: time_t,
1030 pub loading_process_events_interval_bytes: off_t,
1031 pub stat_starttime: time_t,
1032 pub stat_numcommands: libc::c_longlong,
1033 pub stat_numconnections: libc::c_longlong,
1034 pub stat_expiredkeys: libc::c_longlong,
1035 pub stat_expired_stale_perc: libc::c_double,
1036 pub stat_expired_time_cap_reached_count: libc::c_longlong,
1037 pub stat_expire_cycle_time_used: libc::c_longlong,
1038 pub stat_evictedkeys: libc::c_longlong,
1039 pub stat_evictedclients: libc::c_longlong,
1040 pub stat_total_eviction_exceeded_time: libc::c_longlong,
1041 pub stat_last_eviction_exceeded_time: monotime,
1042 pub stat_keyspace_hits: libc::c_longlong,
1043 pub stat_keyspace_misses: libc::c_longlong,
1044 pub stat_active_defrag_hits: libc::c_longlong,
1045 pub stat_active_defrag_misses: libc::c_longlong,
1046 pub stat_active_defrag_key_hits: libc::c_longlong,
1047 pub stat_active_defrag_key_misses: libc::c_longlong,
1048 pub stat_active_defrag_scanned: libc::c_longlong,
1049 pub stat_total_active_defrag_time: libc::c_longlong,
1050 pub stat_last_active_defrag_time: monotime,
1051 pub stat_peak_memory: size_t,
1052 pub stat_aof_rewrites: libc::c_longlong,
1053 pub stat_aofrw_consecutive_failures: libc::c_longlong,
1054 pub stat_rdb_saves: libc::c_longlong,
1055 pub stat_fork_time: libc::c_longlong,
1056 pub stat_fork_rate: libc::c_double,
1057 pub stat_total_forks: libc::c_longlong,
1058 pub stat_rejected_conn: libc::c_longlong,
1059 pub stat_sync_full: libc::c_longlong,
1060 pub stat_sync_partial_ok: libc::c_longlong,
1061 pub stat_sync_partial_err: libc::c_longlong,
1062 pub slowlog: *mut list,
1063 pub slowlog_entry_id: libc::c_longlong,
1064 pub slowlog_log_slower_than: libc::c_longlong,
1065 pub slowlog_max_len: libc::c_ulong,
1066 pub cron_malloc_stats: malloc_stats,
1067 pub stat_net_input_bytes: atomic_llong,
1068 pub stat_net_output_bytes: atomic_llong,
1069 pub stat_net_repl_input_bytes: atomic_llong,
1070 pub stat_net_repl_output_bytes: atomic_llong,
1071 pub stat_current_cow_peak: size_t,
1072 pub stat_current_cow_bytes: size_t,
1073 pub stat_current_cow_updated: monotime,
1074 pub stat_current_save_keys_processed: size_t,
1075 pub stat_current_save_keys_total: size_t,
1076 pub stat_rdb_cow_bytes: size_t,
1077 pub stat_aof_cow_bytes: size_t,
1078 pub stat_module_cow_bytes: size_t,
1079 pub stat_module_progress: libc::c_double,
1080 pub stat_clients_type_memory: [size_t; 4],
1081 pub stat_cluster_links_memory: size_t,
1082 pub stat_unexpected_error_replies: libc::c_longlong,
1083 pub stat_total_error_replies: libc::c_longlong,
1084 pub stat_dump_payload_sanitizations: libc::c_longlong,
1085 pub stat_io_reads_processed: libc::c_longlong,
1086 pub stat_io_writes_processed: libc::c_longlong,
1087 pub stat_total_reads_processed: atomic_llong,
1088 pub stat_total_writes_processed: atomic_llong,
1089 pub inst_metric: [C2RustUnnamed_6; 5],
1090 pub stat_reply_buffer_shrinks: libc::c_longlong,
1091 pub stat_reply_buffer_expands: libc::c_longlong,
1092 pub verbosity: libc::c_int,
1093 pub maxidletime: libc::c_int,
1094 pub tcpkeepalive: libc::c_int,
1095 pub active_expire_enabled: libc::c_int,
1096 pub active_expire_effort: libc::c_int,
1097 pub active_defrag_enabled: libc::c_int,
1098 pub sanitize_dump_payload: libc::c_int,
1099 pub skip_checksum_validation: libc::c_int,
1100 pub jemalloc_bg_thread: libc::c_int,
1101 pub active_defrag_ignore_bytes: size_t,
1102 pub active_defrag_threshold_lower: libc::c_int,
1103 pub active_defrag_threshold_upper: libc::c_int,
1104 pub active_defrag_cycle_min: libc::c_int,
1105 pub active_defrag_cycle_max: libc::c_int,
1106 pub active_defrag_max_scan_fields: libc::c_ulong,
1107 pub client_max_querybuf_len: size_t,
1108 pub dbnum: libc::c_int,
1109 pub supervised: libc::c_int,
1110 pub supervised_mode: libc::c_int,
1111 pub daemonize: libc::c_int,
1112 pub set_proc_title: libc::c_int,
1113 pub proc_title_template: *mut libc::c_char,
1114 pub client_obuf_limits: [clientBufferLimitsConfig; 3],
1115 pub pause_cron: libc::c_int,
1116 pub latency_tracking_enabled: libc::c_int,
1117 pub latency_tracking_info_percentiles: *mut libc::c_double,
1118 pub latency_tracking_info_percentiles_len: libc::c_int,
1119 pub aof_enabled: libc::c_int,
1120 pub aof_state: libc::c_int,
1121 pub aof_fsync: libc::c_int,
1122 pub aof_filename: *mut libc::c_char,
1123 pub aof_dirname: *mut libc::c_char,
1124 pub aof_no_fsync_on_rewrite: libc::c_int,
1125 pub aof_rewrite_perc: libc::c_int,
1126 pub aof_rewrite_min_size: off_t,
1127 pub aof_rewrite_base_size: off_t,
1128 pub aof_current_size: off_t,
1129 pub aof_last_incr_size: off_t,
1130 pub aof_fsync_offset: off_t,
1131 pub aof_flush_sleep: libc::c_int,
1132 pub aof_rewrite_scheduled: libc::c_int,
1133 pub aof_buf: sds,
1134 pub aof_fd: libc::c_int,
1135 pub aof_selected_db: libc::c_int,
1136 pub aof_flush_postponed_start: time_t,
1137 pub aof_last_fsync: time_t,
1138 pub aof_rewrite_time_last: time_t,
1139 pub aof_rewrite_time_start: time_t,
1140 pub aof_cur_timestamp: time_t,
1141 pub aof_timestamp_enabled: libc::c_int,
1142 pub aof_lastbgrewrite_status: libc::c_int,
1143 pub aof_delayed_fsync: libc::c_ulong,
1144 pub aof_rewrite_incremental_fsync: libc::c_int,
1145 pub rdb_save_incremental_fsync: libc::c_int,
1146 pub aof_last_write_status: libc::c_int,
1147 pub aof_last_write_errno: libc::c_int,
1148 pub aof_load_truncated: libc::c_int,
1149 pub aof_use_rdb_preamble: libc::c_int,
1150 pub aof_bio_fsync_status: atomic_int,
1151 pub aof_bio_fsync_errno: atomic_int,
1152 pub aof_manifest: *mut aofManifest,
1153 pub aof_disable_auto_gc: libc::c_int,
1154 pub dirty: libc::c_longlong,
1155 pub dirty_before_bgsave: libc::c_longlong,
1156 pub rdb_last_load_keys_expired: libc::c_longlong,
1157 pub rdb_last_load_keys_loaded: libc::c_longlong,
1158 pub saveparams: *mut saveparam,
1159 pub saveparamslen: libc::c_int,
1160 pub rdb_filename: *mut libc::c_char,
1161 pub rdb_compression: libc::c_int,
1162 pub rdb_checksum: libc::c_int,
1163 pub rdb_del_sync_files: libc::c_int,
1164 pub lastsave: time_t,
1165 pub lastbgsave_try: time_t,
1166 pub rdb_save_time_last: time_t,
1167 pub rdb_save_time_start: time_t,
1168 pub rdb_bgsave_scheduled: libc::c_int,
1169 pub rdb_child_type: libc::c_int,
1170 pub lastbgsave_status: libc::c_int,
1171 pub stop_writes_on_bgsave_err: libc::c_int,
1172 pub rdb_pipe_read: libc::c_int,
1173 pub rdb_child_exit_pipe: libc::c_int,
1174 pub rdb_pipe_conns: *mut *mut connection,
1175 pub rdb_pipe_numconns: libc::c_int,
1176 pub rdb_pipe_numconns_writing: libc::c_int,
1177 pub rdb_pipe_buff: *mut libc::c_char,
1178 pub rdb_pipe_bufflen: libc::c_int,
1179 pub rdb_key_save_delay: libc::c_int,
1180 pub key_load_delay: libc::c_int,
1181 pub child_info_pipe: [libc::c_int; 2],
1182 pub child_info_nread: libc::c_int,
1183 pub also_propagate: redisOpArray,
1184 pub replication_allowed: libc::c_int,
1185 pub logfile: *mut libc::c_char,
1186 pub syslog_enabled: libc::c_int,
1187 pub syslog_ident: *mut libc::c_char,
1188 pub syslog_facility: libc::c_int,
1189 pub crashlog_enabled: libc::c_int,
1190 pub memcheck_enabled: libc::c_int,
1191 pub use_exit_on_panic: libc::c_int,
1192 pub shutdown_timeout: libc::c_int,
1193 pub shutdown_on_sigint: libc::c_int,
1194 pub shutdown_on_sigterm: libc::c_int,
1195 pub replid: [libc::c_char; 41],
1196 pub replid2: [libc::c_char; 41],
1197 pub master_repl_offset: libc::c_longlong,
1198 pub second_replid_offset: libc::c_longlong,
1199 pub slaveseldb: libc::c_int,
1200 pub repl_ping_slave_period: libc::c_int,
1201 pub repl_backlog: *mut replBacklog,
1202 pub repl_backlog_size: libc::c_longlong,
1203 pub repl_backlog_time_limit: time_t,
1204 pub repl_no_slaves_since: time_t,
1205 pub repl_min_slaves_to_write: libc::c_int,
1206 pub repl_min_slaves_max_lag: libc::c_int,
1207 pub repl_good_slaves_count: libc::c_int,
1208 pub repl_diskless_sync: libc::c_int,
1209 pub repl_diskless_load: libc::c_int,
1210 pub repl_diskless_sync_delay: libc::c_int,
1211 pub repl_diskless_sync_max_replicas: libc::c_int,
1212 pub repl_buffer_mem: size_t,
1213 pub repl_buffer_blocks: *mut list,
1214 pub masteruser: *mut libc::c_char,
1215 pub masterauth: sds,
1216 pub masterhost: *mut libc::c_char,
1217 pub masterport: libc::c_int,
1218 pub repl_timeout: libc::c_int,
1219 pub master: *mut client,
1220 pub cached_master: *mut client,
1221 pub repl_syncio_timeout: libc::c_int,
1222 pub repl_state: libc::c_int,
1223 pub repl_transfer_size: off_t,
1224 pub repl_transfer_read: off_t,
1225 pub repl_transfer_last_fsync_off: off_t,
1226 pub repl_transfer_s: *mut connection,
1227 pub repl_transfer_fd: libc::c_int,
1228 pub repl_transfer_tmpfile: *mut libc::c_char,
1229 pub repl_transfer_lastio: time_t,
1230 pub repl_serve_stale_data: libc::c_int,
1231 pub repl_slave_ro: libc::c_int,
1232 pub repl_slave_ignore_maxmemory: libc::c_int,
1233 pub repl_down_since: time_t,
1234 pub repl_disable_tcp_nodelay: libc::c_int,
1235 pub slave_priority: libc::c_int,
1236 pub replica_announced: libc::c_int,
1237 pub slave_announce_port: libc::c_int,
1238 pub slave_announce_ip: *mut libc::c_char,
1239 pub propagation_error_behavior: libc::c_int,
1240 pub repl_ignore_disk_write_error: libc::c_int,
1241 pub master_replid: [libc::c_char; 41],
1242 pub master_initial_offset: libc::c_longlong,
1243 pub repl_slave_lazy_flush: libc::c_int,
1244 pub clients_waiting_acks: *mut list,
1245 pub get_ack_from_slaves: libc::c_int,
1246 pub maxclients: libc::c_uint,
1247 pub maxmemory: libc::c_ulonglong,
1248 pub maxmemory_clients: ssize_t,
1249 pub maxmemory_policy: libc::c_int,
1250 pub maxmemory_samples: libc::c_int,
1251 pub maxmemory_eviction_tenacity: libc::c_int,
1252 pub lfu_log_factor: libc::c_int,
1253 pub lfu_decay_time: libc::c_int,
1254 pub proto_max_bulk_len: libc::c_longlong,
1255 pub oom_score_adj_values: [libc::c_int; 3],
1256 pub oom_score_adj: libc::c_int,
1257 pub disable_thp: libc::c_int,
1258 pub blocked_clients: libc::c_uint,
1259 pub blocked_clients_by_type: [libc::c_uint; 8],
1260 pub unblocked_clients: *mut list,
1261 pub ready_keys: *mut list,
1262 pub tracking_clients: libc::c_uint,
1263 pub tracking_table_max_keys: size_t,
1264 pub tracking_pending_keys: *mut list,
1265 pub sort_desc: libc::c_int,
1266 pub sort_alpha: libc::c_int,
1267 pub sort_bypattern: libc::c_int,
1268 pub sort_store: libc::c_int,
1269 pub hash_max_listpack_entries: size_t,
1270 pub hash_max_listpack_value: size_t,
1271 pub set_max_intset_entries: size_t,
1272 pub zset_max_listpack_entries: size_t,
1273 pub zset_max_listpack_value: size_t,
1274 pub hll_sparse_max_bytes: size_t,
1275 pub stream_node_max_bytes: size_t,
1276 pub stream_node_max_entries: libc::c_longlong,
1277 pub list_max_listpack_size: libc::c_int,
1278 pub list_compress_depth: libc::c_int,
1279 pub unixtime: atomic_int,
1280 pub timezone: time_t,
1281 pub daylight_active: libc::c_int,
1282 pub mstime: mstime_t,
1283 pub ustime: ustime_t,
1284 pub blocking_op_nesting: size_t,
1285 pub blocked_last_cron: libc::c_longlong,
1286 pub pubsub_channels: *mut dict,
1287 pub pubsub_patterns: *mut dict,
1288 pub notify_keyspace_events: libc::c_int,
1289 pub pubsubshard_channels: *mut dict,
1290 pub cluster_enabled: libc::c_int,
1291 pub cluster_port: libc::c_int,
1292 pub cluster_node_timeout: mstime_t,
1293 pub cluster_configfile: *mut libc::c_char,
1294 pub cluster: *mut clusterState,
1295 pub cluster_migration_barrier: libc::c_int,
1296 pub cluster_allow_replica_migration: libc::c_int,
1297 pub cluster_slave_validity_factor: libc::c_int,
1298 pub cluster_require_full_coverage: libc::c_int,
1299 pub cluster_slave_no_failover: libc::c_int,
1300 pub cluster_announce_ip: *mut libc::c_char,
1301 pub cluster_announce_hostname: *mut libc::c_char,
1302 pub cluster_preferred_endpoint_type: libc::c_int,
1303 pub cluster_announce_port: libc::c_int,
1304 pub cluster_announce_tls_port: libc::c_int,
1305 pub cluster_announce_bus_port: libc::c_int,
1306 pub cluster_module_flags: libc::c_int,
1307 pub cluster_allow_reads_when_down: libc::c_int,
1308 pub cluster_config_file_lock_fd: libc::c_int,
1309 pub cluster_link_sendbuf_limit_bytes: libc::c_ulonglong,
1310 pub cluster_drop_packet_filter: libc::c_int,
1311 pub script_caller: *mut client,
1312 pub busy_reply_threshold: mstime_t,
1313 pub pre_command_oom_state: libc::c_int,
1314 pub script_disable_deny_script: libc::c_int,
1315 pub lazyfree_lazy_eviction: libc::c_int,
1316 pub lazyfree_lazy_expire: libc::c_int,
1317 pub lazyfree_lazy_server_del: libc::c_int,
1318 pub lazyfree_lazy_user_del: libc::c_int,
1319 pub lazyfree_lazy_user_flush: libc::c_int,
1320 pub latency_monitor_threshold: libc::c_longlong,
1321 pub latency_events: *mut dict,
1322 pub acl_filename: *mut libc::c_char,
1323 pub acllog_max_len: libc::c_ulong,
1324 pub requirepass: sds,
1325 pub acl_pubsub_default: libc::c_int,
1326 pub watchdog_period: libc::c_int,
1327 pub system_memory_size: size_t,
1328 pub tls_cluster: libc::c_int,
1329 pub tls_replication: libc::c_int,
1330 pub tls_auth_clients: libc::c_int,
1331 pub tls_ctx_config: redisTLSContextConfig,
1332 pub server_cpulist: *mut libc::c_char,
1333 pub bio_cpulist: *mut libc::c_char,
1334 pub aof_rewrite_cpulist: *mut libc::c_char,
1335 pub bgsave_cpulist: *mut libc::c_char,
1336 pub sentinel_config: *mut sentinelConfig,
1337 pub failover_end_time: mstime_t,
1338 pub force_failover: libc::c_int,
1339 pub target_replica_host: *mut libc::c_char,
1340 pub target_replica_port: libc::c_int,
1341 pub failover_state: libc::c_int,
1342 pub cluster_allow_pubsubshard_when_down: libc::c_int,
1343 pub reply_buffer_peak_reset_time: libc::c_long,
1344 pub reply_buffer_resizing_enabled: libc::c_int,
1345}
1346#[derive(Copy, Clone)]
1347#[repr(C)]
1348pub struct C2RustUnnamed_6 {
1349 pub last_sample_time: libc::c_longlong,
1350 pub last_sample_count: libc::c_longlong,
1351 pub samples: [libc::c_longlong; 16],
1352 pub idx: libc::c_int,
1353}
1354#[derive(Copy, Clone,c2rust_bitfields::BitfieldStruct)]
1355#[repr(C)]
1356pub struct watchedKey {
1357 pub key: *mut robj,
1358 pub db: *mut redisDb,
1359 pub client: *mut client,
1360 #[bitfield(name = "expired", ty = "libc::c_uint", bits = "0..=0")]
1361 pub expired: [u8; 1],
1362 #[bitfield(padding)]
1363 pub c2rust_padding: [u8; 7],
1364}
1365#[no_mangle]
1366pub unsafe extern "C" fn initClientMultiState(mut c: *mut client) {
1367 (*c).mstate.commands = 0 as *mut multiCmd;
1368 (*c).mstate.count = 0 as libc::c_int;
1369 (*c).mstate.cmd_flags = 0 as libc::c_int;
1370 (*c).mstate.cmd_inv_flags = 0 as libc::c_int;
1371 (*c).mstate.argv_len_sums = 0 as libc::c_int as size_t;
1372 (*c).mstate.alloc_count = 0 as libc::c_int;
1373}
1374#[no_mangle]
1375pub unsafe extern "C" fn freeClientMultiState(mut c: *mut client) {
1376 let mut j: libc::c_int = 0;
1377 j = 0 as libc::c_int;
1378 while j < (*c).mstate.count {
1379 let mut i: libc::c_int = 0;
1380 let mut mc: *mut multiCmd = ((*c).mstate.commands).offset(j as isize);
1381 i = 0 as libc::c_int;
1382 while i < (*mc).argc {
1383 decrRefCount(*((*mc).argv).offset(i as isize));
1384 i += 1;
1385 }
1386 zfree((*mc).argv as *mut libc::c_void);
1387 j += 1;
1388 }
1389 zfree((*c).mstate.commands as *mut libc::c_void);
1390}
1391#[no_mangle]
1392pub unsafe extern "C" fn queueMultiCommand(mut c: *mut client, mut cmd_flags: uint64_t) {
1393 let mut mc: *mut multiCmd = 0 as *mut multiCmd;
1394 if (*c).flags
1395 & ((1 as libc::c_int) << 5 as libc::c_int
1396 | (1 as libc::c_int) << 12 as libc::c_int) as libc::c_ulong != 0
1397 {
1398 return;
1399 }
1400 if (*c).mstate.count == 0 as libc::c_int {
1401 (*c)
1402 .mstate
1403 .commands = zmalloc(
1404 (core::mem::size_of::<multiCmd>() as libc::c_ulong)
1405 .wrapping_mul(2 as libc::c_int as libc::c_ulong),
1406 ) as *mut multiCmd;
1407 (*c).mstate.alloc_count = 2 as libc::c_int;
1408 }
1409 if (*c).mstate.count == (*c).mstate.alloc_count {
1410 (*c)
1411 .mstate
1412 .alloc_count = if (*c).mstate.alloc_count
1413 < 2147483647 as libc::c_int / 2 as libc::c_int
1414 {
1415 (*c).mstate.alloc_count * 2 as libc::c_int
1416 } else {
1417 2147483647 as libc::c_int
1418 };
1419 (*c)
1420 .mstate
1421 .commands = zrealloc(
1422 (*c).mstate.commands as *mut libc::c_void,
1423 (core::mem::size_of::<multiCmd>() as libc::c_ulong)
1424 .wrapping_mul((*c).mstate.alloc_count as libc::c_ulong),
1425 ) as *mut multiCmd;
1426 }
1427 mc = ((*c).mstate.commands).offset((*c).mstate.count as isize);
1428 (*mc).cmd = (*c).cmd;
1429 (*mc).argc = (*c).argc;
1430 (*mc).argv = (*c).argv;
1431 (*mc).argv_len = (*c).argv_len;
1432 (*c).mstate.count += 1;
1433 (*c)
1434 .mstate
1435 .cmd_flags = ((*c).mstate.cmd_flags as libc::c_ulong | cmd_flags) as libc::c_int;
1436 (*c)
1437 .mstate
1438 .cmd_inv_flags = ((*c).mstate.cmd_inv_flags as libc::c_ulong | !cmd_flags)
1439 as libc::c_int;
1440 (*c)
1441 .mstate
1442 .argv_len_sums = ((*c).mstate.argv_len_sums as libc::c_ulong)
1443 .wrapping_add(
1444 ((*c).argv_len_sum)
1445 .wrapping_add(
1446 (core::mem::size_of::<*mut robj>() as libc::c_ulong)
1447 .wrapping_mul((*c).argc as libc::c_ulong),
1448 ),
1449 ) as size_t as size_t;
1450 (*c).argv = 0 as *mut *mut robj;
1451 (*c).argc = 0 as libc::c_int;
1452 (*c).argv_len_sum = 0 as libc::c_int as size_t;
1453 (*c).argv_len = 0 as libc::c_int;
1454}
1455#[no_mangle]
1456pub unsafe extern "C" fn discardTransaction(mut c: *mut client) {
1457 freeClientMultiState(c);
1458 initClientMultiState(c);
1459 (*c).flags
1460 &= !((1 as libc::c_int) << 3 as libc::c_int
1461 | (1 as libc::c_int) << 5 as libc::c_int
1462 | (1 as libc::c_int) << 12 as libc::c_int) as libc::c_ulong;
1463 unwatchAllKeys(c);
1464}
1465#[no_mangle]
1466pub unsafe extern "C" fn flagTransaction(mut c: *mut client) {
1467 if (*c).flags & ((1 as libc::c_int) << 3 as libc::c_int) as libc::c_ulong != 0 {
1468 (*c).flags |= ((1 as libc::c_int) << 12 as libc::c_int) as libc::c_ulong;
1469 }
1470}
1471#[no_mangle]
1472pub unsafe extern "C" fn multiCommand(mut c: *mut client) {
1473 if (*c).flags & ((1 as libc::c_int) << 3 as libc::c_int) as libc::c_ulong != 0 {
1474 addReplyError(
1475 c,
1476 b"MULTI calls can not be nested\0" as *const u8 as *const libc::c_char,
1477 );
1478 return;
1479 }
1480 (*c).flags |= ((1 as libc::c_int) << 3 as libc::c_int) as libc::c_ulong;
1481 addReply(c, shared.ok);
1482}
1483#[no_mangle]
1484pub unsafe extern "C" fn discardCommand(mut c: *mut client) {
1485 if (*c).flags & ((1 as libc::c_int) << 3 as libc::c_int) as libc::c_ulong == 0 {
1486 addReplyError(c, b"DISCARD without MULTI\0" as *const u8 as *const libc::c_char);
1487 return;
1488 }
1489 discardTransaction(c);
1490 addReply(c, shared.ok);
1491}
1492#[no_mangle]
1493pub unsafe extern "C" fn execCommandAbort(mut c: *mut client, mut error: sds) {
1494 discardTransaction(c);
1495 if *error.offset(0 as libc::c_int as isize) as libc::c_int == '-' as i32 {
1496 error = error.offset(1);
1497 }
1498 addReplyErrorFormat(
1499 c,
1500 b"-EXECABORT Transaction discarded because of: %s\0" as *const u8
1501 as *const libc::c_char,
1502 error,
1503 );
1504 replicationFeedMonitors(c, server.monitors, (*(*c).db).id, (*c).argv, (*c).argc);
1505}
1506#[no_mangle]
1507pub unsafe extern "C" fn execCommand(mut c: *mut client) {
1508 let mut j: libc::c_int = 0;
1509 let mut orig_argv: *mut *mut robj = 0 as *mut *mut robj;
1510 let mut orig_argc: libc::c_int = 0;
1511 let mut orig_argv_len: libc::c_int = 0;
1512 let mut orig_cmd: *mut redisCommand = 0 as *mut redisCommand;
1513 if (*c).flags & ((1 as libc::c_int) << 3 as libc::c_int) as libc::c_ulong == 0 {
1514 addReplyError(c, b"EXEC without MULTI\0" as *const u8 as *const libc::c_char);
1515 return;
1516 }
1517 if isWatchedKeyExpired(c) != 0 {
1518 (*c).flags |= ((1 as libc::c_int) << 5 as libc::c_int) as libc::c_ulong;
1519 }
1520 if (*c).flags
1521 & ((1 as libc::c_int) << 5 as libc::c_int
1522 | (1 as libc::c_int) << 12 as libc::c_int) as libc::c_ulong != 0
1523 {
1524 if (*c).flags & ((1 as libc::c_int) << 12 as libc::c_int) as libc::c_ulong != 0 {
1525 addReplyErrorObject(c, shared.execaborterr);
1526 } else {
1527 addReply(c, shared.nullarray[(*c).resp as usize]);
1528 }
1529 discardTransaction(c);
1530 return;
1531 }
1532 let mut old_flags: uint64_t = (*c).flags;
1533 (*c)
1534 .flags = ((*c).flags as libc::c_ulonglong
1535 | (1 as libc::c_ulonglong) << 41 as libc::c_int) as uint64_t;
1536 unwatchAllKeys(c);
1537 server.in_exec = 1 as libc::c_int;
1538 orig_argv = (*c).argv;
1539 orig_argv_len = (*c).argv_len;
1540 orig_argc = (*c).argc;
1541 orig_cmd = (*c).cmd;
1542 addReplyArrayLen(c, (*c).mstate.count as libc::c_long);
1543 j = 0 as libc::c_int;
1544 while j < (*c).mstate.count {
1545 (*c).argc = (*((*c).mstate.commands).offset(j as isize)).argc;
1546 (*c).argv = (*((*c).mstate.commands).offset(j as isize)).argv;
1547 (*c).argv_len = (*((*c).mstate.commands).offset(j as isize)).argv_len;
1548 (*c).realcmd = (*((*c).mstate.commands).offset(j as isize)).cmd;
1549 (*c).cmd = (*c).realcmd;
1550 let mut acl_errpos: libc::c_int = 0;
1551 let mut acl_retval: libc::c_int = ACLCheckAllPerm(c, &mut acl_errpos);
1552 if acl_retval != 0 as libc::c_int {
1553 let mut reason: *mut libc::c_char = 0 as *mut libc::c_char;
1554 match acl_retval {
1555 1 => {
1556 reason = b"no permission to execute the command or subcommand\0"
1557 as *const u8 as *const libc::c_char as *mut libc::c_char;
1558 }
1559 2 => {
1560 reason = b"no permission to touch the specified keys\0" as *const u8
1561 as *const libc::c_char as *mut libc::c_char;
1562 }
1563 4 => {
1564 reason = b"no permission to access one of the channels used as arguments\0"
1565 as *const u8 as *const libc::c_char as *mut libc::c_char;
1566 }
1567 _ => {
1568 reason = b"no permission\0" as *const u8 as *const libc::c_char
1569 as *mut libc::c_char;
1570 }
1571 }
1572 addACLLogEntry(
1573 c,
1574 acl_retval,
1575 2 as libc::c_int,
1576 acl_errpos,
1577 0 as sds,
1578 0 as sds,
1579 );
1580 addReplyErrorFormat(
1581 c,
1582 b"-NOPERM ACLs rules changed between the moment the transaction was accumulated and the EXEC call. This command is no longer allowed for the following reason: %s\0"
1583 as *const u8 as *const libc::c_char,
1584 reason,
1585 );
1586 } else {
1587 if (*c).id == 18446744073709551615 as libc::c_ulong {
1588 call(c, 0 as libc::c_int);
1589 } else {
1590 call(
1591 c,
1592 (1 as libc::c_int) << 0 as libc::c_int
1593 | (1 as libc::c_int) << 1 as libc::c_int
1594 | ((1 as libc::c_int) << 2 as libc::c_int
1595 | (1 as libc::c_int) << 3 as libc::c_int),
1596 );
1597 }
1598 if (*c).flags & ((1 as libc::c_int) << 4 as libc::c_int) as libc::c_ulong
1599 == 0 as libc::c_int as libc::c_ulong
1600 {} else {
1601 _serverAssert(
1602 b"(c->flags & CLIENT_BLOCKED) == 0\0" as *const u8
1603 as *const libc::c_char,
1604 b"multi.c\0" as *const u8 as *const libc::c_char,
1605 235 as libc::c_int,
1606 );
1607 unreachable!();
1608 };
1609 }
1610 (*((*c).mstate.commands).offset(j as isize)).argc = (*c).argc;
1611 let ref mut fresh0 = (*((*c).mstate.commands).offset(j as isize)).argv;
1612 *fresh0 = (*c).argv;
1613 (*((*c).mstate.commands).offset(j as isize)).argv_len = (*c).argv_len;
1614 let ref mut fresh1 = (*((*c).mstate.commands).offset(j as isize)).cmd;
1615 *fresh1 = (*c).cmd;
1616 j += 1;
1617 }
1618 if old_flags as libc::c_ulonglong & (1 as libc::c_ulonglong) << 41 as libc::c_int
1619 == 0
1620 {
1621 (*c)
1622 .flags = ((*c).flags as libc::c_ulonglong
1623 & !((1 as libc::c_ulonglong) << 41 as libc::c_int)) as uint64_t;
1624 }
1625 (*c).argv = orig_argv;
1626 (*c).argv_len = orig_argv_len;
1627 (*c).argc = orig_argc;
1628 (*c).realcmd = orig_cmd;
1629 (*c).cmd = (*c).realcmd;
1630 discardTransaction(c);
1631 server.in_exec = 0 as libc::c_int;
1632}
1633#[no_mangle]
1634pub unsafe extern "C" fn watchForKey(mut c: *mut client, mut key: *mut robj) {
1635 let mut clients: *mut list = 0 as *mut list;
1636 let mut li: listIter = listIter {
1637 next: 0 as *mut listNode,
1638 direction: 0,
1639 };
1640 let mut ln: *mut listNode = 0 as *mut listNode;
1641 let mut wk: *mut watchedKey = 0 as *mut watchedKey;
1642 listRewind((*c).watched_keys, &mut li);
1643 loop {
1644 ln = listNext(&mut li);
1645 if ln.is_null() {
1646 break;
1647 }
1648 wk = (*ln).value as *mut watchedKey;
1649 if (*wk).db == (*c).db && equalStringObjects(key, (*wk).key) != 0 {
1650 return;
1651 }
1652 }
1653 clients = dictFetchValue((*(*c).db).watched_keys, key as *const libc::c_void)
1654 as *mut list;
1655 if clients.is_null() {
1656 clients = listCreate();
1657 dictAdd(
1658 (*(*c).db).watched_keys,
1659 key as *mut libc::c_void,
1660 clients as *mut libc::c_void,
1661 );
1662 incrRefCount(key);
1663 }
1664 wk = zmalloc(core::mem::size_of::<watchedKey>() as libc::c_ulong)
1665 as *mut watchedKey;
1666 (*wk).key = key;
1667 (*wk).client = c;
1668 (*wk).db = (*c).db;
1669 (*wk).set_expired(keyIsExpired((*c).db, key) as libc::c_uint);
1670 incrRefCount(key);
1671 listAddNodeTail((*c).watched_keys, wk as *mut libc::c_void);
1672 listAddNodeTail(clients, wk as *mut libc::c_void);
1673}
1674#[no_mangle]
1675pub unsafe extern "C" fn unwatchAllKeys(mut c: *mut client) {
1676 let mut li: listIter = listIter {
1677 next: 0 as *mut listNode,
1678 direction: 0,
1679 };
1680 let mut ln: *mut listNode = 0 as *mut listNode;
1681 if (*(*c).watched_keys).len == 0 as libc::c_int as libc::c_ulong {
1682 return;
1683 }
1684 listRewind((*c).watched_keys, &mut li);
1685 loop {
1686 ln = listNext(&mut li);
1687 if ln.is_null() {
1688 break;
1689 }
1690 let mut clients: *mut list = 0 as *mut list;
1691 let mut wk: *mut watchedKey = 0 as *mut watchedKey;
1692 wk = (*ln).value as *mut watchedKey;
1693 clients = dictFetchValue(
1694 (*(*wk).db).watched_keys,
1695 (*wk).key as *const libc::c_void,
1696 ) as *mut list;
1697 if !clients.is_null() {} else {
1698 _serverAssertWithInfo(
1699 c,
1700 0 as *const robj,
1701 b"clients != NULL\0" as *const u8 as *const libc::c_char,
1702 b"multi.c\0" as *const u8 as *const libc::c_char,
1703 326 as libc::c_int,
1704 );
1705 unreachable!();
1706 };
1707 listDelNode(clients, listSearchKey(clients, wk as *mut libc::c_void));
1708 if (*clients).len == 0 as libc::c_int as libc::c_ulong {
1709 dictDelete((*(*wk).db).watched_keys, (*wk).key as *const libc::c_void);
1710 }
1711 listDelNode((*c).watched_keys, ln);
1712 decrRefCount((*wk).key);
1713 zfree(wk as *mut libc::c_void);
1714 };
1715}
1716#[no_mangle]
1717pub unsafe extern "C" fn isWatchedKeyExpired(mut c: *mut client) -> libc::c_int {
1718 let mut li: listIter = listIter {
1719 next: 0 as *mut listNode,
1720 direction: 0,
1721 };
1722 let mut ln: *mut listNode = 0 as *mut listNode;
1723 let mut wk: *mut watchedKey = 0 as *mut watchedKey;
1724 if (*(*c).watched_keys).len == 0 as libc::c_int as libc::c_ulong {
1725 return 0 as libc::c_int;
1726 }
1727 listRewind((*c).watched_keys, &mut li);
1728 loop {
1729 ln = listNext(&mut li);
1730 if ln.is_null() {
1731 break;
1732 }
1733 wk = (*ln).value as *mut watchedKey;
1734 if (*wk).expired() != 0 {
1735 continue;
1736 }
1737 if keyIsExpired((*wk).db, (*wk).key) != 0 {
1738 return 1 as libc::c_int;
1739 }
1740 }
1741 return 0 as libc::c_int;
1742}
1743#[no_mangle]
1744pub unsafe extern "C" fn touchWatchedKey(mut db: *mut redisDb, mut key: *mut robj) {
1745 let mut clients: *mut list = 0 as *mut list;
1746 let mut li: listIter = listIter {
1747 next: 0 as *mut listNode,
1748 direction: 0,
1749 };
1750 let mut ln: *mut listNode = 0 as *mut listNode;
1751 if ((*(*db).watched_keys).ht_used[0 as libc::c_int as usize])
1752 .wrapping_add((*(*db).watched_keys).ht_used[1 as libc::c_int as usize])
1753 == 0 as libc::c_int as libc::c_ulong
1754 {
1755 return;
1756 }
1757 clients = dictFetchValue((*db).watched_keys, key as *const libc::c_void)
1758 as *mut list;
1759 if clients.is_null() {
1760 return;
1761 }
1762 listRewind(clients, &mut li);
1763 loop {
1764 ln = listNext(&mut li);
1765 if ln.is_null() {
1766 break;
1767 }
1768 let mut wk: *mut watchedKey = (*ln).value as *mut watchedKey;
1769 let mut c: *mut client = (*wk).client;
1770 if (*wk).expired() != 0 {
1771 if !(db == (*wk).db && equalStringObjects(key, (*wk).key) != 0
1772 && (dictFind((*db).dict, (*key).ptr)).is_null())
1773 {
1774 break;
1775 }
1776 (*wk).set_expired(0 as libc::c_int as libc::c_uint);
1777 } else {
1778 (*c).flags |= ((1 as libc::c_int) << 5 as libc::c_int) as libc::c_ulong;
1779 unwatchAllKeys(c);
1780 }
1781 };
1782}
1783#[no_mangle]
1784pub unsafe extern "C" fn touchAllWatchedKeysInDb(
1785 mut emptied: *mut redisDb,
1786 mut replaced_with: *mut redisDb,
1787) {
1788 let mut li: listIter = listIter {
1789 next: 0 as *mut listNode,
1790 direction: 0,
1791 };
1792 let mut ln: *mut listNode = 0 as *mut listNode;
1793 let mut de: *mut dictEntry = 0 as *mut dictEntry;
1794 if ((*(*emptied).watched_keys).ht_used[0 as libc::c_int as usize])
1795 .wrapping_add((*(*emptied).watched_keys).ht_used[1 as libc::c_int as usize])
1796 == 0 as libc::c_int as libc::c_ulong
1797 {
1798 return;
1799 }
1800 let mut di: *mut dictIterator = dictGetSafeIterator((*emptied).watched_keys);
1801 loop {
1802 de = dictNext(di);
1803 if de.is_null() {
1804 break;
1805 }
1806 let mut key: *mut robj = (*de).key as *mut robj;
1807 let mut exists_in_emptied: libc::c_int = (dictFind((*emptied).dict, (*key).ptr)
1808 != 0 as *mut libc::c_void as *mut dictEntry) as libc::c_int;
1809 if !(exists_in_emptied != 0
1810 || !replaced_with.is_null()
1811 && !(dictFind((*replaced_with).dict, (*key).ptr)).is_null())
1812 {
1813 continue;
1814 }
1815 let mut clients: *mut list = (*de).v.val as *mut list;
1816 if clients.is_null() {
1817 continue;
1818 }
1819 listRewind(clients, &mut li);
1820 loop {
1821 ln = listNext(&mut li);
1822 if ln.is_null() {
1823 break;
1824 }
1825 let mut wk: *mut watchedKey = (*ln).value as *mut watchedKey;
1826 if (*wk).expired() != 0 {
1827 if replaced_with.is_null()
1828 || (dictFind((*replaced_with).dict, (*key).ptr)).is_null()
1829 {
1830 (*wk).set_expired(0 as libc::c_int as libc::c_uint);
1831 continue;
1832 } else if keyIsExpired(replaced_with, key) != 0 {
1833 continue;
1834 }
1835 } else if exists_in_emptied == 0 && keyIsExpired(replaced_with, key) != 0 {
1836 (*wk).set_expired(1 as libc::c_int as libc::c_uint);
1837 continue;
1838 }
1839 let mut c: *mut client = (*wk).client;
1840 (*c).flags |= ((1 as libc::c_int) << 5 as libc::c_int) as libc::c_ulong;
1841 unwatchAllKeys(c);
1842 }
1843 }
1844 dictReleaseIterator(di);
1845}
1846#[no_mangle]
1847pub unsafe extern "C" fn watchCommand(mut c: *mut client) {
1848 let mut j: libc::c_int = 0;
1849 if (*c).flags & ((1 as libc::c_int) << 3 as libc::c_int) as libc::c_ulong != 0 {
1850 addReplyError(
1851 c,
1852 b"WATCH inside MULTI is not allowed\0" as *const u8 as *const libc::c_char,
1853 );
1854 return;
1855 }
1856 if (*c).flags & ((1 as libc::c_int) << 5 as libc::c_int) as libc::c_ulong != 0 {
1857 addReply(c, shared.ok);
1858 return;
1859 }
1860 j = 1 as libc::c_int;
1861 while j < (*c).argc {
1862 watchForKey(c, *((*c).argv).offset(j as isize));
1863 j += 1;
1864 }
1865 addReply(c, shared.ok);
1866}
1867#[no_mangle]
1868pub unsafe extern "C" fn unwatchCommand(mut c: *mut client) {
1869 unwatchAllKeys(c);
1870 (*c).flags &= !((1 as libc::c_int) << 5 as libc::c_int) as libc::c_ulong;
1871 addReply(c, shared.ok);
1872}
1873#[no_mangle]
1874pub unsafe extern "C" fn multiStateMemOverhead(mut c: *mut client) -> size_t {
1875 let mut mem: size_t = (*c).mstate.argv_len_sums;
1876 mem = (mem as libc::c_ulong)
1877 .wrapping_add(
1878 ((*(*c).watched_keys).len)
1879 .wrapping_mul(
1880 (core::mem::size_of::<listNode>() as libc::c_ulong)
1881 .wrapping_add(
1882 core::mem::size_of::<watchedKey>() as libc::c_ulong,
1883 ),
1884 ),
1885 ) as size_t as size_t;
1886 mem = (mem as libc::c_ulong)
1887 .wrapping_add(
1888 ((*c).mstate.alloc_count as libc::c_ulong)
1889 .wrapping_mul(core::mem::size_of::<multiCmd>() as libc::c_ulong),
1890 ) as size_t as size_t;
1891 return mem;
1892}