Asterisk - The Open Source Telephony Project
18.5.0
|
I/O Managment (Derived from Cheops-NG) More...
#include "asterisk.h"
#include <termios.h>
#include <sys/ioctl.h>
#include "asterisk/io.h"
#include "asterisk/utils.h"
Go to the source code of this file.
Data Structures | |
struct | io_context |
Global IO variables are now in a struct in order to be made threadsafe. More... | |
struct | io_rec |
Kept for each file descriptor. More... | |
Macros | |
#define | DEBUG(a) |
#define | GROW_SHRINK_SIZE 512 |
Functions | |
int | ast_get_termcols (int fd) |
int | ast_hide_password (int fd) |
int * | ast_io_add (struct io_context *ioc, int fd, ast_io_cb callback, short events, void *data) |
Add a new I/O entry for this file descriptor with the given event mask, to call callback with data as an argument. More... | |
int * | ast_io_change (struct io_context *ioc, int *id, int fd, ast_io_cb callback, short events, void *data) |
Changes an IO handler. More... | |
void | ast_io_dump (struct io_context *ioc) |
Dumps the IO array. Debugging: Dump everything in the I/O array. More... | |
int | ast_io_remove (struct io_context *ioc, int *_id) |
Removes an IO context. More... | |
int | ast_io_wait (struct io_context *ioc, int howlong) |
Make the poll call, and call the callbacks for anything that needs to be handled. More... | |
int | ast_restore_tty (int fd, int oldstate) |
Restores TTY mode. Call with result from previous ast_hide_password. More... | |
int | ast_sd_get_fd (int type, const struct ast_sockaddr *addr) |
Find a listening file descriptor provided by socket activation. More... | |
int | ast_sd_get_fd_un (int type, const char *path) |
Find a listening AF_LOCAL file descriptor provided by socket activation. More... | |
int | ast_sd_notify (const char *state) |
a wrapper for sd_notify(): notify systemd of any state changes. More... | |
struct io_context * | io_context_create (void) |
Create an I/O context. More... | |
void | io_context_destroy (struct io_context *ioc) |
Destroys a context. More... | |
static int | io_grow (struct io_context *ioc) |
Grow the size of our arrays. More... | |
static int | io_shrink (struct io_context *ioc) |
I/O Managment (Derived from Cheops-NG)
Definition in file io.c.
#define DEBUG | ( | a | ) |
Definition at line 48 of file io.c.
Referenced by ast_io_add(), ast_io_wait(), and io_grow().
#define GROW_SHRINK_SIZE 512 |
Definition at line 67 of file io.c.
Referenced by io_context_create(), and io_grow().
int ast_get_termcols | ( | int | fd | ) |
Definition at line 373 of file io.c.
References isatty().
Referenced by ast_cli_display_match_list().
int ast_hide_password | ( | int | fd | ) |
int* ast_io_add | ( | struct io_context * | ioc, |
int | fd, | ||
ast_io_cb | callback, | ||
short | events, | ||
void * | data | ||
) |
Add a new I/O entry for this file descriptor with the given event mask, to call callback with data as an argument.
Adds an IO context.
Definition at line 162 of file io.c.
References ast_debug, ast_malloc, io_rec::callback, io_rec::data, DEBUG, events, io_context::fdcnt, io_context::fds, io_rec::id, io_grow(), io_context::ior, io_context::maxfdcnt, and NULL.
Referenced by ast_netsock_bindaddr(), ast_udptl_new_with_bindaddr(), do_monitor(), mbl_load_adapter(), and network_thread().
int* ast_io_change | ( | struct io_context * | ioc, |
int * | id, | ||
int | fd, | ||
ast_io_cb | callback, | ||
short | events, | ||
void * | data | ||
) |
Changes an IO handler.
ioc | which context to use |
id | |
fd | the fd you wish it to contain now |
callback | new callback function |
events | event mask to wait for |
data | data to pass to the callback function Change an I/O handler, updating fd if > -1, callback if non-null, and revents if >-1, and data if non-null. |
a | pointer to the ID of the IO event |
NULL | on failure |
Definition at line 200 of file io.c.
References io_rec::callback, io_rec::data, events, io_context::fdcnt, io_context::fds, io_rec::id, io_context::ior, and NULL.
Referenced by do_monitor().
void ast_io_dump | ( | struct io_context * | ioc | ) |
Dumps the IO array. Debugging: Dump everything in the I/O array.
Definition at line 312 of file io.c.
References ast_debug, io_rec::callback, io_rec::data, io_context::fdcnt, io_context::fds, io_rec::id, io_context::ior, and io_context::maxfdcnt.
int ast_io_remove | ( | struct io_context * | ioc, |
int * | id | ||
) |
Removes an IO context.
ioc | which io_context to remove it from |
id | which ID to remove Remove an I/O id from consideration |
0 | on success |
-1 | on failure |
Definition at line 245 of file io.c.
References ast_free, ast_log, io_context::current_ioc, io_context::fdcnt, io_context::fds, io_rec::id, io_shrink(), io_context::ior, LOG_NOTICE, LOG_WARNING, io_context::needshrink, and NULL.
Referenced by ast_io_wait(), ast_netsock_destroy(), ast_udptl_destroy(), do_monitor(), mbl_load_adapter(), network_thread(), reload_config(), and unload_module().
int ast_io_wait | ( | struct io_context * | ioc, |
int | howlong | ||
) |
Make the poll call, and call the callbacks for anything that needs to be handled.
Waits for IO.
Definition at line 278 of file io.c.
References ast_debug, ast_io_remove(), ast_poll, io_rec::callback, io_context::current_ioc, io_rec::data, DEBUG, io_context::fdcnt, io_context::fds, io_rec::id, io_shrink(), io_context::ior, and io_context::needshrink.
Referenced by do_monitor(), do_sco_listen(), network_thread(), and reload_config().
int ast_restore_tty | ( | int | fd, |
int | oldstate | ||
) |
int ast_sd_get_fd | ( | int | type, |
const struct ast_sockaddr * | addr | ||
) |
Find a listening file descriptor provided by socket activation.
type | SOCK_STREAM or SOCK_DGRAM |
addr | The socket address of the bound listener. |
<0 | No match. |
>0 | File Descriptor matching sockaddr. |
Definition at line 438 of file io.c.
Referenced by ast_tcptls_server_start().
int ast_sd_get_fd_un | ( | int | type, |
const char * | path | ||
) |
Find a listening AF_LOCAL file descriptor provided by socket activation.
type | SOCK_STREAM or SOCK_DGRAM |
path | The path of the listener. |
<0 | No match. |
>0 | File Descriptor matching path. |
Definition at line 454 of file io.c.
Referenced by ast_makesocket(), and main().
int ast_sd_notify | ( | const char * | state | ) |
a wrapper for sd_notify(): notify systemd of any state changes.
state | a string that states the changes. See sd_notify(3). The wrapper does nothing if systemd ('s development headers) was not detected on the system. |
Definition at line 392 of file io.c.
References ast_sockaddr_cmp(), ast_sockaddr_copy_sockaddr(), and type.
Referenced by ast_module_reload(), asterisk_daemon(), and really_quit().
struct io_context* io_context_create | ( | void | ) |
Create an I/O context.
Creates a context Create a context for I/O operations Basically mallocs an IO structure and sets up some default values.
Definition at line 81 of file io.c.
References ast_calloc, ast_free, ast_malloc, io_context::current_ioc, io_context::fdcnt, io_context::fds, GROW_SHRINK_SIZE, io_context::ior, io_context::maxfdcnt, io_context::needshrink, NULL, and tmp().
Referenced by load_module(), and mbl_load_adapter().
void io_context_destroy | ( | struct io_context * | ioc | ) |
Destroys a context.
ioc | structure to destroy Destroy a context for I/O operations Frees all memory associated with the given io_context structure along with the structure itself |
Definition at line 107 of file io.c.
References ast_free, io_context::fds, and io_context::ior.
Referenced by load_module(), mbl_load_adapter(), and unload_module().
|
static |
Grow the size of our arrays.
Definition at line 122 of file io.c.
References ast_debug, ast_realloc, DEBUG, io_context::fds, GROW_SHRINK_SIZE, io_context::ior, io_context::maxfdcnt, and tmp().
Referenced by ast_io_add().
|
static |
Definition at line 218 of file io.c.
References io_context::fdcnt, io_context::fds, io_rec::id, io_context::ior, and io_context::needshrink.
Referenced by ast_io_remove(), and ast_io_wait().