1extern crate c2rust_bitfields;
2extern crate libc;
3extern crate core;
4extern "C" {
5 pub type RedisModuleCommand;
6 fn sdsnew(init: *const libc::c_char) -> sds;
7 fn sdsempty() -> sds;
8 fn sdsdup(s: sds) -> sds;
9 fn sdscatfmt(s: sds, fmt: *const libc::c_char, _: ...) -> sds;
10 fn strerror(_: libc::c_int) -> *mut libc::c_char;
11 static mut getMonotonicUs: Option::<unsafe extern "C" fn() -> monotime>;
12 static mut server: redisServer;
13 static mut shared: sharedObjectsStruct;
14 fn moduleCallCommandFilters(c: *mut client);
15 fn mstime() -> libc::c_longlong;
16 fn addReply(c: *mut client, obj: *mut robj);
17 fn addReplyErrorObject(c: *mut client, err: *mut robj);
18 fn afterErrorReply(
19 c: *mut client,
20 s: *const libc::c_char,
21 len: size_t,
22 flags: libc::c_int,
23 );
24 fn addReplyError(c: *mut client, err: *const libc::c_char);
25 fn processEventsWhileBlocked();
26 fn blockingOperationStarts();
27 fn blockingOperationEnds();
28 fn protectClient(c: *mut client);
29 fn unprotectClient(c: *mut client);
30 fn addReplyErrorFormat(c: *mut client, fmt: *const libc::c_char, _: ...);
31 fn checkGoodReplicasStatus() -> libc::c_int;
32 fn writeCommandsDeniedByDiskError() -> libc::c_int;
33 fn ACLCheckAllPerm(c: *mut client, idxptr: *mut libc::c_int) -> libc::c_int;
34 fn addACLLogEntry(
35 c: *mut client,
36 reason: libc::c_int,
37 context: libc::c_int,
38 argpos: libc::c_int,
39 username: sds,
40 object: sds,
41 );
42 fn getAclErrorMessage(acl_res: libc::c_int) -> *const libc::c_char;
43 fn lookupCommand(argv: *mut *mut robj, argc: libc::c_int) -> *mut redisCommand;
44 fn incrCommandStatsOnError(
45 cmd: *mut redisCommand,
46 flags: libc::c_int,
47 ) -> libc::c_int;
48 fn call(c: *mut client, flags: libc::c_int);
49 fn preventCommandPropagation(c: *mut client);
50 fn mustObeyClient(c: *mut client) -> libc::c_int;
51 fn _serverLog(level: libc::c_int, fmt: *const libc::c_char, _: ...);
52 fn selectDb(c: *mut client, id: libc::c_int) -> libc::c_int;
53 fn queueClientForReprocessing(c: *mut client);
54 fn writeCommandsGetDiskErrorMessage(_: libc::c_int) -> sds;
55 fn _serverAssert(
56 estr: *const libc::c_char,
57 file: *const libc::c_char,
58 line: libc::c_int,
59 );
60 fn getNodeByQuery(
61 c: *mut client,
62 cmd: *mut redisCommand,
63 argv: *mut *mut robj,
64 argc: libc::c_int,
65 hashslot: *mut libc::c_int,
66 ask: *mut libc::c_int,
67 ) -> *mut clusterNode;
68}
69pub type __uint8_t = libc::c_uchar;
70pub type __int16_t = libc::c_short;
71pub type __uint16_t = libc::c_ushort;
72pub type __int32_t = libc::c_int;
73pub type __uint32_t = libc::c_uint;
74pub type __int64_t = libc::c_long;
75pub type __uint64_t = libc::c_ulong;
76pub type __uint_least64_t = __uint64_t;
77pub type __mode_t = libc::c_uint;
78pub type __off64_t = libc::c_long;
79pub type __pid_t = libc::c_int;
80pub type __time_t = libc::c_long;
81pub type __ssize_t = libc::c_long;
82pub type __sig_atomic_t = libc::c_int;
83pub type size_t = libc::c_ulong;
84#[derive(Copy, Clone)]
85#[repr(C)]
86pub struct iovec {
87 pub iov_base: *mut libc::c_void,
88 pub iov_len: size_t,
89}
90pub type mode_t = __mode_t;
91pub type off_t = __off64_t;
92pub type pid_t = __pid_t;
93pub type ssize_t = __ssize_t;
94pub type time_t = __time_t;
95pub type int16_t = __int16_t;
96pub type int32_t = __int32_t;
97pub type int64_t = __int64_t;
98pub type pthread_t = libc::c_ulong;
99pub type uint8_t = __uint8_t;
100pub type uint16_t = __uint16_t;
101pub type uint32_t = __uint32_t;
102pub type uint64_t = __uint64_t;
103pub type uint_least64_t = __uint_least64_t;
104pub type sds = *mut libc::c_char;
105#[derive(Copy, Clone)]
106#[repr(C, packed)]
107pub struct sdshdr8 {
108 pub len: uint8_t,
109 pub alloc: uint8_t,
110 pub flags: libc::c_uchar,
111 pub buf: [libc::c_char; 0],
112}
113#[derive(Copy, Clone)]
114#[repr(C, packed)]
115pub struct sdshdr16 {
116 pub len: uint16_t,
117 pub alloc: uint16_t,
118 pub flags: libc::c_uchar,
119 pub buf: [libc::c_char; 0],
120}
121#[derive(Copy, Clone)]
122#[repr(C, packed)]
123pub struct sdshdr32 {
124 pub len: uint32_t,
125 pub alloc: uint32_t,
126 pub flags: libc::c_uchar,
127 pub buf: [libc::c_char; 0],
128}
129#[derive(Copy, Clone)]
130#[repr(C, packed)]
131pub struct sdshdr64 {
132 pub len: uint64_t,
133 pub alloc: uint64_t,
134 pub flags: libc::c_uchar,
135 pub buf: [libc::c_char; 0],
136}
137#[derive(Copy, Clone)]
138#[repr(C)]
139pub struct aeEventLoop {
140 pub maxfd: libc::c_int,
141 pub setsize: libc::c_int,
142 pub timeEventNextId: libc::c_longlong,
143 pub events: *mut aeFileEvent,
144 pub fired: *mut aeFiredEvent,
145 pub timeEventHead: *mut aeTimeEvent,
146 pub stop: libc::c_int,
147 pub apidata: *mut libc::c_void,
148 pub beforesleep: Option::<aeBeforeSleepProc>,
149 pub aftersleep: Option::<aeBeforeSleepProc>,
150 pub flags: libc::c_int,
151}
152pub type aeBeforeSleepProc = unsafe extern "C" fn(*mut aeEventLoop) -> ();
153#[derive(Copy, Clone)]
154#[repr(C)]
155pub struct aeTimeEvent {
156 pub id: libc::c_longlong,
157 pub when: monotime,
158 pub timeProc: Option::<aeTimeProc>,
159 pub finalizerProc: Option::<aeEventFinalizerProc>,
160 pub clientData: *mut libc::c_void,
161 pub prev: *mut aeTimeEvent,
162 pub next: *mut aeTimeEvent,
163 pub refcount: libc::c_int,
164}
165pub type aeEventFinalizerProc = unsafe extern "C" fn(
166 *mut aeEventLoop,
167 *mut libc::c_void,
168) -> ();
169pub type aeTimeProc = unsafe extern "C" fn(
170 *mut aeEventLoop,
171 libc::c_longlong,
172 *mut libc::c_void,
173) -> libc::c_int;
174pub type monotime = uint64_t;
175#[derive(Copy, Clone)]
176#[repr(C)]
177pub struct aeFiredEvent {
178 pub fd: libc::c_int,
179 pub mask: libc::c_int,
180}
181#[derive(Copy, Clone)]
182#[repr(C)]
183pub struct aeFileEvent {
184 pub mask: libc::c_int,
185 pub rfileProc: Option::<aeFileProc>,
186 pub wfileProc: Option::<aeFileProc>,
187 pub clientData: *mut libc::c_void,
188}
189pub type aeFileProc = unsafe extern "C" fn(
190 *mut aeEventLoop,
191 libc::c_int,
192 *mut libc::c_void,
193 libc::c_int,
194) -> ();
195#[derive(Copy, Clone)]
196#[repr(C)]
197pub struct connection {
198 pub type_0: *mut ConnectionType,
199 pub state: ConnectionState,
200 pub flags: libc::c_short,
201 pub refs: libc::c_short,
202 pub last_errno: libc::c_int,
203 pub private_data: *mut libc::c_void,
204 pub conn_handler: ConnectionCallbackFunc,
205 pub write_handler: ConnectionCallbackFunc,
206 pub read_handler: ConnectionCallbackFunc,
207 pub fd: libc::c_int,
208}
209pub type ConnectionCallbackFunc = Option::<unsafe extern "C" fn(*mut connection) -> ()>;
210pub type ConnectionState = libc::c_uint;
211pub const CONN_STATE_ERROR: ConnectionState = 5;
212pub const CONN_STATE_CLOSED: ConnectionState = 4;
213pub const CONN_STATE_CONNECTED: ConnectionState = 3;
214pub const CONN_STATE_ACCEPTING: ConnectionState = 2;
215pub const CONN_STATE_CONNECTING: ConnectionState = 1;
216pub const CONN_STATE_NONE: ConnectionState = 0;
217#[derive(Copy, Clone)]
218#[repr(C)]
219pub struct ConnectionType {
220 pub ae_handler: Option::<
221 unsafe extern "C" fn(
222 *mut aeEventLoop,
223 libc::c_int,
224 *mut libc::c_void,
225 libc::c_int,
226 ) -> (),
227 >,
228 pub connect: Option::<
229 unsafe extern "C" fn(
230 *mut connection,
231 *const libc::c_char,
232 libc::c_int,
233 *const libc::c_char,
234 ConnectionCallbackFunc,
235 ) -> libc::c_int,
236 >,
237 pub write: Option::<
238 unsafe extern "C" fn(*mut connection, *const libc::c_void, size_t) -> libc::c_int,
239 >,
240 pub writev: Option::<
241 unsafe extern "C" fn(*mut connection, *const iovec, libc::c_int) -> libc::c_int,
242 >,
243 pub read: Option::<
244 unsafe extern "C" fn(*mut connection, *mut libc::c_void, size_t) -> libc::c_int,
245 >,
246 pub close: Option::<unsafe extern "C" fn(*mut connection) -> ()>,
247 pub accept: Option::<
248 unsafe extern "C" fn(*mut connection, ConnectionCallbackFunc) -> libc::c_int,
249 >,
250 pub set_write_handler: Option::<
251 unsafe extern "C" fn(
252 *mut connection,
253 ConnectionCallbackFunc,
254 libc::c_int,
255 ) -> libc::c_int,
256 >,
257 pub set_read_handler: Option::<
258 unsafe extern "C" fn(*mut connection, ConnectionCallbackFunc) -> libc::c_int,
259 >,
260 pub get_last_error: Option::<
261 unsafe extern "C" fn(*mut connection) -> *const libc::c_char,
262 >,
263 pub blocking_connect: Option::<
264 unsafe extern "C" fn(
265 *mut connection,
266 *const libc::c_char,
267 libc::c_int,
268 libc::c_longlong,
269 ) -> libc::c_int,
270 >,
271 pub sync_write: Option::<
272 unsafe extern "C" fn(
273 *mut connection,
274 *mut libc::c_char,
275 ssize_t,
276 libc::c_longlong,
277 ) -> ssize_t,
278 >,
279 pub sync_read: Option::<
280 unsafe extern "C" fn(
281 *mut connection,
282 *mut libc::c_char,
283 ssize_t,
284 libc::c_longlong,
285 ) -> ssize_t,
286 >,
287 pub sync_readline: Option::<
288 unsafe extern "C" fn(
289 *mut connection,
290 *mut libc::c_char,
291 ssize_t,
292 libc::c_longlong,
293 ) -> ssize_t,
294 >,
295 pub get_type: Option::<unsafe extern "C" fn(*mut connection) -> libc::c_int>,
296}
297#[derive(Copy, Clone,c2rust_bitfields:: BitfieldStruct)]
298#[repr(C)]
299pub struct redisObject {
300 #[bitfield(name = "type_0", ty = "libc::c_uint", bits = "0..=3")]
301 #[bitfield(name = "encoding", ty = "libc::c_uint", bits = "4..=7")]
302 #[bitfield(name = "lru", ty = "libc::c_uint", bits = "8..=31")]
303 pub type_0_encoding_lru: [u8; 4],
304 pub refcount: libc::c_int,
305 pub ptr: *mut libc::c_void,
306}
307pub type atomic_int = libc::c_int;
308pub type atomic_uint = libc::c_uint;
309pub type atomic_llong = libc::c_longlong;
310pub type sig_atomic_t = __sig_atomic_t;
311#[derive(Copy, Clone)]
312#[repr(C)]
313pub struct hdr_histogram {
314 pub lowest_discernible_value: int64_t,
315 pub highest_trackable_value: int64_t,
316 pub unit_magnitude: int32_t,
317 pub significant_figures: int32_t,
318 pub sub_bucket_half_count_magnitude: int32_t,
319 pub sub_bucket_half_count: int32_t,
320 pub sub_bucket_mask: int64_t,
321 pub sub_bucket_count: int32_t,
322 pub bucket_count: int32_t,
323 pub min_value: int64_t,
324 pub max_value: int64_t,
325 pub normalizing_index_offset: int32_t,
326 pub conversion_ratio: libc::c_double,
327 pub counts_len: int32_t,
328 pub total_count: int64_t,
329 pub counts: *mut int64_t,
330}
331pub type mstime_t = libc::c_longlong;
332pub type ustime_t = libc::c_longlong;
333#[derive(Copy, Clone)]
334#[repr(C)]
335pub struct dictEntry {
336 pub key: *mut libc::c_void,
337 pub v: C2RustUnnamed,
338 pub next: *mut dictEntry,
339 pub metadata: [*mut libc::c_void; 0],
340}
341#[derive(Copy, Clone)]
342#[repr(C)]
343pub union C2RustUnnamed {
344 pub val: *mut libc::c_void,
345 pub u64_0: uint64_t,
346 pub s64: int64_t,
347 pub d: libc::c_double,
348}
349#[derive(Copy, Clone)]
350#[repr(C)]
351pub struct dict {
352 pub type_0: *mut dictType,
353 pub ht_table: [*mut *mut dictEntry; 2],
354 pub ht_used: [libc::c_ulong; 2],
355 pub rehashidx: libc::c_long,
356 pub pauserehash: int16_t,
357 pub ht_size_exp: [libc::c_schar; 2],
358}
359#[derive(Copy, Clone)]
360#[repr(C)]
361pub struct dictType {
362 pub hashFunction: Option::<unsafe extern "C" fn(*const libc::c_void) -> uint64_t>,
363 pub keyDup: Option::<
364 unsafe extern "C" fn(*mut dict, *const libc::c_void) -> *mut libc::c_void,
365 >,
366 pub valDup: Option::<
367 unsafe extern "C" fn(*mut dict, *const libc::c_void) -> *mut libc::c_void,
368 >,
369 pub keyCompare: Option::<
370 unsafe extern "C" fn(
371 *mut dict,
372 *const libc::c_void,
373 *const libc::c_void,
374 ) -> libc::c_int,
375 >,
376 pub keyDestructor: Option::<
377 unsafe extern "C" fn(*mut dict, *mut libc::c_void) -> (),
378 >,
379 pub valDestructor: Option::<
380 unsafe extern "C" fn(*mut dict, *mut libc::c_void) -> (),
381 >,
382 pub expandAllowed: Option::<
383 unsafe extern "C" fn(size_t, libc::c_double) -> libc::c_int,
384 >,
385 pub dictEntryMetadataBytes: Option::<unsafe extern "C" fn(*mut dict) -> size_t>,
386}
387#[derive(Copy, Clone)]
388#[repr(C)]
389pub struct listNode {
390 pub prev: *mut listNode,
391 pub next: *mut listNode,
392 pub value: *mut libc::c_void,
393}
394#[derive(Copy, Clone)]
395#[repr(C)]
396pub struct list {
397 pub head: *mut listNode,
398 pub tail: *mut listNode,
399 pub dup: Option::<unsafe extern "C" fn(*mut libc::c_void) -> *mut libc::c_void>,
400 pub free: Option::<unsafe extern "C" fn(*mut libc::c_void) -> ()>,
401 pub match_0: Option::<
402 unsafe extern "C" fn(*mut libc::c_void, *mut libc::c_void) -> libc::c_int,
403 >,
404 pub len: libc::c_ulong,
405}
406#[derive(Copy, Clone,c2rust_bitfields:: BitfieldStruct)]
407#[repr(C)]
408pub struct raxNode {
409 #[bitfield(name = "iskey", ty = "uint32_t", bits = "0..=0")]
410 #[bitfield(name = "isnull", ty = "uint32_t", bits = "1..=1")]
411 #[bitfield(name = "iscompr", ty = "uint32_t", bits = "2..=2")]
412 #[bitfield(name = "size", ty = "uint32_t", bits = "3..=31")]
413 pub iskey_isnull_iscompr_size: [u8; 4],
414 pub data: [libc::c_uchar; 0],
415}
416#[derive(Copy, Clone)]
417#[repr(C)]
418pub struct rax {
419 pub head: *mut raxNode,
420 pub numele: uint64_t,
421 pub numnodes: uint64_t,
422}
423pub type C2RustUnnamed_0 = libc::c_uint;
424pub const REPL_STATE_CONNECTED: C2RustUnnamed_0 = 12;
425pub const REPL_STATE_TRANSFER: C2RustUnnamed_0 = 11;
426pub const REPL_STATE_RECEIVE_PSYNC_REPLY: C2RustUnnamed_0 = 10;
427pub const REPL_STATE_SEND_PSYNC: C2RustUnnamed_0 = 9;
428pub const REPL_STATE_RECEIVE_CAPA_REPLY: C2RustUnnamed_0 = 8;
429pub const REPL_STATE_RECEIVE_IP_REPLY: C2RustUnnamed_0 = 7;
430pub const REPL_STATE_RECEIVE_PORT_REPLY: C2RustUnnamed_0 = 6;
431pub const REPL_STATE_RECEIVE_AUTH_REPLY: C2RustUnnamed_0 = 5;
432pub const REPL_STATE_SEND_HANDSHAKE: C2RustUnnamed_0 = 4;
433pub const REPL_STATE_RECEIVE_PING_REPLY: C2RustUnnamed_0 = 3;
434pub const REPL_STATE_CONNECTING: C2RustUnnamed_0 = 2;
435pub const REPL_STATE_CONNECT: C2RustUnnamed_0 = 1;
436pub const REPL_STATE_NONE: C2RustUnnamed_0 = 0;
437pub type pause_type = libc::c_uint;
438pub const CLIENT_PAUSE_ALL: pause_type = 2;
439pub const CLIENT_PAUSE_WRITE: pause_type = 1;
440pub const CLIENT_PAUSE_OFF: pause_type = 0;
441#[derive(Copy, Clone)]
442#[repr(C)]
443pub struct pause_event {
444 pub type_0: pause_type,
445 pub end: mstime_t,
446}
447pub type robj = redisObject;
448pub type RedisModuleUserChangedFunc = Option::<
449 unsafe extern "C" fn(uint64_t, *mut libc::c_void) -> (),
450>;
451#[derive(Copy, Clone)]
452#[repr(C)]
453pub struct clusterSlotToKeyMapping {
454 pub by_slot: [slotToKeys; 16384],
455}
456#[derive(Copy, Clone)]
457#[repr(C)]
458pub struct slotToKeys {
459 pub count: uint64_t,
460 pub head: *mut dictEntry,
461}
462#[derive(Copy, Clone)]
463#[repr(C)]
464pub struct redisDb {
465 pub dict: *mut dict,
466 pub expires: *mut dict,
467 pub blocking_keys: *mut dict,
468 pub ready_keys: *mut dict,
469 pub watched_keys: *mut dict,
470 pub id: libc::c_int,
471 pub avg_ttl: libc::c_longlong,
472 pub expires_cursor: libc::c_ulong,
473 pub defrag_later: *mut list,
474 pub slots_to_keys: *mut clusterSlotToKeyMapping,
475}
476#[derive(Copy, Clone)]
477#[repr(C)]
478pub struct multiCmd {
479 pub argv: *mut *mut robj,
480 pub argv_len: libc::c_int,
481 pub argc: libc::c_int,
482 pub cmd: *mut redisCommand,
483}
484#[derive(Copy, Clone)]
485#[repr(C)]
486pub struct redisCommand {
487 pub declared_name: *const libc::c_char,
488 pub summary: *const libc::c_char,
489 pub complexity: *const libc::c_char,
490 pub since: *const libc::c_char,
491 pub doc_flags: libc::c_int,
492 pub replaced_by: *const libc::c_char,
493 pub deprecated_since: *const libc::c_char,
494 pub group: redisCommandGroup,
495 pub history: *mut commandHistory,
496 pub tips: *mut *const libc::c_char,
497 pub proc_0: Option::<redisCommandProc>,
498 pub arity: libc::c_int,
499 pub flags: uint64_t,
500 pub acl_categories: uint64_t,
501 pub key_specs_static: [keySpec; 4],
502 pub getkeys_proc: Option::<redisGetKeysProc>,
503 pub subcommands: *mut redisCommand,
504 pub args: *mut redisCommandArg,
505 pub microseconds: libc::c_longlong,
506 pub calls: libc::c_longlong,
507 pub rejected_calls: libc::c_longlong,
508 pub failed_calls: libc::c_longlong,
509 pub id: libc::c_int,
510 pub fullname: sds,
511 pub latency_histogram: *mut hdr_histogram,
512 pub key_specs: *mut keySpec,
513 pub legacy_range_key_spec: keySpec,
514 pub num_args: libc::c_int,
515 pub num_history: libc::c_int,
516 pub num_tips: libc::c_int,
517 pub key_specs_num: libc::c_int,
518 pub key_specs_max: libc::c_int,
519 pub subcommands_dict: *mut dict,
520 pub parent: *mut redisCommand,
521 pub module_cmd: *mut RedisModuleCommand,
522}
523#[derive(Copy, Clone)]
524#[repr(C)]
525pub struct keySpec {
526 pub notes: *const libc::c_char,
527 pub flags: uint64_t,
528 pub begin_search_type: kspec_bs_type,
529 pub bs: C2RustUnnamed_4,
530 pub find_keys_type: kspec_fk_type,
531 pub fk: C2RustUnnamed_1,
532}
533#[derive(Copy, Clone)]
534#[repr(C)]
535pub union C2RustUnnamed_1 {
536 pub range: C2RustUnnamed_3,
537 pub keynum: C2RustUnnamed_2,
538}
539#[derive(Copy, Clone)]
540#[repr(C)]
541pub struct C2RustUnnamed_2 {
542 pub keynumidx: libc::c_int,
543 pub firstkey: libc::c_int,
544 pub keystep: libc::c_int,
545}
546#[derive(Copy, Clone)]
547#[repr(C)]
548pub struct C2RustUnnamed_3 {
549 pub lastkey: libc::c_int,
550 pub keystep: libc::c_int,
551 pub limit: libc::c_int,
552}
553pub type kspec_fk_type = libc::c_uint;
554pub const KSPEC_FK_KEYNUM: kspec_fk_type = 3;
555pub const KSPEC_FK_RANGE: kspec_fk_type = 2;
556pub const KSPEC_FK_UNKNOWN: kspec_fk_type = 1;
557pub const KSPEC_FK_INVALID: kspec_fk_type = 0;
558#[derive(Copy, Clone)]
559#[repr(C)]
560pub union C2RustUnnamed_4 {
561 pub index: C2RustUnnamed_6,
562 pub keyword: C2RustUnnamed_5,
563}
564#[derive(Copy, Clone)]
565#[repr(C)]
566pub struct C2RustUnnamed_5 {
567 pub keyword: *const libc::c_char,
568 pub startfrom: libc::c_int,
569}
570#[derive(Copy, Clone)]
571#[repr(C)]
572pub struct C2RustUnnamed_6 {
573 pub pos: libc::c_int,
574}
575pub type kspec_bs_type = libc::c_uint;
576pub const KSPEC_BS_KEYWORD: kspec_bs_type = 3;
577pub const KSPEC_BS_INDEX: kspec_bs_type = 2;
578pub const KSPEC_BS_UNKNOWN: kspec_bs_type = 1;
579pub const KSPEC_BS_INVALID: kspec_bs_type = 0;
580#[derive(Copy, Clone)]
581#[repr(C)]
582pub struct redisCommandArg {
583 pub name: *const libc::c_char,
584 pub type_0: redisCommandArgType,
585 pub key_spec_index: libc::c_int,
586 pub token: *const libc::c_char,
587 pub summary: *const libc::c_char,
588 pub since: *const libc::c_char,
589 pub flags: libc::c_int,
590 pub deprecated_since: *const libc::c_char,
591 pub subargs: *mut redisCommandArg,
592 pub num_args: libc::c_int,
593}
594pub type redisCommandArgType = libc::c_uint;
595pub const ARG_TYPE_BLOCK: redisCommandArgType = 8;
596pub const ARG_TYPE_ONEOF: redisCommandArgType = 7;
597pub const ARG_TYPE_PURE_TOKEN: redisCommandArgType = 6;
598pub const ARG_TYPE_UNIX_TIME: redisCommandArgType = 5;
599pub const ARG_TYPE_PATTERN: redisCommandArgType = 4;
600pub const ARG_TYPE_KEY: redisCommandArgType = 3;
601pub const ARG_TYPE_DOUBLE: redisCommandArgType = 2;
602pub const ARG_TYPE_INTEGER: redisCommandArgType = 1;
603pub const ARG_TYPE_STRING: redisCommandArgType = 0;
604pub type redisGetKeysProc = unsafe extern "C" fn(
605 *mut redisCommand,
606 *mut *mut robj,
607 libc::c_int,
608 *mut getKeysResult,
609) -> libc::c_int;
610#[derive(Copy, Clone)]
611#[repr(C)]
612pub struct getKeysResult {
613 pub keysbuf: [keyReference; 256],
614 pub keys: *mut keyReference,
615 pub numkeys: libc::c_int,
616 pub size: libc::c_int,
617}
618#[derive(Copy, Clone)]
619#[repr(C)]
620pub struct keyReference {
621 pub pos: libc::c_int,
622 pub flags: libc::c_int,
623}
624pub type redisCommandProc = unsafe extern "C" fn(*mut client) -> ();
625#[derive(Copy, Clone)]
626#[repr(C)]
627pub struct client {
628 pub id: uint64_t,
629 pub flags: uint64_t,
630 pub conn: *mut connection,
631 pub resp: libc::c_int,
632 pub db: *mut redisDb,
633 pub name: *mut robj,
634 pub querybuf: sds,
635 pub qb_pos: size_t,
636 pub querybuf_peak: size_t,
637 pub argc: libc::c_int,
638 pub argv: *mut *mut robj,
639 pub argv_len: libc::c_int,
640 pub original_argc: libc::c_int,
641 pub original_argv: *mut *mut robj,
642 pub argv_len_sum: size_t,
643 pub cmd: *mut redisCommand,
644 pub lastcmd: *mut redisCommand,
645 pub realcmd: *mut redisCommand,
646 pub user: *mut user,
647 pub reqtype: libc::c_int,
648 pub multibulklen: libc::c_int,
649 pub bulklen: libc::c_long,
650 pub reply: *mut list,
651 pub reply_bytes: libc::c_ulonglong,
652 pub deferred_reply_errors: *mut list,
653 pub sentlen: size_t,
654 pub ctime: time_t,
655 pub duration: libc::c_long,
656 pub slot: libc::c_int,
657 pub cur_script: *mut dictEntry,
658 pub lastinteraction: time_t,
659 pub obuf_soft_limit_reached_time: time_t,
660 pub authenticated: libc::c_int,
661 pub replstate: libc::c_int,
662 pub repl_start_cmd_stream_on_ack: libc::c_int,
663 pub repldbfd: libc::c_int,
664 pub repldboff: off_t,
665 pub repldbsize: off_t,
666 pub replpreamble: sds,
667 pub read_reploff: libc::c_longlong,
668 pub reploff: libc::c_longlong,
669 pub repl_applied: libc::c_longlong,
670 pub repl_ack_off: libc::c_longlong,
671 pub repl_ack_time: libc::c_longlong,
672 pub repl_last_partial_write: libc::c_longlong,
673 pub psync_initial_offset: libc::c_longlong,
674 pub replid: [libc::c_char; 41],
675 pub slave_listening_port: libc::c_int,
676 pub slave_addr: *mut libc::c_char,
677 pub slave_capa: libc::c_int,
678 pub slave_req: libc::c_int,
679 pub mstate: multiState,
680 pub btype: libc::c_int,
681 pub bpop: blockingState,
682 pub woff: libc::c_longlong,
683 pub watched_keys: *mut list,
684 pub pubsub_channels: *mut dict,
685 pub pubsub_patterns: *mut list,
686 pub pubsubshard_channels: *mut dict,
687 pub peerid: sds,
688 pub sockname: sds,
689 pub client_list_node: *mut listNode,
690 pub postponed_list_node: *mut listNode,
691 pub pending_read_list_node: *mut listNode,
692 pub auth_callback: RedisModuleUserChangedFunc,
693 pub auth_callback_privdata: *mut libc::c_void,
694 pub auth_module: *mut libc::c_void,
695 pub client_tracking_redirection: uint64_t,
696 pub client_tracking_prefixes: *mut rax,
697 pub last_memory_usage: size_t,
698 pub last_memory_type: libc::c_int,
699 pub mem_usage_bucket_node: *mut listNode,
700 pub mem_usage_bucket: *mut clientMemUsageBucket,
701 pub ref_repl_buf_node: *mut listNode,
702 pub ref_block_pos: size_t,
703 pub buf_peak: size_t,
704 pub buf_peak_last_reset_time: mstime_t,
705 pub bufpos: libc::c_int,
706 pub buf_usable_size: size_t,
707 pub buf: *mut libc::c_char,
708}
709#[derive(Copy, Clone)]
710#[repr(C)]
711pub struct clientMemUsageBucket {
712 pub clients: *mut list,
713 pub mem_usage_sum: size_t,
714}
715#[derive(Copy, Clone)]
716#[repr(C)]
717pub struct blockingState {
718 pub count: libc::c_long,
719 pub timeout: mstime_t,
720 pub keys: *mut dict,
721 pub target: *mut robj,
722 pub blockpos: blockPos,
723 pub xread_count: size_t,
724 pub xread_group: *mut robj,
725 pub xread_consumer: *mut robj,
726 pub xread_group_noack: libc::c_int,
727 pub numreplicas: libc::c_int,
728 pub reploffset: libc::c_longlong,
729 pub module_blocked_handle: *mut libc::c_void,
730}
731#[derive(Copy, Clone)]
732#[repr(C)]
733pub struct blockPos {
734 pub wherefrom: libc::c_int,
735 pub whereto: libc::c_int,
736}
737#[derive(Copy, Clone)]
738#[repr(C)]
739pub struct multiState {
740 pub commands: *mut multiCmd,
741 pub count: libc::c_int,
742 pub cmd_flags: libc::c_int,
743 pub cmd_inv_flags: libc::c_int,
744 pub argv_len_sums: size_t,
745 pub alloc_count: libc::c_int,
746}
747#[derive(Copy, Clone)]
748#[repr(C)]
749pub struct user {
750 pub name: sds,
751 pub flags: uint32_t,
752 pub passwords: *mut list,
753 pub selectors: *mut list,
754 pub acl_string: *mut robj,
755}
756#[derive(Copy, Clone)]
757#[repr(C)]
758pub struct commandHistory {
759 pub since: *const libc::c_char,
760 pub changes: *const libc::c_char,
761}
762pub type redisCommandGroup = libc::c_uint;
763pub const COMMAND_GROUP_MODULE: redisCommandGroup = 17;
764pub const COMMAND_GROUP_BITMAP: redisCommandGroup = 16;
765pub const COMMAND_GROUP_STREAM: redisCommandGroup = 15;
766pub const COMMAND_GROUP_GEO: redisCommandGroup = 14;
767pub const COMMAND_GROUP_SENTINEL: redisCommandGroup = 13;
768pub const COMMAND_GROUP_CLUSTER: redisCommandGroup = 12;
769pub const COMMAND_GROUP_HYPERLOGLOG: redisCommandGroup = 11;
770pub const COMMAND_GROUP_SCRIPTING: redisCommandGroup = 10;
771pub const COMMAND_GROUP_SERVER: redisCommandGroup = 9;
772pub const COMMAND_GROUP_CONNECTION: redisCommandGroup = 8;
773pub const COMMAND_GROUP_TRANSACTIONS: redisCommandGroup = 7;
774pub const COMMAND_GROUP_PUBSUB: redisCommandGroup = 6;
775pub const COMMAND_GROUP_HASH: redisCommandGroup = 5;
776pub const COMMAND_GROUP_SORTED_SET: redisCommandGroup = 4;
777pub const COMMAND_GROUP_SET: redisCommandGroup = 3;
778pub const COMMAND_GROUP_LIST: redisCommandGroup = 2;
779pub const COMMAND_GROUP_STRING: redisCommandGroup = 1;
780pub const COMMAND_GROUP_GENERIC: redisCommandGroup = 0;
781#[derive(Copy, Clone)]
782#[repr(C)]
783pub struct replBacklog {
784 pub ref_repl_buf_node: *mut listNode,
785 pub unindexed_count: size_t,
786 pub blocks_index: *mut rax,
787 pub histlen: libc::c_longlong,
788 pub offset: libc::c_longlong,
789}
790#[derive(Copy, Clone)]
791#[repr(C)]
792pub struct saveparam {
793 pub seconds: time_t,
794 pub changes: libc::c_int,
795}
796#[derive(Copy, Clone)]
797#[repr(C)]
798pub struct sentinelConfig {
799 pub pre_monitor_cfg: *mut list,
800 pub monitor_cfg: *mut list,
801 pub post_monitor_cfg: *mut list,
802}
803#[derive(Copy, Clone)]
804#[repr(C)]
805pub struct sharedObjectsStruct {
806 pub crlf: *mut robj,
807 pub ok: *mut robj,
808 pub err: *mut robj,
809 pub emptybulk: *mut robj,
810 pub czero: *mut robj,
811 pub cone: *mut robj,
812 pub pong: *mut robj,
813 pub space: *mut robj,
814 pub queued: *mut robj,
815 pub null: [*mut robj; 4],
816 pub nullarray: [*mut robj; 4],
817 pub emptymap: [*mut robj; 4],
818 pub emptyset: [*mut robj; 4],
819 pub emptyarray: *mut robj,
820 pub wrongtypeerr: *mut robj,
821 pub nokeyerr: *mut robj,
822 pub syntaxerr: *mut robj,
823 pub sameobjecterr: *mut robj,
824 pub outofrangeerr: *mut robj,
825 pub noscripterr: *mut robj,
826 pub loadingerr: *mut robj,
827 pub slowevalerr: *mut robj,
828 pub slowscripterr: *mut robj,
829 pub slowmoduleerr: *mut robj,
830 pub bgsaveerr: *mut robj,
831 pub masterdownerr: *mut robj,
832 pub roslaveerr: *mut robj,
833 pub execaborterr: *mut robj,
834 pub noautherr: *mut robj,
835 pub noreplicaserr: *mut robj,
836 pub busykeyerr: *mut robj,
837 pub oomerr: *mut robj,
838 pub plus: *mut robj,
839 pub messagebulk: *mut robj,
840 pub pmessagebulk: *mut robj,
841 pub subscribebulk: *mut robj,
842 pub unsubscribebulk: *mut robj,
843 pub psubscribebulk: *mut robj,
844 pub punsubscribebulk: *mut robj,
845 pub del: *mut robj,
846 pub unlink: *mut robj,
847 pub rpop: *mut robj,
848 pub lpop: *mut robj,
849 pub lpush: *mut robj,
850 pub rpoplpush: *mut robj,
851 pub lmove: *mut robj,
852 pub blmove: *mut robj,
853 pub zpopmin: *mut robj,
854 pub zpopmax: *mut robj,
855 pub emptyscan: *mut robj,
856 pub multi: *mut robj,
857 pub exec: *mut robj,
858 pub left: *mut robj,
859 pub right: *mut robj,
860 pub hset: *mut robj,
861 pub srem: *mut robj,
862 pub xgroup: *mut robj,
863 pub xclaim: *mut robj,
864 pub script: *mut robj,
865 pub replconf: *mut robj,
866 pub eval: *mut robj,
867 pub persist: *mut robj,
868 pub set: *mut robj,
869 pub pexpireat: *mut robj,
870 pub pexpire: *mut robj,
871 pub time: *mut robj,
872 pub pxat: *mut robj,
873 pub absttl: *mut robj,
874 pub retrycount: *mut robj,
875 pub force: *mut robj,
876 pub justid: *mut robj,
877 pub entriesread: *mut robj,
878 pub lastid: *mut robj,
879 pub ping: *mut robj,
880 pub setid: *mut robj,
881 pub keepttl: *mut robj,
882 pub load: *mut robj,
883 pub createconsumer: *mut robj,
884 pub getack: *mut robj,
885 pub special_asterick: *mut robj,
886 pub special_equals: *mut robj,
887 pub default_username: *mut robj,
888 pub redacted: *mut robj,
889 pub ssubscribebulk: *mut robj,
890 pub sunsubscribebulk: *mut robj,
891 pub smessagebulk: *mut robj,
892 pub select: [*mut robj; 10],
893 pub integers: [*mut robj; 10000],
894 pub mbulkhdr: [*mut robj; 32],
895 pub bulkhdr: [*mut robj; 32],
896 pub maphdr: [*mut robj; 32],
897 pub sethdr: [*mut robj; 32],
898 pub minstring: sds,
899 pub maxstring: sds,
900}
901#[derive(Copy, Clone)]
902#[repr(C)]
903pub struct clientBufferLimitsConfig {
904 pub hard_limit_bytes: libc::c_ulonglong,
905 pub soft_limit_bytes: libc::c_ulonglong,
906 pub soft_limit_seconds: time_t,
907}
908#[derive(Copy, Clone)]
909#[repr(C)]
910pub struct redisOp {
911 pub argv: *mut *mut robj,
912 pub argc: libc::c_int,
913 pub dbid: libc::c_int,
914 pub target: libc::c_int,
915}
916#[derive(Copy, Clone)]
917#[repr(C)]
918pub struct redisOpArray {
919 pub ops: *mut redisOp,
920 pub numops: libc::c_int,
921 pub capacity: libc::c_int,
922}
923#[derive(Copy, Clone)]
924#[repr(C)]
925pub struct malloc_stats {
926 pub zmalloc_used: size_t,
927 pub process_rss: size_t,
928 pub allocator_allocated: size_t,
929 pub allocator_active: size_t,
930 pub allocator_resident: size_t,
931}
932#[derive(Copy, Clone)]
933#[repr(C)]
934pub struct socketFds {
935 pub fd: [libc::c_int; 16],
936 pub count: libc::c_int,
937}
938#[derive(Copy, Clone)]
939#[repr(C)]
940pub struct redisTLSContextConfig {
941 pub cert_file: *mut libc::c_char,
942 pub key_file: *mut libc::c_char,
943 pub key_file_pass: *mut libc::c_char,
944 pub client_cert_file: *mut libc::c_char,
945 pub client_key_file: *mut libc::c_char,
946 pub client_key_file_pass: *mut libc::c_char,
947 pub dh_params_file: *mut libc::c_char,
948 pub ca_cert_file: *mut libc::c_char,
949 pub ca_cert_dir: *mut libc::c_char,
950 pub protocols: *mut libc::c_char,
951 pub ciphers: *mut libc::c_char,
952 pub ciphersuites: *mut libc::c_char,
953 pub prefer_server_ciphers: libc::c_int,
954 pub session_caching: libc::c_int,
955 pub session_cache_size: libc::c_int,
956 pub session_cache_timeout: libc::c_int,
957}
958pub type aof_file_type = libc::c_uint;
959pub const AOF_FILE_TYPE_INCR: aof_file_type = 105;
960pub const AOF_FILE_TYPE_HIST: aof_file_type = 104;
961pub const AOF_FILE_TYPE_BASE: aof_file_type = 98;
962#[derive(Copy, Clone)]
963#[repr(C)]
964pub struct aofInfo {
965 pub file_name: sds,
966 pub file_seq: libc::c_longlong,
967 pub file_type: aof_file_type,
968}
969#[derive(Copy, Clone)]
970#[repr(C)]
971pub struct aofManifest {
972 pub base_aof_info: *mut aofInfo,
973 pub incr_aof_list: *mut list,
974 pub history_aof_list: *mut list,
975 pub curr_base_file_seq: libc::c_longlong,
976 pub curr_incr_file_seq: libc::c_longlong,
977 pub dirty: libc::c_int,
978}
979#[derive(Copy, Clone)]
980#[repr(C)]
981pub struct redisServer {
982 pub pid: pid_t,
983 pub main_thread_id: pthread_t,
984 pub configfile: *mut libc::c_char,
985 pub executable: *mut libc::c_char,
986 pub exec_argv: *mut *mut libc::c_char,
987 pub dynamic_hz: libc::c_int,
988 pub config_hz: libc::c_int,
989 pub umask: mode_t,
990 pub hz: libc::c_int,
991 pub in_fork_child: libc::c_int,
992 pub db: *mut redisDb,
993 pub commands: *mut dict,
994 pub orig_commands: *mut dict,
995 pub el: *mut aeEventLoop,
996 pub errors: *mut rax,
997 pub lruclock: atomic_uint,
998 pub shutdown_asap: sig_atomic_t,
999 pub shutdown_mstime: mstime_t,
1000 pub last_sig_received: libc::c_int,
1001 pub shutdown_flags: libc::c_int,
1002 pub activerehashing: libc::c_int,
1003 pub active_defrag_running: libc::c_int,
1004 pub pidfile: *mut libc::c_char,
1005 pub arch_bits: libc::c_int,
1006 pub cronloops: libc::c_int,
1007 pub runid: [libc::c_char; 41],
1008 pub sentinel_mode: libc::c_int,
1009 pub initial_memory_usage: size_t,
1010 pub always_show_logo: libc::c_int,
1011 pub in_exec: libc::c_int,
1012 pub busy_module_yield_flags: libc::c_int,
1013 pub busy_module_yield_reply: *const libc::c_char,
1014 pub core_propagates: libc::c_int,
1015 pub propagate_no_multi: libc::c_int,
1016 pub module_ctx_nesting: libc::c_int,
1017 pub ignore_warnings: *mut libc::c_char,
1018 pub client_pause_in_transaction: libc::c_int,
1019 pub thp_enabled: libc::c_int,
1020 pub page_size: size_t,
1021 pub moduleapi: *mut dict,
1022 pub sharedapi: *mut dict,
1023 pub module_configs_queue: *mut dict,
1024 pub loadmodule_queue: *mut list,
1025 pub module_pipe: [libc::c_int; 2],
1026 pub child_pid: pid_t,
1027 pub child_type: libc::c_int,
1028 pub port: libc::c_int,
1029 pub tls_port: libc::c_int,
1030 pub tcp_backlog: libc::c_int,
1031 pub bindaddr: [*mut libc::c_char; 16],
1032 pub bindaddr_count: libc::c_int,
1033 pub bind_source_addr: *mut libc::c_char,
1034 pub unixsocket: *mut libc::c_char,
1035 pub unixsocketperm: libc::c_uint,
1036 pub ipfd: socketFds,
1037 pub tlsfd: socketFds,
1038 pub sofd: libc::c_int,
1039 pub socket_mark_id: uint32_t,
1040 pub cfd: socketFds,
1041 pub clients: *mut list,
1042 pub clients_to_close: *mut list,
1043 pub clients_pending_write: *mut list,
1044 pub clients_pending_read: *mut list,
1045 pub slaves: *mut list,
1046 pub monitors: *mut list,
1047 pub current_client: *mut client,
1048 pub client_mem_usage_buckets: *mut clientMemUsageBucket,
1049 pub clients_timeout_table: *mut rax,
1050 pub fixed_time_expire: libc::c_long,
1051 pub in_nested_call: libc::c_int,
1052 pub clients_index: *mut rax,
1053 pub client_pause_type: pause_type,
1054 pub postponed_clients: *mut list,
1055 pub client_pause_end_time: mstime_t,
1056 pub client_pause_per_purpose: [*mut pause_event; 3],
1057 pub neterr: [libc::c_char; 256],
1058 pub migrate_cached_sockets: *mut dict,
1059 pub next_client_id: uint_least64_t,
1060 pub protected_mode: libc::c_int,
1061 pub io_threads_num: libc::c_int,
1062 pub io_threads_do_reads: libc::c_int,
1063 pub io_threads_active: libc::c_int,
1064 pub events_processed_while_blocked: libc::c_longlong,
1065 pub enable_protected_configs: libc::c_int,
1066 pub enable_debug_cmd: libc::c_int,
1067 pub enable_module_cmd: libc::c_int,
1068 pub loading: sig_atomic_t,
1069 pub async_loading: sig_atomic_t,
1070 pub loading_total_bytes: off_t,
1071 pub loading_rdb_used_mem: off_t,
1072 pub loading_loaded_bytes: off_t,
1073 pub loading_start_time: time_t,
1074 pub loading_process_events_interval_bytes: off_t,
1075 pub stat_starttime: time_t,
1076 pub stat_numcommands: libc::c_longlong,
1077 pub stat_numconnections: libc::c_longlong,
1078 pub stat_expiredkeys: libc::c_longlong,
1079 pub stat_expired_stale_perc: libc::c_double,
1080 pub stat_expired_time_cap_reached_count: libc::c_longlong,
1081 pub stat_expire_cycle_time_used: libc::c_longlong,
1082 pub stat_evictedkeys: libc::c_longlong,
1083 pub stat_evictedclients: libc::c_longlong,
1084 pub stat_total_eviction_exceeded_time: libc::c_longlong,
1085 pub stat_last_eviction_exceeded_time: monotime,
1086 pub stat_keyspace_hits: libc::c_longlong,
1087 pub stat_keyspace_misses: libc::c_longlong,
1088 pub stat_active_defrag_hits: libc::c_longlong,
1089 pub stat_active_defrag_misses: libc::c_longlong,
1090 pub stat_active_defrag_key_hits: libc::c_longlong,
1091 pub stat_active_defrag_key_misses: libc::c_longlong,
1092 pub stat_active_defrag_scanned: libc::c_longlong,
1093 pub stat_total_active_defrag_time: libc::c_longlong,
1094 pub stat_last_active_defrag_time: monotime,
1095 pub stat_peak_memory: size_t,
1096 pub stat_aof_rewrites: libc::c_longlong,
1097 pub stat_aofrw_consecutive_failures: libc::c_longlong,
1098 pub stat_rdb_saves: libc::c_longlong,
1099 pub stat_fork_time: libc::c_longlong,
1100 pub stat_fork_rate: libc::c_double,
1101 pub stat_total_forks: libc::c_longlong,
1102 pub stat_rejected_conn: libc::c_longlong,
1103 pub stat_sync_full: libc::c_longlong,
1104 pub stat_sync_partial_ok: libc::c_longlong,
1105 pub stat_sync_partial_err: libc::c_longlong,
1106 pub slowlog: *mut list,
1107 pub slowlog_entry_id: libc::c_longlong,
1108 pub slowlog_log_slower_than: libc::c_longlong,
1109 pub slowlog_max_len: libc::c_ulong,
1110 pub cron_malloc_stats: malloc_stats,
1111 pub stat_net_input_bytes: atomic_llong,
1112 pub stat_net_output_bytes: atomic_llong,
1113 pub stat_net_repl_input_bytes: atomic_llong,
1114 pub stat_net_repl_output_bytes: atomic_llong,
1115 pub stat_current_cow_peak: size_t,
1116 pub stat_current_cow_bytes: size_t,
1117 pub stat_current_cow_updated: monotime,
1118 pub stat_current_save_keys_processed: size_t,
1119 pub stat_current_save_keys_total: size_t,
1120 pub stat_rdb_cow_bytes: size_t,
1121 pub stat_aof_cow_bytes: size_t,
1122 pub stat_module_cow_bytes: size_t,
1123 pub stat_module_progress: libc::c_double,
1124 pub stat_clients_type_memory: [size_t; 4],
1125 pub stat_cluster_links_memory: size_t,
1126 pub stat_unexpected_error_replies: libc::c_longlong,
1127 pub stat_total_error_replies: libc::c_longlong,
1128 pub stat_dump_payload_sanitizations: libc::c_longlong,
1129 pub stat_io_reads_processed: libc::c_longlong,
1130 pub stat_io_writes_processed: libc::c_longlong,
1131 pub stat_total_reads_processed: atomic_llong,
1132 pub stat_total_writes_processed: atomic_llong,
1133 pub inst_metric: [C2RustUnnamed_7; 5],
1134 pub stat_reply_buffer_shrinks: libc::c_longlong,
1135 pub stat_reply_buffer_expands: libc::c_longlong,
1136 pub verbosity: libc::c_int,
1137 pub maxidletime: libc::c_int,
1138 pub tcpkeepalive: libc::c_int,
1139 pub active_expire_enabled: libc::c_int,
1140 pub active_expire_effort: libc::c_int,
1141 pub active_defrag_enabled: libc::c_int,
1142 pub sanitize_dump_payload: libc::c_int,
1143 pub skip_checksum_validation: libc::c_int,
1144 pub jemalloc_bg_thread: libc::c_int,
1145 pub active_defrag_ignore_bytes: size_t,
1146 pub active_defrag_threshold_lower: libc::c_int,
1147 pub active_defrag_threshold_upper: libc::c_int,
1148 pub active_defrag_cycle_min: libc::c_int,
1149 pub active_defrag_cycle_max: libc::c_int,
1150 pub active_defrag_max_scan_fields: libc::c_ulong,
1151 pub client_max_querybuf_len: size_t,
1152 pub dbnum: libc::c_int,
1153 pub supervised: libc::c_int,
1154 pub supervised_mode: libc::c_int,
1155 pub daemonize: libc::c_int,
1156 pub set_proc_title: libc::c_int,
1157 pub proc_title_template: *mut libc::c_char,
1158 pub client_obuf_limits: [clientBufferLimitsConfig; 3],
1159 pub pause_cron: libc::c_int,
1160 pub latency_tracking_enabled: libc::c_int,
1161 pub latency_tracking_info_percentiles: *mut libc::c_double,
1162 pub latency_tracking_info_percentiles_len: libc::c_int,
1163 pub aof_enabled: libc::c_int,
1164 pub aof_state: libc::c_int,
1165 pub aof_fsync: libc::c_int,
1166 pub aof_filename: *mut libc::c_char,
1167 pub aof_dirname: *mut libc::c_char,
1168 pub aof_no_fsync_on_rewrite: libc::c_int,
1169 pub aof_rewrite_perc: libc::c_int,
1170 pub aof_rewrite_min_size: off_t,
1171 pub aof_rewrite_base_size: off_t,
1172 pub aof_current_size: off_t,
1173 pub aof_last_incr_size: off_t,
1174 pub aof_fsync_offset: off_t,
1175 pub aof_flush_sleep: libc::c_int,
1176 pub aof_rewrite_scheduled: libc::c_int,
1177 pub aof_buf: sds,
1178 pub aof_fd: libc::c_int,
1179 pub aof_selected_db: libc::c_int,
1180 pub aof_flush_postponed_start: time_t,
1181 pub aof_last_fsync: time_t,
1182 pub aof_rewrite_time_last: time_t,
1183 pub aof_rewrite_time_start: time_t,
1184 pub aof_cur_timestamp: time_t,
1185 pub aof_timestamp_enabled: libc::c_int,
1186 pub aof_lastbgrewrite_status: libc::c_int,
1187 pub aof_delayed_fsync: libc::c_ulong,
1188 pub aof_rewrite_incremental_fsync: libc::c_int,
1189 pub rdb_save_incremental_fsync: libc::c_int,
1190 pub aof_last_write_status: libc::c_int,
1191 pub aof_last_write_errno: libc::c_int,
1192 pub aof_load_truncated: libc::c_int,
1193 pub aof_use_rdb_preamble: libc::c_int,
1194 pub aof_bio_fsync_status: atomic_int,
1195 pub aof_bio_fsync_errno: atomic_int,
1196 pub aof_manifest: *mut aofManifest,
1197 pub aof_disable_auto_gc: libc::c_int,
1198 pub dirty: libc::c_longlong,
1199 pub dirty_before_bgsave: libc::c_longlong,
1200 pub rdb_last_load_keys_expired: libc::c_longlong,
1201 pub rdb_last_load_keys_loaded: libc::c_longlong,
1202 pub saveparams: *mut saveparam,
1203 pub saveparamslen: libc::c_int,
1204 pub rdb_filename: *mut libc::c_char,
1205 pub rdb_compression: libc::c_int,
1206 pub rdb_checksum: libc::c_int,
1207 pub rdb_del_sync_files: libc::c_int,
1208 pub lastsave: time_t,
1209 pub lastbgsave_try: time_t,
1210 pub rdb_save_time_last: time_t,
1211 pub rdb_save_time_start: time_t,
1212 pub rdb_bgsave_scheduled: libc::c_int,
1213 pub rdb_child_type: libc::c_int,
1214 pub lastbgsave_status: libc::c_int,
1215 pub stop_writes_on_bgsave_err: libc::c_int,
1216 pub rdb_pipe_read: libc::c_int,
1217 pub rdb_child_exit_pipe: libc::c_int,
1218 pub rdb_pipe_conns: *mut *mut connection,
1219 pub rdb_pipe_numconns: libc::c_int,
1220 pub rdb_pipe_numconns_writing: libc::c_int,
1221 pub rdb_pipe_buff: *mut libc::c_char,
1222 pub rdb_pipe_bufflen: libc::c_int,
1223 pub rdb_key_save_delay: libc::c_int,
1224 pub key_load_delay: libc::c_int,
1225 pub child_info_pipe: [libc::c_int; 2],
1226 pub child_info_nread: libc::c_int,
1227 pub also_propagate: redisOpArray,
1228 pub replication_allowed: libc::c_int,
1229 pub logfile: *mut libc::c_char,
1230 pub syslog_enabled: libc::c_int,
1231 pub syslog_ident: *mut libc::c_char,
1232 pub syslog_facility: libc::c_int,
1233 pub crashlog_enabled: libc::c_int,
1234 pub memcheck_enabled: libc::c_int,
1235 pub use_exit_on_panic: libc::c_int,
1236 pub shutdown_timeout: libc::c_int,
1237 pub shutdown_on_sigint: libc::c_int,
1238 pub shutdown_on_sigterm: libc::c_int,
1239 pub replid: [libc::c_char; 41],
1240 pub replid2: [libc::c_char; 41],
1241 pub master_repl_offset: libc::c_longlong,
1242 pub second_replid_offset: libc::c_longlong,
1243 pub slaveseldb: libc::c_int,
1244 pub repl_ping_slave_period: libc::c_int,
1245 pub repl_backlog: *mut replBacklog,
1246 pub repl_backlog_size: libc::c_longlong,
1247 pub repl_backlog_time_limit: time_t,
1248 pub repl_no_slaves_since: time_t,
1249 pub repl_min_slaves_to_write: libc::c_int,
1250 pub repl_min_slaves_max_lag: libc::c_int,
1251 pub repl_good_slaves_count: libc::c_int,
1252 pub repl_diskless_sync: libc::c_int,
1253 pub repl_diskless_load: libc::c_int,
1254 pub repl_diskless_sync_delay: libc::c_int,
1255 pub repl_diskless_sync_max_replicas: libc::c_int,
1256 pub repl_buffer_mem: size_t,
1257 pub repl_buffer_blocks: *mut list,
1258 pub masteruser: *mut libc::c_char,
1259 pub masterauth: sds,
1260 pub masterhost: *mut libc::c_char,
1261 pub masterport: libc::c_int,
1262 pub repl_timeout: libc::c_int,
1263 pub master: *mut client,
1264 pub cached_master: *mut client,
1265 pub repl_syncio_timeout: libc::c_int,
1266 pub repl_state: libc::c_int,
1267 pub repl_transfer_size: off_t,
1268 pub repl_transfer_read: off_t,
1269 pub repl_transfer_last_fsync_off: off_t,
1270 pub repl_transfer_s: *mut connection,
1271 pub repl_transfer_fd: libc::c_int,
1272 pub repl_transfer_tmpfile: *mut libc::c_char,
1273 pub repl_transfer_lastio: time_t,
1274 pub repl_serve_stale_data: libc::c_int,
1275 pub repl_slave_ro: libc::c_int,
1276 pub repl_slave_ignore_maxmemory: libc::c_int,
1277 pub repl_down_since: time_t,
1278 pub repl_disable_tcp_nodelay: libc::c_int,
1279 pub slave_priority: libc::c_int,
1280 pub replica_announced: libc::c_int,
1281 pub slave_announce_port: libc::c_int,
1282 pub slave_announce_ip: *mut libc::c_char,
1283 pub propagation_error_behavior: libc::c_int,
1284 pub repl_ignore_disk_write_error: libc::c_int,
1285 pub master_replid: [libc::c_char; 41],
1286 pub master_initial_offset: libc::c_longlong,
1287 pub repl_slave_lazy_flush: libc::c_int,
1288 pub clients_waiting_acks: *mut list,
1289 pub get_ack_from_slaves: libc::c_int,
1290 pub maxclients: libc::c_uint,
1291 pub maxmemory: libc::c_ulonglong,
1292 pub maxmemory_clients: ssize_t,
1293 pub maxmemory_policy: libc::c_int,
1294 pub maxmemory_samples: libc::c_int,
1295 pub maxmemory_eviction_tenacity: libc::c_int,
1296 pub lfu_log_factor: libc::c_int,
1297 pub lfu_decay_time: libc::c_int,
1298 pub proto_max_bulk_len: libc::c_longlong,
1299 pub oom_score_adj_values: [libc::c_int; 3],
1300 pub oom_score_adj: libc::c_int,
1301 pub disable_thp: libc::c_int,
1302 pub blocked_clients: libc::c_uint,
1303 pub blocked_clients_by_type: [libc::c_uint; 8],
1304 pub unblocked_clients: *mut list,
1305 pub ready_keys: *mut list,
1306 pub tracking_clients: libc::c_uint,
1307 pub tracking_table_max_keys: size_t,
1308 pub tracking_pending_keys: *mut list,
1309 pub sort_desc: libc::c_int,
1310 pub sort_alpha: libc::c_int,
1311 pub sort_bypattern: libc::c_int,
1312 pub sort_store: libc::c_int,
1313 pub hash_max_listpack_entries: size_t,
1314 pub hash_max_listpack_value: size_t,
1315 pub set_max_intset_entries: size_t,
1316 pub zset_max_listpack_entries: size_t,
1317 pub zset_max_listpack_value: size_t,
1318 pub hll_sparse_max_bytes: size_t,
1319 pub stream_node_max_bytes: size_t,
1320 pub stream_node_max_entries: libc::c_longlong,
1321 pub list_max_listpack_size: libc::c_int,
1322 pub list_compress_depth: libc::c_int,
1323 pub unixtime: atomic_int,
1324 pub timezone: time_t,
1325 pub daylight_active: libc::c_int,
1326 pub mstime: mstime_t,
1327 pub ustime: ustime_t,
1328 pub blocking_op_nesting: size_t,
1329 pub blocked_last_cron: libc::c_longlong,
1330 pub pubsub_channels: *mut dict,
1331 pub pubsub_patterns: *mut dict,
1332 pub notify_keyspace_events: libc::c_int,
1333 pub pubsubshard_channels: *mut dict,
1334 pub cluster_enabled: libc::c_int,
1335 pub cluster_port: libc::c_int,
1336 pub cluster_node_timeout: mstime_t,
1337 pub cluster_configfile: *mut libc::c_char,
1338 pub cluster: *mut clusterState,
1339 pub cluster_migration_barrier: libc::c_int,
1340 pub cluster_allow_replica_migration: libc::c_int,
1341 pub cluster_slave_validity_factor: libc::c_int,
1342 pub cluster_require_full_coverage: libc::c_int,
1343 pub cluster_slave_no_failover: libc::c_int,
1344 pub cluster_announce_ip: *mut libc::c_char,
1345 pub cluster_announce_hostname: *mut libc::c_char,
1346 pub cluster_preferred_endpoint_type: libc::c_int,
1347 pub cluster_announce_port: libc::c_int,
1348 pub cluster_announce_tls_port: libc::c_int,
1349 pub cluster_announce_bus_port: libc::c_int,
1350 pub cluster_module_flags: libc::c_int,
1351 pub cluster_allow_reads_when_down: libc::c_int,
1352 pub cluster_config_file_lock_fd: libc::c_int,
1353 pub cluster_link_sendbuf_limit_bytes: libc::c_ulonglong,
1354 pub cluster_drop_packet_filter: libc::c_int,
1355 pub script_caller: *mut client,
1356 pub busy_reply_threshold: mstime_t,
1357 pub pre_command_oom_state: libc::c_int,
1358 pub script_disable_deny_script: libc::c_int,
1359 pub lazyfree_lazy_eviction: libc::c_int,
1360 pub lazyfree_lazy_expire: libc::c_int,
1361 pub lazyfree_lazy_server_del: libc::c_int,
1362 pub lazyfree_lazy_user_del: libc::c_int,
1363 pub lazyfree_lazy_user_flush: libc::c_int,
1364 pub latency_monitor_threshold: libc::c_longlong,
1365 pub latency_events: *mut dict,
1366 pub acl_filename: *mut libc::c_char,
1367 pub acllog_max_len: libc::c_ulong,
1368 pub requirepass: sds,
1369 pub acl_pubsub_default: libc::c_int,
1370 pub watchdog_period: libc::c_int,
1371 pub system_memory_size: size_t,
1372 pub tls_cluster: libc::c_int,
1373 pub tls_replication: libc::c_int,
1374 pub tls_auth_clients: libc::c_int,
1375 pub tls_ctx_config: redisTLSContextConfig,
1376 pub server_cpulist: *mut libc::c_char,
1377 pub bio_cpulist: *mut libc::c_char,
1378 pub aof_rewrite_cpulist: *mut libc::c_char,
1379 pub bgsave_cpulist: *mut libc::c_char,
1380 pub sentinel_config: *mut sentinelConfig,
1381 pub failover_end_time: mstime_t,
1382 pub force_failover: libc::c_int,
1383 pub target_replica_host: *mut libc::c_char,
1384 pub target_replica_port: libc::c_int,
1385 pub failover_state: libc::c_int,
1386 pub cluster_allow_pubsubshard_when_down: libc::c_int,
1387 pub reply_buffer_peak_reset_time: libc::c_long,
1388 pub reply_buffer_resizing_enabled: libc::c_int,
1389}
1390#[derive(Copy, Clone)]
1391#[repr(C)]
1392pub struct clusterState {
1393 pub myself: *mut clusterNode,
1394 pub currentEpoch: uint64_t,
1395 pub state: libc::c_int,
1396 pub size: libc::c_int,
1397 pub nodes: *mut dict,
1398 pub nodes_black_list: *mut dict,
1399 pub migrating_slots_to: [*mut clusterNode; 16384],
1400 pub importing_slots_from: [*mut clusterNode; 16384],
1401 pub slots: [*mut clusterNode; 16384],
1402 pub slots_to_channels: *mut rax,
1403 pub failover_auth_time: mstime_t,
1404 pub failover_auth_count: libc::c_int,
1405 pub failover_auth_sent: libc::c_int,
1406 pub failover_auth_rank: libc::c_int,
1407 pub failover_auth_epoch: uint64_t,
1408 pub cant_failover_reason: libc::c_int,
1409 pub mf_end: mstime_t,
1410 pub mf_slave: *mut clusterNode,
1411 pub mf_master_offset: libc::c_longlong,
1412 pub mf_can_start: libc::c_int,
1413 pub lastVoteEpoch: uint64_t,
1414 pub todo_before_sleep: libc::c_int,
1415 pub stats_bus_messages_sent: [libc::c_longlong; 11],
1416 pub stats_bus_messages_received: [libc::c_longlong; 11],
1417 pub stats_pfail_nodes: libc::c_longlong,
1418 pub stat_cluster_links_buffer_limit_exceeded: libc::c_ulonglong,
1419}
1420#[derive(Copy, Clone)]
1421#[repr(C)]
1422pub struct clusterNode {
1423 pub ctime: mstime_t,
1424 pub name: [libc::c_char; 40],
1425 pub flags: libc::c_int,
1426 pub configEpoch: uint64_t,
1427 pub slots: [libc::c_uchar; 2048],
1428 pub slot_info_pairs: *mut uint16_t,
1429 pub slot_info_pairs_count: libc::c_int,
1430 pub numslots: libc::c_int,
1431 pub numslaves: libc::c_int,
1432 pub slaves: *mut *mut clusterNode,
1433 pub slaveof: *mut clusterNode,
1434 pub last_in_ping_gossip: libc::c_ulonglong,
1435 pub ping_sent: mstime_t,
1436 pub pong_received: mstime_t,
1437 pub data_received: mstime_t,
1438 pub fail_time: mstime_t,
1439 pub voted_time: mstime_t,
1440 pub repl_offset_time: mstime_t,
1441 pub orphaned_time: mstime_t,
1442 pub repl_offset: libc::c_longlong,
1443 pub ip: [libc::c_char; 46],
1444 pub hostname: sds,
1445 pub port: libc::c_int,
1446 pub pport: libc::c_int,
1447 pub cport: libc::c_int,
1448 pub link: *mut clusterLink,
1449 pub inbound_link: *mut clusterLink,
1450 pub fail_reports: *mut list,
1451}
1452#[derive(Copy, Clone)]
1453#[repr(C)]
1454pub struct clusterLink {
1455 pub ctime: mstime_t,
1456 pub conn: *mut connection,
1457 pub sndbuf: sds,
1458 pub rcvbuf: *mut libc::c_char,
1459 pub rcvbuf_len: size_t,
1460 pub rcvbuf_alloc: size_t,
1461 pub node: *mut clusterNode,
1462 pub inbound: libc::c_int,
1463}
1464#[derive(Copy, Clone)]
1465#[repr(C)]
1466pub struct C2RustUnnamed_7 {
1467 pub last_sample_time: libc::c_longlong,
1468 pub last_sample_count: libc::c_longlong,
1469 pub samples: [libc::c_longlong; 16],
1470 pub idx: libc::c_int,
1471}
1472#[derive(Copy, Clone)]
1473#[repr(C)]
1474pub struct scriptRunCtx {
1475 pub funcname: *const libc::c_char,
1476 pub c: *mut client,
1477 pub original_client: *mut client,
1478 pub flags: libc::c_int,
1479 pub repl_flags: libc::c_int,
1480 pub start_time: monotime,
1481 pub snapshot_time: mstime_t,
1482}
1483#[derive(Copy, Clone)]
1484#[repr(C)]
1485pub struct scriptFlag {
1486 pub flag: uint64_t,
1487 pub str_0: *const libc::c_char,
1488}
1489#[inline]
1490unsafe extern "C" fn sdslen(s: sds) -> size_t {
1491 let mut flags: libc::c_uchar = *s.offset(-(1 as libc::c_int) as isize)
1492 as libc::c_uchar;
1493 match flags as libc::c_int & 7 as libc::c_int {
1494 0 => return (flags as libc::c_int >> 3 as libc::c_int) as size_t,
1495 1 => {
1496 return (*(s
1497 .offset(-(core::mem::size_of::<sdshdr8>() as libc::c_ulong as isize))
1498 as *mut sdshdr8))
1499 .len as size_t;
1500 }
1501 2 => {
1502 return (*(s
1503 .offset(-(core::mem::size_of::<sdshdr16>() as libc::c_ulong as isize))
1504 as *mut sdshdr16))
1505 .len as size_t;
1506 }
1507 3 => {
1508 return (*(s
1509 .offset(-(core::mem::size_of::<sdshdr32>() as libc::c_ulong as isize))
1510 as *mut sdshdr32))
1511 .len as size_t;
1512 }
1513 4 => {
1514 return (*(s
1515 .offset(-(core::mem::size_of::<sdshdr64>() as libc::c_ulong as isize))
1516 as *mut sdshdr64))
1517 .len;
1518 }
1519 _ => {}
1520 }
1521 return 0 as libc::c_int as size_t;
1522}
1523#[inline]
1524unsafe extern "C" fn elapsedUs(mut start_time: monotime) -> uint64_t {
1525 return (getMonotonicUs.expect("non-null function pointer")())
1526 .wrapping_sub(start_time);
1527}
1528#[inline]
1529unsafe extern "C" fn elapsedMs(mut start_time: monotime) -> uint64_t {
1530 return (elapsedUs(start_time)).wrapping_div(1000 as libc::c_int as libc::c_ulong);
1531}
1532#[no_mangle]
1533pub static mut scripts_flags_def: [scriptFlag; 6] = [
1534 {
1535 let mut init = scriptFlag {
1536 flag: ((1 as libc::c_ulonglong) << 0 as libc::c_int) as uint64_t,
1537 str_0: b"no-writes\0" as *const u8 as *const libc::c_char,
1538 };
1539 init
1540 },
1541 {
1542 let mut init = scriptFlag {
1543 flag: ((1 as libc::c_ulonglong) << 1 as libc::c_int) as uint64_t,
1544 str_0: b"allow-oom\0" as *const u8 as *const libc::c_char,
1545 };
1546 init
1547 },
1548 {
1549 let mut init = scriptFlag {
1550 flag: ((1 as libc::c_ulonglong) << 2 as libc::c_int) as uint64_t,
1551 str_0: b"allow-stale\0" as *const u8 as *const libc::c_char,
1552 };
1553 init
1554 },
1555 {
1556 let mut init = scriptFlag {
1557 flag: ((1 as libc::c_ulonglong) << 3 as libc::c_int) as uint64_t,
1558 str_0: b"no-cluster\0" as *const u8 as *const libc::c_char,
1559 };
1560 init
1561 },
1562 {
1563 let mut init = scriptFlag {
1564 flag: ((1 as libc::c_ulonglong) << 5 as libc::c_int) as uint64_t,
1565 str_0: b"allow-cross-slot-keys\0" as *const u8 as *const libc::c_char,
1566 };
1567 init
1568 },
1569 {
1570 let mut init = scriptFlag {
1571 flag: 0 as libc::c_int as uint64_t,
1572 str_0: 0 as *const libc::c_char,
1573 };
1574 init
1575 },
1576];
1577static mut curr_run_ctx: *mut scriptRunCtx = 0 as *const scriptRunCtx
1578 as *mut scriptRunCtx;
1579unsafe extern "C" fn exitScriptTimedoutMode(mut run_ctx: *mut scriptRunCtx) {
1580 if run_ctx == curr_run_ctx {} else {
1581 _serverAssert(
1582 b"run_ctx == curr_run_ctx\0" as *const u8 as *const libc::c_char,
1583 b"script.c\0" as *const u8 as *const libc::c_char,
1584 47 as libc::c_int,
1585 );
1586 unreachable!();
1587 };
1588 if scriptIsTimedout() != 0 {} else {
1589 _serverAssert(
1590 b"scriptIsTimedout()\0" as *const u8 as *const libc::c_char,
1591 b"script.c\0" as *const u8 as *const libc::c_char,
1592 48 as libc::c_int,
1593 );
1594 unreachable!();
1595 };
1596 (*run_ctx)
1597 .flags = ((*run_ctx).flags as libc::c_ulonglong
1598 & !((1 as libc::c_ulonglong) << 3 as libc::c_int)) as libc::c_int;
1599 blockingOperationEnds();
1600 if !(server.masterhost).is_null() && !(server.master).is_null() {
1601 queueClientForReprocessing(server.master);
1602 }
1603}
1604unsafe extern "C" fn enterScriptTimedoutMode(mut run_ctx: *mut scriptRunCtx) {
1605 if run_ctx == curr_run_ctx {} else {
1606 _serverAssert(
1607 b"run_ctx == curr_run_ctx\0" as *const u8 as *const libc::c_char,
1608 b"script.c\0" as *const u8 as *const libc::c_char,
1609 56 as libc::c_int,
1610 );
1611 unreachable!();
1612 };
1613 if scriptIsTimedout() == 0 {} else {
1614 _serverAssert(
1615 b"!scriptIsTimedout()\0" as *const u8 as *const libc::c_char,
1616 b"script.c\0" as *const u8 as *const libc::c_char,
1617 57 as libc::c_int,
1618 );
1619 unreachable!();
1620 };
1621 (*run_ctx)
1622 .flags = ((*run_ctx).flags as libc::c_ulonglong
1623 | (1 as libc::c_ulonglong) << 3 as libc::c_int) as libc::c_int;
1624 blockingOperationStarts();
1625}
1626#[no_mangle]
1627pub unsafe extern "C" fn scriptIsTimedout() -> libc::c_int {
1628 return (scriptIsRunning() != 0
1629 && (*curr_run_ctx).flags as libc::c_ulonglong
1630 & (1 as libc::c_ulonglong) << 3 as libc::c_int != 0) as libc::c_int;
1631}
1632#[no_mangle]
1633pub unsafe extern "C" fn scriptGetClient() -> *mut client {
1634 if scriptIsRunning() != 0 {} else {
1635 _serverAssert(
1636 b"scriptIsRunning()\0" as *const u8 as *const libc::c_char,
1637 b"script.c\0" as *const u8 as *const libc::c_char,
1638 68 as libc::c_int,
1639 );
1640 unreachable!();
1641 };
1642 return (*curr_run_ctx).c;
1643}
1644#[no_mangle]
1645pub unsafe extern "C" fn scriptGetCaller() -> *mut client {
1646 if scriptIsRunning() != 0 {} else {
1647 _serverAssert(
1648 b"scriptIsRunning()\0" as *const u8 as *const libc::c_char,
1649 b"script.c\0" as *const u8 as *const libc::c_char,
1650 73 as libc::c_int,
1651 );
1652 unreachable!();
1653 };
1654 return (*curr_run_ctx).original_client;
1655}
1656#[no_mangle]
1657pub unsafe extern "C" fn scriptInterrupt(mut run_ctx: *mut scriptRunCtx) -> libc::c_int {
1658 if (*run_ctx).flags as libc::c_ulonglong
1659 & (1 as libc::c_ulonglong) << 3 as libc::c_int != 0
1660 {
1661 processEventsWhileBlocked();
1662 return if (*run_ctx).flags as libc::c_ulonglong
1663 & (1 as libc::c_ulonglong) << 4 as libc::c_int != 0
1664 {
1665 1 as libc::c_int
1666 } else {
1667 2 as libc::c_int
1668 };
1669 }
1670 let mut elapsed: libc::c_longlong = elapsedMs((*run_ctx).start_time)
1671 as libc::c_longlong;
1672 if elapsed < server.busy_reply_threshold {
1673 return 2 as libc::c_int;
1674 }
1675 if !((3 as libc::c_int & 0xff as libc::c_int) < server.verbosity) {
1676 _serverLog(
1677 3 as libc::c_int,
1678 b"Slow script detected: still in execution after %lld milliseconds. You can try killing the script using the %s command. Script name is: %s.\0"
1679 as *const u8 as *const libc::c_char,
1680 elapsed,
1681 if (*run_ctx).flags as libc::c_ulonglong
1682 & (1 as libc::c_ulonglong) << 7 as libc::c_int != 0
1683 {
1684 b"SCRIPT KILL\0" as *const u8 as *const libc::c_char
1685 } else {
1686 b"FUNCTION KILL\0" as *const u8 as *const libc::c_char
1687 },
1688 (*run_ctx).funcname,
1689 );
1690 }
1691 enterScriptTimedoutMode(run_ctx);
1692 protectClient((*run_ctx).original_client);
1693 processEventsWhileBlocked();
1694 return if (*run_ctx).flags as libc::c_ulonglong
1695 & (1 as libc::c_ulonglong) << 4 as libc::c_int != 0
1696 {
1697 1 as libc::c_int
1698 } else {
1699 2 as libc::c_int
1700 };
1701}
1702#[no_mangle]
1703pub unsafe extern "C" fn scriptFlagsToCmdFlags(
1704 mut cmd_flags: uint64_t,
1705 mut script_flags: uint64_t,
1706) -> uint64_t {
1707 cmd_flags = (cmd_flags as libc::c_ulonglong
1708 & !((1 as libc::c_ulonglong) << 10 as libc::c_int
1709 | (1 as libc::c_ulonglong) << 2 as libc::c_int
1710 | (1 as libc::c_ulonglong) << 0 as libc::c_int)) as uint64_t;
1711 if script_flags as libc::c_ulonglong
1712 & ((1 as libc::c_ulonglong) << 1 as libc::c_int
1713 | (1 as libc::c_ulonglong) << 0 as libc::c_int) == 0
1714 {
1715 cmd_flags = (cmd_flags as libc::c_ulonglong
1716 | (1 as libc::c_ulonglong) << 2 as libc::c_int) as uint64_t;
1717 }
1718 if script_flags as libc::c_ulonglong & (1 as libc::c_ulonglong) << 0 as libc::c_int
1719 == 0
1720 {
1721 cmd_flags = (cmd_flags as libc::c_ulonglong
1722 | (1 as libc::c_ulonglong) << 0 as libc::c_int) as uint64_t;
1723 }
1724 if script_flags as libc::c_ulonglong & (1 as libc::c_ulonglong) << 2 as libc::c_int
1725 != 0
1726 {
1727 cmd_flags = (cmd_flags as libc::c_ulonglong
1728 | (1 as libc::c_ulonglong) << 10 as libc::c_int) as uint64_t;
1729 }
1730 cmd_flags = (cmd_flags as libc::c_ulonglong
1731 & !((1 as libc::c_ulonglong) << 16 as libc::c_int)) as uint64_t;
1732 return cmd_flags;
1733}
1734#[no_mangle]
1735pub unsafe extern "C" fn scriptPrepareForRun(
1736 mut run_ctx: *mut scriptRunCtx,
1737 mut engine_client: *mut client,
1738 mut caller: *mut client,
1739 mut funcname: *const libc::c_char,
1740 mut script_flags: uint64_t,
1741 mut ro: libc::c_int,
1742) -> libc::c_int {
1743 if curr_run_ctx.is_null() {} else {
1744 _serverAssert(
1745 b"!curr_run_ctx\0" as *const u8 as *const libc::c_char,
1746 b"script.c\0" as *const u8 as *const libc::c_char,
1747 132 as libc::c_int,
1748 );
1749 unreachable!();
1750 };
1751 let mut running_stale: libc::c_int = (!(server.masterhost).is_null()
1752 && server.repl_state != REPL_STATE_CONNECTED as libc::c_int
1753 && server.repl_serve_stale_data == 0 as libc::c_int) as libc::c_int;
1754 let mut obey_client: libc::c_int = mustObeyClient(caller);
1755 if script_flags as libc::c_ulonglong & (1 as libc::c_ulonglong) << 4 as libc::c_int
1756 == 0
1757 {
1758 if script_flags as libc::c_ulonglong
1759 & (1 as libc::c_ulonglong) << 3 as libc::c_int != 0
1760 && server.cluster_enabled != 0
1761 {
1762 addReplyError(
1763 caller,
1764 b"Can not run script on cluster, 'no-cluster' flag is set.\0"
1765 as *const u8 as *const libc::c_char,
1766 );
1767 return -(1 as libc::c_int);
1768 }
1769 if running_stale != 0
1770 && script_flags as libc::c_ulonglong
1771 & (1 as libc::c_ulonglong) << 2 as libc::c_int == 0
1772 {
1773 addReplyError(
1774 caller,
1775 b"-MASTERDOWN Link with MASTER is down, replica-serve-stale-data is set to 'no' and 'allow-stale' flag is not set on the script.\0"
1776 as *const u8 as *const libc::c_char,
1777 );
1778 return -(1 as libc::c_int);
1779 }
1780 if script_flags as libc::c_ulonglong
1781 & (1 as libc::c_ulonglong) << 0 as libc::c_int == 0
1782 {
1783 if !(server.masterhost).is_null() && server.repl_slave_ro != 0
1784 && obey_client == 0
1785 {
1786 addReplyError(
1787 caller,
1788 b"-READONLY Can not run script with write flag on readonly replica\0"
1789 as *const u8 as *const libc::c_char,
1790 );
1791 return -(1 as libc::c_int);
1792 }
1793 let mut deny_write_type: libc::c_int = writeCommandsDeniedByDiskError();
1794 if deny_write_type != 0 as libc::c_int && obey_client == 0 {
1795 if deny_write_type == 2 as libc::c_int {
1796 addReplyError(
1797 caller,
1798 b"-MISCONF Redis is configured to save RDB snapshots, but it's currently unable to persist to disk. Writable scripts are blocked. Use 'no-writes' flag for read only scripts.\0"
1799 as *const u8 as *const libc::c_char,
1800 );
1801 } else {
1802 addReplyErrorFormat(
1803 caller,
1804 b"-MISCONF Redis is configured to persist data to AOF, but it's currently unable to persist to disk. Writable scripts are blocked. Use 'no-writes' flag for read only scripts. AOF error: %s\0"
1805 as *const u8 as *const libc::c_char,
1806 strerror(server.aof_last_write_errno),
1807 );
1808 }
1809 return -(1 as libc::c_int);
1810 }
1811 if ro != 0 {
1812 addReplyError(
1813 caller,
1814 b"Can not execute a script with write flag using *_ro command.\0"
1815 as *const u8 as *const libc::c_char,
1816 );
1817 return -(1 as libc::c_int);
1818 }
1819 if (server.masterhost).is_null() && server.repl_min_slaves_max_lag != 0
1820 && server.repl_min_slaves_to_write != 0
1821 && server.repl_good_slaves_count < server.repl_min_slaves_to_write
1822 {
1823 addReplyErrorObject(caller, shared.noreplicaserr);
1824 return -(1 as libc::c_int);
1825 }
1826 }
1827 if server.pre_command_oom_state != 0 && server.maxmemory != 0
1828 && script_flags as libc::c_ulonglong
1829 & ((1 as libc::c_ulonglong) << 1 as libc::c_int
1830 | (1 as libc::c_ulonglong) << 0 as libc::c_int) == 0
1831 {
1832 addReplyError(
1833 caller,
1834 b"-OOM allow-oom flag is not set on the script, can not run it when used memory > 'maxmemory'\0"
1835 as *const u8 as *const libc::c_char,
1836 );
1837 return -(1 as libc::c_int);
1838 }
1839 } else if running_stale != 0 {
1840 addReplyErrorObject(caller, shared.masterdownerr);
1841 return -(1 as libc::c_int);
1842 }
1843 (*run_ctx).c = engine_client;
1844 (*run_ctx).original_client = caller;
1845 (*run_ctx).funcname = funcname;
1846 let mut script_client: *mut client = (*run_ctx).c;
1847 let mut curr_client: *mut client = (*run_ctx).original_client;
1848 server.script_caller = curr_client;
1849 selectDb(script_client, (*(*curr_client).db).id);
1850 (*script_client).resp = 2 as libc::c_int;
1851 if (*curr_client).flags & ((1 as libc::c_int) << 3 as libc::c_int) as libc::c_ulong
1852 != 0
1853 {
1854 (*script_client).flags
1855 |= ((1 as libc::c_int) << 3 as libc::c_int) as libc::c_ulong;
1856 }
1857 (*run_ctx).start_time = getMonotonicUs.expect("non-null function pointer")();
1858 (*run_ctx).snapshot_time = mstime();
1859 (*run_ctx).flags = 0 as libc::c_int;
1860 (*run_ctx).repl_flags = 1 as libc::c_int | 2 as libc::c_int;
1861 if ro != 0
1862 || script_flags as libc::c_ulonglong
1863 & (1 as libc::c_ulonglong) << 4 as libc::c_int == 0
1864 && script_flags as libc::c_ulonglong
1865 & (1 as libc::c_ulonglong) << 0 as libc::c_int != 0
1866 {
1867 (*run_ctx)
1868 .flags = ((*run_ctx).flags as libc::c_ulonglong
1869 | (1 as libc::c_ulonglong) << 5 as libc::c_int) as libc::c_int;
1870 }
1871 if script_flags as libc::c_ulonglong & (1 as libc::c_ulonglong) << 4 as libc::c_int
1872 == 0
1873 && script_flags as libc::c_ulonglong
1874 & (1 as libc::c_ulonglong) << 1 as libc::c_int != 0
1875 {
1876 (*run_ctx)
1877 .flags = ((*run_ctx).flags as libc::c_ulonglong
1878 | (1 as libc::c_ulonglong) << 6 as libc::c_int) as libc::c_int;
1879 }
1880 if script_flags as libc::c_ulonglong & (1 as libc::c_ulonglong) << 4 as libc::c_int
1881 != 0
1882 || script_flags as libc::c_ulonglong
1883 & (1 as libc::c_ulonglong) << 5 as libc::c_int != 0
1884 {
1885 (*run_ctx)
1886 .flags = ((*run_ctx).flags as libc::c_ulonglong
1887 | (1 as libc::c_ulonglong) << 8 as libc::c_int) as libc::c_int;
1888 }
1889 curr_run_ctx = run_ctx;
1890 return 0 as libc::c_int;
1891}
1892#[no_mangle]
1893pub unsafe extern "C" fn scriptResetRun(mut run_ctx: *mut scriptRunCtx) {
1894 if !curr_run_ctx.is_null() {} else {
1895 _serverAssert(
1896 b"curr_run_ctx\0" as *const u8 as *const libc::c_char,
1897 b"script.c\0" as *const u8 as *const libc::c_char,
1898 258 as libc::c_int,
1899 );
1900 unreachable!();
1901 };
1902 (*(*run_ctx).c).flags &= !((1 as libc::c_int) << 3 as libc::c_int) as libc::c_ulong;
1903 server.script_caller = 0 as *mut client;
1904 if scriptIsTimedout() != 0 {
1905 exitScriptTimedoutMode(run_ctx);
1906 unprotectClient((*run_ctx).original_client);
1907 }
1908 preventCommandPropagation((*run_ctx).original_client);
1909 curr_run_ctx = 0 as *mut scriptRunCtx;
1910}
1911#[no_mangle]
1912pub unsafe extern "C" fn scriptIsRunning() -> libc::c_int {
1913 return (curr_run_ctx != 0 as *mut libc::c_void as *mut scriptRunCtx) as libc::c_int;
1914}
1915#[no_mangle]
1916pub unsafe extern "C" fn scriptCurrFunction() -> *const libc::c_char {
1917 if scriptIsRunning() != 0 {} else {
1918 _serverAssert(
1919 b"scriptIsRunning()\0" as *const u8 as *const libc::c_char,
1920 b"script.c\0" as *const u8 as *const libc::c_char,
1921 284 as libc::c_int,
1922 );
1923 unreachable!();
1924 };
1925 return (*curr_run_ctx).funcname;
1926}
1927#[no_mangle]
1928pub unsafe extern "C" fn scriptIsEval() -> libc::c_int {
1929 if scriptIsRunning() != 0 {} else {
1930 _serverAssert(
1931 b"scriptIsRunning()\0" as *const u8 as *const libc::c_char,
1932 b"script.c\0" as *const u8 as *const libc::c_char,
1933 289 as libc::c_int,
1934 );
1935 unreachable!();
1936 };
1937 return ((*curr_run_ctx).flags as libc::c_ulonglong
1938 & (1 as libc::c_ulonglong) << 7 as libc::c_int) as libc::c_int;
1939}
1940#[no_mangle]
1941pub unsafe extern "C" fn scriptKill(mut c: *mut client, mut is_eval: libc::c_int) {
1942 if curr_run_ctx.is_null() {
1943 addReplyError(
1944 c,
1945 b"-NOTBUSY No scripts in execution right now.\0" as *const u8
1946 as *const libc::c_char,
1947 );
1948 return;
1949 }
1950 if mustObeyClient((*curr_run_ctx).original_client) != 0 {
1951 addReplyError(
1952 c,
1953 b"-UNKILLABLE The busy script was sent by a master instance in the context of replication and cannot be killed.\0"
1954 as *const u8 as *const libc::c_char,
1955 );
1956 }
1957 if (*curr_run_ctx).flags as libc::c_ulonglong
1958 & (1 as libc::c_ulonglong) << 0 as libc::c_int != 0
1959 {
1960 addReplyError(
1961 c,
1962 b"-UNKILLABLE Sorry the script already executed write commands against the dataset. You can either wait the script termination or kill the server in a hard way using the SHUTDOWN NOSAVE command.\0"
1963 as *const u8 as *const libc::c_char,
1964 );
1965 return;
1966 }
1967 if is_eval != 0
1968 && (*curr_run_ctx).flags as libc::c_ulonglong
1969 & (1 as libc::c_ulonglong) << 7 as libc::c_int == 0
1970 {
1971 addReplyErrorObject(c, shared.slowscripterr);
1972 return;
1973 }
1974 if is_eval == 0
1975 && (*curr_run_ctx).flags as libc::c_ulonglong
1976 & (1 as libc::c_ulonglong) << 7 as libc::c_int != 0
1977 {
1978 addReplyErrorObject(c, shared.slowevalerr);
1979 return;
1980 }
1981 (*curr_run_ctx)
1982 .flags = ((*curr_run_ctx).flags as libc::c_ulonglong
1983 | (1 as libc::c_ulonglong) << 4 as libc::c_int) as libc::c_int;
1984 addReply(c, shared.ok);
1985}
1986unsafe extern "C" fn scriptVerifyCommandArity(
1987 mut cmd: *mut redisCommand,
1988 mut argc: libc::c_int,
1989 mut err: *mut sds,
1990) -> libc::c_int {
1991 if cmd.is_null()
1992 || ((*cmd).arity > 0 as libc::c_int && (*cmd).arity != argc
1993 || argc < -(*cmd).arity)
1994 {
1995 if !cmd.is_null() {
1996 *err = sdsnew(
1997 b"Wrong number of args calling Redis command from script\0" as *const u8
1998 as *const libc::c_char,
1999 );
2000 } else {
2001 *err = sdsnew(
2002 b"Unknown Redis command called from script\0" as *const u8
2003 as *const libc::c_char,
2004 );
2005 }
2006 return -(1 as libc::c_int);
2007 }
2008 return 0 as libc::c_int;
2009}
2010unsafe extern "C" fn scriptVerifyACL(
2011 mut c: *mut client,
2012 mut err: *mut sds,
2013) -> libc::c_int {
2014 let mut acl_errpos: libc::c_int = 0;
2015 let mut acl_retval: libc::c_int = ACLCheckAllPerm(c, &mut acl_errpos);
2016 if acl_retval != 0 as libc::c_int {
2017 addACLLogEntry(c, acl_retval, 1 as libc::c_int, acl_errpos, 0 as sds, 0 as sds);
2018 *err = sdscatfmt(
2019 sdsempty(),
2020 b"The user executing the script %s\0" as *const u8 as *const libc::c_char,
2021 getAclErrorMessage(acl_retval),
2022 );
2023 return -(1 as libc::c_int);
2024 }
2025 return 0 as libc::c_int;
2026}
2027unsafe extern "C" fn scriptVerifyWriteCommandAllow(
2028 mut run_ctx: *mut scriptRunCtx,
2029 mut err: *mut *mut libc::c_char,
2030) -> libc::c_int {
2031 if (*run_ctx).flags as libc::c_ulonglong
2032 & (1 as libc::c_ulonglong) << 5 as libc::c_int != 0
2033 && (*(*(*run_ctx).c).cmd).flags as libc::c_ulonglong
2034 & ((1 as libc::c_ulonglong) << 0 as libc::c_int
2035 | (1 as libc::c_ulonglong) << 16 as libc::c_int) != 0
2036 {
2037 *err = sdsnew(
2038 b"Write commands are not allowed from read-only scripts.\0" as *const u8
2039 as *const libc::c_char,
2040 );
2041 return -(1 as libc::c_int);
2042 }
2043 if (*(*(*run_ctx).c).cmd).flags as libc::c_ulonglong
2044 & (1 as libc::c_ulonglong) << 0 as libc::c_int == 0
2045 {
2046 return 0 as libc::c_int;
2047 }
2048 if (*run_ctx).flags as libc::c_ulonglong
2049 & (1 as libc::c_ulonglong) << 0 as libc::c_int != 0
2050 {
2051 return 0 as libc::c_int;
2052 }
2053 let mut deny_write_type: libc::c_int = writeCommandsDeniedByDiskError();
2054 if !(server.masterhost).is_null() && server.repl_slave_ro != 0
2055 && mustObeyClient((*run_ctx).original_client) == 0
2056 {
2057 *err = sdsdup((*shared.roslaveerr).ptr as sds);
2058 return -(1 as libc::c_int);
2059 }
2060 if deny_write_type != 0 as libc::c_int {
2061 *err = writeCommandsGetDiskErrorMessage(deny_write_type);
2062 return -(1 as libc::c_int);
2063 }
2064 if checkGoodReplicasStatus() == 0 {
2065 *err = sdsdup((*shared.noreplicaserr).ptr as sds);
2066 return -(1 as libc::c_int);
2067 }
2068 return 0 as libc::c_int;
2069}
2070unsafe extern "C" fn scriptVerifyOOM(
2071 mut run_ctx: *mut scriptRunCtx,
2072 mut err: *mut *mut libc::c_char,
2073) -> libc::c_int {
2074 if (*run_ctx).flags as libc::c_ulonglong
2075 & (1 as libc::c_ulonglong) << 6 as libc::c_int != 0
2076 {
2077 return 0 as libc::c_int;
2078 }
2079 if server.maxmemory != 0 && mustObeyClient((*run_ctx).original_client) == 0
2080 && (*run_ctx).flags as libc::c_ulonglong
2081 & (1 as libc::c_ulonglong) << 0 as libc::c_int == 0
2082 && server.pre_command_oom_state != 0
2083 && (*(*(*run_ctx).c).cmd).flags as libc::c_ulonglong
2084 & (1 as libc::c_ulonglong) << 2 as libc::c_int != 0
2085 {
2086 *err = sdsdup((*shared.oomerr).ptr as sds);
2087 return -(1 as libc::c_int);
2088 }
2089 return 0 as libc::c_int;
2090}
2091unsafe extern "C" fn scriptVerifyClusterState(
2092 mut run_ctx: *mut scriptRunCtx,
2093 mut c: *mut client,
2094 mut original_c: *mut client,
2095 mut err: *mut sds,
2096) -> libc::c_int {
2097 if server.cluster_enabled == 0 || mustObeyClient(original_c) != 0 {
2098 return 0 as libc::c_int;
2099 }
2100 let mut error_code: libc::c_int = 0;
2101 (*c).flags
2102 &= !((1 as libc::c_int) << 17 as libc::c_int
2103 | (1 as libc::c_int) << 9 as libc::c_int) as libc::c_ulong;
2104 (*c).flags
2105 |= (*original_c).flags
2106 & ((1 as libc::c_int) << 17 as libc::c_int
2107 | (1 as libc::c_int) << 9 as libc::c_int) as libc::c_ulong;
2108 let mut hashslot: libc::c_int = -(1 as libc::c_int);
2109 if getNodeByQuery(c, (*c).cmd, (*c).argv, (*c).argc, &mut hashslot, &mut error_code)
2110 != (*server.cluster).myself
2111 {
2112 if error_code == 7 as libc::c_int {
2113 *err = sdsnew(
2114 b"Script attempted to execute a write command while the cluster is down and readonly\0"
2115 as *const u8 as *const libc::c_char,
2116 );
2117 } else if error_code == 5 as libc::c_int {
2118 *err = sdsnew(
2119 b"Script attempted to execute a command while the cluster is down\0"
2120 as *const u8 as *const libc::c_char,
2121 );
2122 } else {
2123 *err = sdsnew(
2124 b"Script attempted to access a non local key in a cluster node\0"
2125 as *const u8 as *const libc::c_char,
2126 );
2127 }
2128 return -(1 as libc::c_int);
2129 }
2130 if hashslot != -(1 as libc::c_int)
2131 && (*run_ctx).flags as libc::c_ulonglong
2132 & (1 as libc::c_ulonglong) << 8 as libc::c_int == 0
2133 {
2134 if (*original_c).slot == -(1 as libc::c_int) {
2135 (*original_c).slot = hashslot;
2136 } else if (*original_c).slot != hashslot {
2137 *err = sdsnew(
2138 b"Script attempted to access keys that do not hash to the same slot\0"
2139 as *const u8 as *const libc::c_char,
2140 );
2141 return -(1 as libc::c_int);
2142 }
2143 }
2144 return 0 as libc::c_int;
2145}
2146#[no_mangle]
2147pub unsafe extern "C" fn scriptSetResp(
2148 mut run_ctx: *mut scriptRunCtx,
2149 mut resp: libc::c_int,
2150) -> libc::c_int {
2151 if resp != 2 as libc::c_int && resp != 3 as libc::c_int {
2152 return -(1 as libc::c_int);
2153 }
2154 (*(*run_ctx).c).resp = resp;
2155 return 0 as libc::c_int;
2156}
2157#[no_mangle]
2158pub unsafe extern "C" fn scriptSetRepl(
2159 mut run_ctx: *mut scriptRunCtx,
2160 mut repl: libc::c_int,
2161) -> libc::c_int {
2162 if repl & !(1 as libc::c_int | 2 as libc::c_int) != 0 as libc::c_int {
2163 return -(1 as libc::c_int);
2164 }
2165 (*run_ctx).repl_flags = repl;
2166 return 0 as libc::c_int;
2167}
2168unsafe extern "C" fn scriptVerifyAllowStale(
2169 mut c: *mut client,
2170 mut err: *mut sds,
2171) -> libc::c_int {
2172 if (server.masterhost).is_null() {
2173 return 0 as libc::c_int;
2174 }
2175 if server.repl_state == REPL_STATE_CONNECTED as libc::c_int {
2176 return 0 as libc::c_int;
2177 }
2178 if server.repl_serve_stale_data == 1 as libc::c_int {
2179 return 0 as libc::c_int;
2180 }
2181 if (*(*c).cmd).flags as libc::c_ulonglong
2182 & (1 as libc::c_ulonglong) << 10 as libc::c_int != 0
2183 {
2184 return 0 as libc::c_int;
2185 }
2186 *err = sdsnew(
2187 b"Can not execute the command on a stale replica\0" as *const u8
2188 as *const libc::c_char,
2189 );
2190 return -(1 as libc::c_int);
2191}
2192#[no_mangle]
2193pub unsafe extern "C" fn scriptCall(mut run_ctx: *mut scriptRunCtx, mut err: *mut sds) {
2194 let mut call_flags: libc::c_int = 0;
2195 let mut c: *mut client = (*run_ctx).c;
2196 (*c).user = (*(*run_ctx).original_client).user;
2197 moduleCallCommandFilters(c);
2198 let mut cmd: *mut redisCommand = lookupCommand((*c).argv, (*c).argc);
2199 (*c).realcmd = cmd;
2200 (*c).lastcmd = (*c).realcmd;
2201 (*c).cmd = (*c).lastcmd;
2202 if !(scriptVerifyCommandArity(cmd, (*c).argc, err) != 0 as libc::c_int) {
2203 if server.script_disable_deny_script == 0
2204 && (*cmd).flags as libc::c_ulonglong
2205 & (1 as libc::c_ulonglong) << 6 as libc::c_int != 0
2206 {
2207 *err = sdsnew(
2208 b"This Redis command is not allowed from script\0" as *const u8
2209 as *const libc::c_char,
2210 );
2211 } else if !(scriptVerifyAllowStale(c, err) != 0 as libc::c_int) {
2212 if !(scriptVerifyACL(c, err) != 0 as libc::c_int) {
2213 if !(scriptVerifyWriteCommandAllow(run_ctx, err) != 0 as libc::c_int) {
2214 if !(scriptVerifyOOM(run_ctx, err) != 0 as libc::c_int) {
2215 if (*cmd).flags as libc::c_ulonglong
2216 & (1 as libc::c_ulonglong) << 0 as libc::c_int != 0
2217 {
2218 (*run_ctx)
2219 .flags = ((*run_ctx).flags as libc::c_ulonglong
2220 | (1 as libc::c_ulonglong) << 0 as libc::c_int)
2221 as libc::c_int;
2222 }
2223 if !(scriptVerifyClusterState(
2224 run_ctx,
2225 c,
2226 (*run_ctx).original_client,
2227 err,
2228 ) != 0 as libc::c_int)
2229 {
2230 call_flags = (1 as libc::c_int) << 0 as libc::c_int
2231 | (1 as libc::c_int) << 1 as libc::c_int;
2232 if (*run_ctx).repl_flags & 1 as libc::c_int != 0 {
2233 call_flags |= (1 as libc::c_int) << 2 as libc::c_int;
2234 }
2235 if (*run_ctx).repl_flags & 2 as libc::c_int != 0 {
2236 call_flags |= (1 as libc::c_int) << 3 as libc::c_int;
2237 }
2238 call(c, call_flags);
2239 if (*c).flags
2240 & ((1 as libc::c_int) << 4 as libc::c_int) as libc::c_ulong
2241 == 0 as libc::c_int as libc::c_ulong
2242 {} else {
2243 _serverAssert(
2244 b"(c->flags & CLIENT_BLOCKED) == 0\0" as *const u8
2245 as *const libc::c_char,
2246 b"script.c\0" as *const u8 as *const libc::c_char,
2247 571 as libc::c_int,
2248 );
2249 unreachable!();
2250 };
2251 return;
2252 }
2253 }
2254 }
2255 }
2256 }
2257 }
2258 afterErrorReply(c, *err as *const libc::c_char, sdslen(*err), 0 as libc::c_int);
2259 incrCommandStatsOnError(cmd, (1 as libc::c_int) << 0 as libc::c_int);
2260}
2261#[no_mangle]
2262pub unsafe extern "C" fn scriptTimeSnapshot() -> mstime_t {
2263 if !curr_run_ctx.is_null() {} else {
2264 _serverAssert(
2265 b"curr_run_ctx\0" as *const u8 as *const libc::c_char,
2266 b"script.c\0" as *const u8 as *const libc::c_char,
2267 581 as libc::c_int,
2268 );
2269 unreachable!();
2270 };
2271 return (*curr_run_ctx).snapshot_time;
2272}
2273#[no_mangle]
2274pub unsafe extern "C" fn scriptRunDuration() -> libc::c_longlong {
2275 if scriptIsRunning() != 0 {} else {
2276 _serverAssert(
2277 b"scriptIsRunning()\0" as *const u8 as *const libc::c_char,
2278 b"script.c\0" as *const u8 as *const libc::c_char,
2279 586 as libc::c_int,
2280 );
2281 unreachable!();
2282 };
2283 return elapsedMs((*curr_run_ctx).start_time) as libc::c_longlong;
2284}