Coverage Report

Created: 2025-11-03 07:11

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/dovecot/src/lib/ioloop-iolist.c
Line
Count
Source
1
/*
2
 * Copyright (c) 2004 Andrey Panin <pazke@donpac.ru>
3
 *
4
 * This software is released under the MIT license.
5
 */
6
7
#include "lib.h"
8
#include "ioloop-private.h"
9
#include "ioloop-iolist.h"
10
11
bool ioloop_iolist_add(struct io_list *list, struct io_file *io)
12
0
{
13
0
  int i, idx;
14
15
0
  if ((io->io.condition & IO_READ) != 0)
16
0
    idx = IOLOOP_IOLIST_INPUT;
17
0
  else if ((io->io.condition & IO_WRITE) != 0)
18
0
    idx = IOLOOP_IOLIST_OUTPUT;
19
0
  else if ((io->io.condition & IO_ERROR) != 0)
20
0
    idx = IOLOOP_IOLIST_ERROR;
21
0
  else {
22
0
    i_unreached();
23
0
  }
24
25
0
  if (list->ios[idx] != NULL) {
26
0
    i_panic("io_add(0x%x) called twice fd=%d, callback=%p -> %p",
27
0
      io->io.condition, io->fd, list->ios[idx]->io.callback,
28
0
      io->io.callback);
29
0
  }
30
0
  i_assert(list->ios[idx] == NULL);
31
0
  list->ios[idx] = io;
32
33
  /* check if this was the first one */
34
0
  for (i = 0; i < IOLOOP_IOLIST_IOS_PER_FD; i++) {
35
0
    if (i != idx && list->ios[i] != NULL)
36
0
      return FALSE;
37
0
  }
38
39
0
  return TRUE;
40
0
}
41
42
bool ioloop_iolist_del(struct io_list *list, struct io_file *io)
43
0
{
44
0
  bool last = TRUE;
45
0
  int i;
46
47
0
  for (i = 0; i < IOLOOP_IOLIST_IOS_PER_FD; i++) {
48
0
    if (list->ios[i] != NULL) {
49
0
      if (list->ios[i] == io)
50
0
        list->ios[i] = NULL;
51
0
      else
52
0
        last = FALSE;
53
0
    }
54
0
  }
55
0
  return last;
56
0
}