"Invalid delay_until randomness number '%s'", p);
request->failed = TRUE;
} else {
- extra_secs = i_rand() % extra_secs;
+ extra_secs = i_rand_limit(extra_secs);
}
}
if (str_to_time(value, ×tamp) < 0) {
o_stream_nsend(output, data, size);
i_stream_skip(input, size);
- if (i_rand() % 3 == 0 && conn->to_delay == NULL) {
+ if (i_rand_limit(3) == 0 && conn->to_delay == NULL) {
conn->to_delay =
- timeout_add(i_rand() % DIRECTOR_CONN_MAX_DELAY_MSECS,
+ timeout_add(i_rand_limit(DIRECTOR_CONN_MAX_DELAY_MSECS),
director_connection_timeout, conn);
io_remove(&conn->in_io);
io_remove(&conn->out_io);
return;
hosts = array_get(&hosts_array, &count);
- i = i_rand() % count;
+ i = i_rand_limit(count);
- hosts[i]->vhost_count = (i_rand() % 20) * 10;
+ hosts[i]->vhost_count = i_rand_limit(20) * 10;
admin_send(conn, t_strdup_printf("HOST-SET\t%s\t%u\n",
net_ip2addr(&hosts[i]->ip), hosts[i]->vhost_count));
admin_read_hosts(admin);
to_disconnect =
- timeout_add(1000*(5 + i_rand()%DIRECTOR_DISCONNECT_TIMEOUT_SECS),
+ timeout_add(1000 * i_rand_minmax(5, 5 + DIRECTOR_DISCONNECT_TIMEOUT_SECS - 1),
director_connection_disconnect_timeout, (void *)NULL);
}
struct user_directory *dir;
struct mail_host *host = t_new(struct mail_host, 1);
time_t timestamp;
- unsigned int i, count = 10000 + i_rand()%10000;
+ unsigned int i, count = i_rand_minmax(10000, 19999);
test_begin("user directory random");
dir = user_directory_init(USER_DIR_TIMEOUT, NULL);
for (i = 0; i < count; i++) {
- if (i_rand() % 10 == 0)
+ if (i_rand_limit(10) == 0)
timestamp = ioloop_time;
else
- timestamp = ioloop_time-i_rand()%100;
+ timestamp = ioloop_time-i_rand_limit(100);
(void)user_directory_add(dir, i+1, host, timestamp);
}
verify_user_directory(dir, count);
random_node_create(struct dsync_mailbox_tree *tree, unsigned int counter,
const char *name)
{
- return node_create(tree, counter, name, i_rand() % 10);
+ return node_create(tree, counter, name, i_rand_limit(10));
}
static void nodes_create(struct dsync_mailbox_tree *tree, unsigned int *counter,
create_random_nodes(struct dsync_mailbox_tree *tree, const char *parent_name,
unsigned int depth, unsigned int *counter)
{
- unsigned int parent_len, i, nodes_count = 1 + i_rand() % 3;
+ unsigned int parent_len, i, nodes_count = i_rand_minmax(1, 3);
string_t *str;
if (depth == MAX_DEPTH)
/* 3) write semi-compressible data */
for (i = 0; i < sizeof(buf); i++) {
- if (i_rand() % 3 == 0)
- buf[i] = i_rand() % 4;
+ if (i_rand_limit(3) == 0)
+ buf[i] = i_rand_limit(4);
else
buf[i] = i;
}
i_fatal("dict_init(%s) failed: %s", argv[1], error);
for (i = 0;; i++) {
- i_snprintf(key, sizeof(key), "%s/%02x", prefix, i_rand() % 0xff);
- i_snprintf(value, sizeof(value), "%04x", i_rand() % 0xffff);
- switch (i_rand() % 4) {
+ i_snprintf(key, sizeof(key), "%s/%02x", prefix,
+ i_rand_limit(0xff));
+ i_snprintf(value, sizeof(value), "%04x", i_rand_limit(0xffff));
+ switch (i_rand_limit(4)) {
case 0:
pending++;
dict_lookup_async(dict, key, lookup_callback, NULL);
if (fs->op_probability[op] == 0)
return FALSE;
- if ((unsigned int)(i_rand() % (100*divider)) <= fs->op_probability[op]) {
+ if ((unsigned int)i_rand_limit(100 * divider) <= fs->op_probability[op]) {
errno = EIO;
fs_set_error(_fs, RANDOMFAIL_ERROR);
return TRUE;
if (!fs_random_fail(_fs, 1, op))
return FALSE;
- *offset_r = fs->range_start[op] +
- i_rand() % (fs->range_end[op] - fs->range_start[op] + 1);
+ *offset_r = i_rand_minmax(fs->range_start[op], fs->range_end[op]);
return TRUE;
}
/* test input in random chunks */
outi = first_outi;
for (i = 0; i < input_len; i += char_len) {
- max = i_rand() % (input_len - i) + 1;
+ max = i_rand_minmax(1, input_len - i);
for (char_len = 0; char_len < max; )
char_len += uni_utf8_char_bytes(input[i+char_len]);
while (fts_tokenizer_next(tok, input+i, char_len, &token, &error) > 0) {
flags = t_new(enum mail_flags, hdr.messages_count + 1);
for (r = 0; r < 1000; r++) {
- change = i_rand() % (MAIL_FLAGS_NONRECENT+1);
- seq1 = (i_rand() % hdr.messages_count) + 1;
+ change = i_rand_limit(MAIL_FLAGS_NONRECENT + 1);
+ seq1 = i_rand_minmax(1, hdr.messages_count);
seq2 = seq1 == hdr.messages_count ? seq1 :
- (i_rand() % (hdr.messages_count - seq1 + 1)) + seq1;
+ i_rand_minmax(seq1, hdr.messages_count);
- switch (i_rand() % 3) {
+ switch (i_rand_limit(3)) {
case 0:
modify_type = MODIFY_ADD;
for (seq = seq1; seq <= seq2; seq++)
test_assert(MODSEQ_MATCH(2, next_offset));
/* do some random testing with cache */
for (unsigned int i = 0; i < LOG_FILE_MODSEQ_CACHE_SIZE*10; i++) {
- modseq = (i_rand() % max_modseq) + 1;
+ modseq = i_rand_minmax(1, max_modseq);
test_assert(mail_transaction_log_file_get_modseq_next_offset(file, modseq, &next_offset) == 0);
test_assert(MODSEQ_MATCH(modseq, next_offset));
}
test_assert(modseq == max_modseq);
/* do some random testing with cache */
for (unsigned int i = 0; i < LOG_FILE_MODSEQ_CACHE_SIZE*10; i++) {
- modseq = (i_rand() % max_modseq) + 1;
+ modseq = i_rand_minmax(1, max_modseq);
test_assert(mail_transaction_log_file_get_highest_modseq_at(file, modseq_next_offset[modseq], &modseq_at, &error) == 0);
test_assert(modseq_at == modseq);
test_assert(mail_transaction_log_file_get_highest_modseq_at(file, modseq_alt_next_offset[modseq], &modseq_at, &error) == 0);
unsigned int i;
for (i = 0; i < count; i++)
- str_append_c(dest, i_rand() % ('z'-'a'+1) + 'a');
+ str_append_c(dest, i_rand_minmax('a', 'z'));
}
static void ATTR_NULL(3)
ht = mail_html2text_init(0);
for (unsigned int i = 0; i < 100; i++) {
- s[0] = valid_chars[i_rand() % N_ELEMENTS(valid_chars)];
- s[1] = valid_chars[i_rand() % N_ELEMENTS(valid_chars)];
- mail_html2text_more(ht, s, i_rand()%2+1, str);
+ s[0] = valid_chars[i_rand_limit(N_ELEMENTS(valid_chars))];
+ s[1] = valid_chars[i_rand_limit(N_ELEMENTS(valid_chars))];
+ mail_html2text_more(ht, s, i_rand_minmax(1, 2), str);
}
mail_html2text_deinit(&ht);
str_truncate(str, 0);
/* fill only with 7bit data so we don't have to worry about
the data being valid UTF-8 */
for (j = 0; j < sizeof(buf); j++)
- buf[j] = i_rand() % 128;
- buflen = i_rand() % sizeof(buf);
+ buf[j] = i_rand_limit(128);
+ buflen = i_rand_limit(sizeof(buf));
str_truncate(encoded, 0);
str_truncate(decoded, 0);
for (unsigned int j = 0; j < input_len; ) {
const unsigned char *input_part =
(const unsigned char *)tests[i].input + j;
- unsigned int len = i_rand() % (input_len - j) + 1;
+ unsigned int len = i_rand_minmax(1, input_len - j);
message_header_hash_more(&ctx, &hash_method_md5,
&md5_ctx, tests[i].version,
input_part, len);
auth->refcount = 1;
auth->fd = -1;
hash_table_create_direct(&auth->requests, pool, 0);
- auth->id_counter = (i_rand() % 32767) * 131072U;
+ auth->id_counter = i_rand_limit(32767) * 131072U;
return auth;
}
const struct setting_parser_context *parser;
const char *error;
- output.used_local = output.service_uses_local && (i_rand() % 2) != 0;
+ output.used_local = output.service_uses_local && i_rand_limit(2) != 0;
if (output.used_local) {
input.local_ip.family = AF_INET;
- input.local_ip.u.ip4.s_addr = 100 + i_rand() % 100;
+ input.local_ip.u.ip4.s_addr = i_rand_minmax(100, 199);
}
- output.used_remote = output.service_uses_remote && (i_rand() % 2) != 0;
+ output.used_remote = output.service_uses_remote && i_rand_limit(2) != 0;
if (output.used_remote) {
input.remote_ip.family = AF_INET;
- input.remote_ip.u.ip4.s_addr = 100 + i_rand() % 100;
+ input.remote_ip.u.ip4.s_addr = i_rand_minmax(100, 199);
}
test_assert(master_service_settings_cache_read(cache, &input, NULL, &parser, &error) == 0);
}
} else {
/* copy data to a buffer in somewhat random place. this could
help catch bugs. */
- new_skip_diff = i_rand() % 128;
+ new_skip_diff = i_rand_limit(128);
stream->skip = (stream->skip - tstream->skip_diff) +
new_skip_diff;
stream->pos = (stream->pos - tstream->skip_diff) +
break;
/* busy. wait for a while. */
- usleep(((i_rand() % 10) + 1) * 10000);
+ usleep(i_rand_minmax(1, 10) * 10000);
if (gettimeofday(&now, NULL) < 0)
i_panic("gettimeofday() failed: %m");
} while (timeval_diff_msecs(&now, &start) < (int)msecs);
test_begin("padded base32 encode/decode with random input");
for (i = 0; i < 1000; i++) {
- max = i_rand() % sizeof(buf);
+ max = i_rand_limit(sizeof(buf));
for (j = 0; j < max; j++)
buf[j] = i_rand();
test_begin("padded base32hex encode/decode with random input");
for (i = 0; i < 1000; i++) {
- max = i_rand() % sizeof(buf);
+ max = i_rand_limit(sizeof(buf));
for (j = 0; j < max; j++)
buf[j] = i_rand();
test_begin("base64 encode/decode with random input");
for (i = 0; i < 1000; i++) {
- max = i_rand() % sizeof(buf);
+ max = i_rand_limit(sizeof(buf));
for (j = 0; j < max; j++)
buf[j] = i_rand();
shadowbuf_size = 0;
for (i = 0; i < BUF_TEST_COUNT; i++) {
if (buf->used == BUF_TEST_SIZE) {
- size = shadowbuf_size = i_rand() % (buf->used - 1);
+ size = shadowbuf_size = i_rand_limit(buf->used - 1);
buffer_set_used_size(buf, size);
memset(shadowbuf + shadowbuf_size, 0,
BUF_TEST_SIZE - shadowbuf_size);
i_assert(buf->used < BUF_TEST_SIZE);
}
- test = i_rand() % 6;
- zero = i_rand() % 10 == 0;
+ test = i_rand_limit(6);
+ zero = i_rand_limit(10) == 0;
switch (test) {
case 0:
- pos = i_rand() % (BUF_TEST_SIZE-1);
- size = i_rand() % (BUF_TEST_SIZE - pos);
+ pos = i_rand_limit(BUF_TEST_SIZE - 1);
+ size = i_rand_limit(BUF_TEST_SIZE - pos);
if (!zero) {
buffer_write(buf, pos, testdata, size);
memcpy(shadowbuf + pos, testdata, size);
shadowbuf_size = pos + size;
break;
case 1:
- size = i_rand() % (BUF_TEST_SIZE - buf->used);
+ size = i_rand_limit(BUF_TEST_SIZE - buf->used);
if (!zero) {
buffer_append(buf, testdata, size);
memcpy(shadowbuf + shadowbuf_size,
shadowbuf_size += size;
break;
case 2:
- pos = i_rand() % (BUF_TEST_SIZE-1);
- size = i_rand() % (BUF_TEST_SIZE - I_MAX(buf->used, pos));
+ pos = i_rand_limit(BUF_TEST_SIZE - 1);
+ size = i_rand_limit(BUF_TEST_SIZE - I_MAX(buf->used, pos));
if (!zero) {
buffer_insert(buf, pos, testdata, size);
memmove(shadowbuf + pos + size,
shadowbuf_size = pos + size;
break;
case 3:
- pos = i_rand() % (BUF_TEST_SIZE-1);
- size = i_rand() % (BUF_TEST_SIZE - pos);
+ pos = i_rand_limit(BUF_TEST_SIZE - 1);
+ size = i_rand_limit(BUF_TEST_SIZE - pos);
buffer_delete(buf, pos, size);
if (pos < shadowbuf_size) {
if (pos + size > shadowbuf_size)
case 4:
if (shadowbuf_size <= 1)
break;
- pos = i_rand() % (shadowbuf_size-1); /* dest */
- pos2 = i_rand() % (shadowbuf_size-1); /* source */
- size = i_rand() % (shadowbuf_size - I_MAX(pos, pos2));
+ pos = i_rand_limit(shadowbuf_size - 1); /* dest */
+ pos2 = i_rand_limit(shadowbuf_size - 1); /* source */
+ size = i_rand_limit(shadowbuf_size - I_MAX(pos, pos2));
buffer_copy(buf, pos, buf, pos2, size);
memmove(shadowbuf + pos,
shadowbuf + pos2, size);
shadowbuf_size = pos + size;
break;
case 5:
- pos = i_rand() % (BUF_TEST_SIZE-1);
- size = i_rand() % (BUF_TEST_SIZE - pos);
+ pos = i_rand_limit(BUF_TEST_SIZE - 1);
+ size = i_rand_limit(BUF_TEST_SIZE - pos);
p = buffer_get_space_unsafe(buf, pos, size);
memcpy(p, testdata, size);
memcpy(shadowbuf + pos, testdata, size);
size_t size = 0;
unsigned int i, j, offset, stream_count, data_len, simult;
- stream_count = (i_rand() % TEST_MAX_ISTREAM_COUNT) + 2;
+ stream_count = i_rand_minmax(2, TEST_MAX_ISTREAM_COUNT + 2 - 1);
streams = t_new(struct istream *, stream_count + 1);
for (i = 0, offset = 0; i < stream_count; i++) {
- data_len = i_rand() % TEST_MAX_ISTREAM_SIZE + 1;
+ data_len = i_rand_minmax(1, TEST_MAX_ISTREAM_SIZE);
w_data = t_malloc_no0(data_len);
for (j = 0; j < data_len; j++)
w_data[j] = offset++;
concat = i_stream_create_concat(streams);
i_stream_set_max_buffer_size(concat, TEST_MAX_BUFFER_SIZE);
- simult = i_rand() % TEST_MAX_ISTREAM_COUNT;
+ simult = i_rand_limit(TEST_MAX_ISTREAM_COUNT);
if (simult > 0) {
limits = t_new(struct istream *, simult);
for (i = 0; i < simult; i++)
}
for (i = 0; i < 1000; i++) {
- struct istream *input = (simult == 0) ? concat : limits[i_rand() % simult];
- if (i_rand() % 3 == 0) {
- i_stream_seek(input, i_rand() % offset);
+ struct istream *input = (simult == 0) ? concat : limits[i_rand_limit(simult)];
+ if (i_rand_limit(3) == 0) {
+ i_stream_seek(input, i_rand_limit(offset));
} else {
ssize_t ret = i_stream_read(input);
size = i_stream_get_data_size(input);
} else if (input->v_offset + size != offset) {
test_assert(ret > 0);
test_assert(input->v_offset + ret <= offset);
- i_stream_skip(input, i_rand() % ret);
+ i_stream_skip(input, i_rand_limit(ret));
data = i_stream_get_data(input, &size);
for (j = 0; j < size; j++) {
size_t size;
unsigned int i, j, offset, stream_count, data_len, buffer_size;
- stream_count = (i_rand() % 10) + 2;
+ stream_count = i_rand_minmax(2, 10 + 2 - 1);
streams = t_new(struct istream *, stream_count + 1);
for (i = 0, offset = 0; i < stream_count; i++) {
- data_len = i_rand() % 100 + 1;
+ data_len = i_rand_minmax(1, 100);
w_data = t_malloc_no0(data_len);
for (j = 0; j < data_len; j++)
w_data[j] = offset++;
streams[i] = NULL;
i_assert(offset > 0);
- buffer_size = (i_rand() % 100) + 1; size = 0;
+ buffer_size = i_rand_minmax(1, 100); size = 0;
input = i_stream_create_seekable(streams, buffer_size, fd_callback, NULL);
/* first read it through */
i_stream_seek(input, 0);
for (i = 0; i < 100; i++) {
- if (i_rand() % 3 == 0) {
- i_stream_seek(input, i_rand() % offset);
+ if (i_rand_limit(3) == 0) {
+ i_stream_seek(input, i_rand_limit(offset));
} else {
ssize_t ret = i_stream_read(input);
if (input->v_offset + size == offset)
} else {
test_assert(ret > 0);
test_assert(input->v_offset + ret <= offset);
- i_stream_skip(input, i_rand() % (ret+1));
+ i_stream_skip(input, i_rand_limit(ret + 1));
data = i_stream_get_data(input, &size);
for (j = 0; j < size; j++) {
test_assert_idx(i_stream_read(child_input[i]) == 0, len);
test_assert_idx(!tee_i_stream_child_is_waiting(child_input[i]), len);
}
- delta = i_rand() % 32; /* may stand still */
+ delta = i_rand_limit(32); /* may stand still */
if(delta > TEST_BUF_SIZE - len)
delta = 1;
}
delta = 1;
while ((len += delta) <= TEST_STR_LEN) {
- unsigned int lagger = i_rand() % CHILD_COUNT;
+ unsigned int lagger = i_rand_limit(CHILD_COUNT);
test_istream_set_size(test_input, len);
for (i = 0; i < CHILD_COUNT; i++) {
test_assert(i_stream_read(child_input[i]) == -2);
test_assert(i_stream_read(child_input[i]) == -2);
test_assert(!tee_i_stream_child_is_waiting(child_input[i]));
}
- delta = i_rand() % 31 + 1; /* mustn't stand still */
+ delta = i_rand_minmax(1, 31); /* mustn't stand still */
if(delta > TEST_STR_LEN - len)
delta = 1;
}
output = o_stream_create_buffer(buffer);
o_stream_cork(output);
- size = (i_rand() % MAX_BUFSIZE) + 1;
+ size = i_rand_minmax(1, MAX_BUFSIZE);
random_fill(randbuf, size);
memcpy(buf, randbuf, size);
test_assert(o_stream_send(output, buf, size) > 0);
for (i = 0; i < 10; i++) {
- offset = i_rand() % (MAX_BUFSIZE*3);
- size = (i_rand() % MAX_BUFSIZE) + 1;
+ offset = i_rand_limit(MAX_BUFSIZE * 3);
+ size = i_rand_minmax(1, MAX_BUFSIZE);
random_fill(randbuf, size);
memcpy(buf + offset, randbuf, size);
test_assert(o_stream_pwrite(output, randbuf, size, offset) == 0);
- if (i_rand() % 10 == 0)
+ if (i_rand_limit(10) == 0)
test_assert(o_stream_flush(output) > 0);
}
output = o_stream_create_fd(fd, MAX_BUFSIZE);
o_stream_cork(output);
- size = (i_rand() % MAX_BUFSIZE) + 1;
+ size = i_rand_minmax(1, MAX_BUFSIZE);
random_fill(randbuf, size);
memcpy(buf, randbuf, size);
test_assert(o_stream_send(output, buf, size) > 0);
for (i = 0; i < 10; i++) {
- offset = i_rand() % (MAX_BUFSIZE*3);
- size = (i_rand() % MAX_BUFSIZE) + 1;
+ offset = i_rand_limit(MAX_BUFSIZE * 3);
+ size = i_rand_minmax(1, MAX_BUFSIZE);
random_fill(randbuf, size);
memcpy(buf + offset, randbuf, size);
test_assert(o_stream_pwrite(output, randbuf, size, offset) == 0);
- if (i_rand() % 10 == 0)
+ if (i_rand_limit(10) == 0)
test_assert(o_stream_flush(output) > 0);
}
for (i = 0; i < 100; i++) {
pq = priorityq_init(cmp_int, 1);
for (j = 0; j < PQ_MAX_ITEMS; j++) {
- items[j].num = i_rand() % INT_MAX;
+ items[j].num = i_rand_limit(INT_MAX);
priorityq_add(pq, &items[j].item);
}
for (j = 0; j < PQ_MAX_ITEMS; j++) {
- if (i_rand() % 3 == 0) {
+ if (i_rand_limit(3) == 0) {
priorityq_remove(pq, &items[j].item);
items[j].num = -1;
}
static void test_str_to_uintmax(void)
{
unsigned int i=0;
- int randrange = i_rand()%15+1; /* when 1, will max out on 1s */
+ int randrange = i_rand_minmax(1, 15); /* when 1, will max out on 1s */
uintmax_t value = 0, valbase = i_rand() * 1000ull;
int len, ret;
char buff[50]; /* totally assumes < 159 bits */
value = (value << 1) + 1;
if (value >= 64)
- value -= i_rand()%randrange; /* don't always test the same numbers */
+ value -= i_rand_limit(randrange); /* don't always test the same numbers */
len = crappy_uintmax_to_str(buff, value);
ret = str_to_uintmax(buff, &value_back);
test_assert_idx(ret == 0, i);
static void test_str_to_uintmax_hex(void)
{
unsigned int i=0;
- int randrange = i_rand()%15+1; /* when 1, will max out on 1s */
+ int randrange = i_rand_minmax(1, 15); /* when 1, will max out on 1s */
uintmax_t value = 0, valbase = i_rand() * 1000ull;
int len, ret;
char buff[52]; /* totally assumes < 200 bits */
value = (value << 1) + 1;
if (value >= 64)
- value -= i_rand()%randrange; /* don't always test the same numbers */
+ value -= i_rand_limit(randrange); /* don't always test the same numbers */
len = crappy_uintmax_to_str_hex(buff, value);
ret = str_to_uintmax_hex(buff, &value_back);
test_assert_idx(ret == 0, i);
static void test_str_to_uintmax_oct(void)
{
unsigned int i=0;
- int randrange = i_rand()%15+1; /* when 1, will max out on 1s */
+ int randrange = i_rand_minmax(1, 15); /* when 1, will max out on 1s */
uintmax_t value = 0, valbase = i_rand() * 1000ull;
int len, ret;
char buff[69]; /* totally assumes < 200 bits */
value = (value << 1) + 1;
if (value >= 64)
- value -= i_rand()%randrange; /* don't always test the same numbers */
+ value -= i_rand_limit(randrange); /* don't always test the same numbers */
len = crappy_uintmax_to_str_oct(buff, value);
ret = str_to_uintmax_oct(buff, &value_back);
test_assert_idx(ret == 0, i);
/* The bottom 6 bits should be irrelevant to code coverage,
only test 000000, 111111, and something in between. */
if ((chr & 63) == 1)
- chr += i_rand() % 62; /* After 0, somewhere between 1 and 62 */
+ chr += i_rand_limit(62); /* After 0, somewhere between 1 and 62 */
else if ((chr & 63) > 0 && (chr & 63) < 63)
chr |= 63; /* After random, straight to 63 */
if (timing->count == 0)
timing->min = timing->max = usecs;
} else {
- unsigned int idx = i_rand() % timing->count;
+ unsigned int idx = i_rand_limit(timing->count);
if (idx < TIMING_SUBSAMPLING_BUFFER)
timing->samples[idx] = usecs;
}
processes will disconnect at slightly different times to
spread the load. */
timeval_add_msecs(&rec->disconnect_timestamp,
- i_rand() % PROXY_DISCONNECT_INTERVAL_MSECS);
+ i_rand_limit(PROXY_DISCONNECT_INTERVAL_MSECS));
}
rec->num_disconnects_since_ts++;
if (proxy->to != NULL) {
/* randomize the initial index in case service_count=1
(although in that case it's unlikely this setting is
even used..) */
- login_source_ips_idx = i_rand() % login_source_ips_count;
+ login_source_ips_idx = i_rand_limit(login_source_ips_count);
}
login_load_modules();
if (to_instance != NULL)
timeout_remove(&to_instance);
- to_instance = timeout_add((3600*12 + i_rand()%(60*30)) * 1000,
+ to_instance = timeout_add((3600 * 12 + i_rand_limit(60 * 30)) * 1000,
instance_update_now, list);
}
signal to all of them at once */
process->to_idle =
timeout_add((service->idle_kill * 1000) +
- (i_rand() % 100)*10,
+ i_rand_limit(100) * 10,
service_process_kill_idle,
process);
}