netio.c File Reference
`#include <config.h>`
`#include <assert.h>`
`#include <errno.h>`
`#include <sys/time.h>`
`#include <string.h>`
`#include <stdlib.h>`
`#include "log.h"`
`#include "wire/netio.h"`

Go to the source code of this file.

## Macros

#define | NANOSECONDS_PER_SECOND 1000000000L

## Functions

int | pselect (int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const struct timespec *timeout, const sigset_t *sigmask)
netio_type * | netio_create ()
void | netio_add_handler (netio_type *netio, netio_handler_type *handler)
void | netio_remove_handler (netio_type *netio, netio_handler_type *handler)
void | timespec_add (struct timespec *left, const struct timespec *right)
const struct timespec * | netio_current_time (netio_type *netio)
int | netio_dispatch (netio_type *netio, const struct timespec *timeout, const sigset_t *sigmask)
void | netio_cleanup (netio_type *netio)
void | netio_cleanup_shallow (netio_type *netio)

## Macro Definition Documentation

## NANOSECONDS_PER_SECOND

#define NANOSECONDS_PER_SECOND 1000000000L

Definition at line 28 of file netio.c.

Referenced by timespec_add().

## Function Documentation

## netio_add_handler()

void netio_add_handler | ( | netio_type * | netio,
|  | netio_handler_type * | handler )

Definition at line 53 of file netio.c.

References netio_handler_list_struct::handler, netio_struct::handlers, and netio_handler_list_struct::next.

Referenced by dnshandler_start(), sock_handle_tcp_accept(), and xfrhandler_start().

## netio_cleanup()

void netio_cleanup | ( | netio_type * | netio | ) |

Clean up netio instance

Definition at line 336 of file netio.c.

References netio_handler_struct::free_handler, netio_handler_list_struct::handler, netio_struct::handlers, netio_handler_list_struct::next, and netio_handler_struct::user_data.

Referenced by dnshandler_cleanup().

## netio_cleanup_shallow()

void netio_cleanup_shallow | ( | netio_type * | netio | ) |

Clean up netio instance

Definition at line 355 of file netio.c.

References netio_struct::handlers.

Referenced by xfrhandler_cleanup().

## netio_create()

netio_type * netio_create | ( | void |  | ) |

Definition at line 39 of file netio.c.

References netio_struct::dispatch_next, and netio_struct::handlers.

Referenced by dnshandler_create(), and xfrhandler_create().

## netio_current_time()

const struct timespec * netio_current_time | ( | netio_type * | netio | ) |

Definition at line 163 of file netio.c.

References netio_struct::cached_current_time, and netio_struct::have_current_time.

Referenced by netio_dispatch(), sock_handle_tcp_accept(), sock_handle_tcp_read(), and sock_handle_tcp_write().

## netio_dispatch()

int netio_dispatch | ( | netio_type * | netio,
|  | const struct timespec * | timeout,
|  | const sigset_t * | sigmask )

Definition at line 187 of file netio.c.

References netio_struct::dispatch_next, netio_handler_struct::event_handler, netio_handler_struct::event_types, netio_handler_struct::fd, netio_handler_list_struct::handler, netio_struct::handlers, netio_struct::have_current_time, netio_current_time(), NETIO_EVENT_EXCEPT, NETIO_EVENT_NONE, NETIO_EVENT_READ, NETIO_EVENT_TIMEOUT, NETIO_EVENT_WRITE, netio_handler_list_struct::next, pselect(), and netio_handler_struct::timeout.

Referenced by dnshandler_start(), and xfrhandler_start().

## netio_remove_handler()

void netio_remove_handler | ( | netio_type * | netio,
|  | netio_handler_type * | handler )

Definition at line 72 of file netio.c.

References netio_struct::dispatch_next, netio_struct::handlers, and netio_handler_list_struct::next.

Referenced by engine_update_zones().

## pselect()

int pselect | ( | int | n,
|  | fd_set * | readfds,
|  | fd_set * | writefds,
|  | fd_set * | exceptfds,
|  | const struct timespec * | timeout,
|  | const sigset_t * | sigmask )

Referenced by netio_dispatch().

## timespec_add()

void timespec_add | ( | struct timespec * | left,
|  | const struct timespec * | right )

Add timespecs.

Definition at line 131 of file netio.c.

References NANOSECONDS_PER_SECOND.

Referenced by sock_handle_tcp_accept(), sock_handle_tcp_read(), and sock_handle_tcp_write().