Files | |
| file | sysio.c |
| System I/O management. | |
Macros | |
| #define | padico_io_t padico_sysio_t |
| for backwards compatibility with legacy codes | |
| #define | PADICO_IO_EVENT_READ 0x01 |
| the fildes is readable | |
| #define | PADICO_IO_EVENT_WRITE 0x02 |
| the fildes is writable | |
| #define | PADICO_IO_EVENT_ERROR 0x04 |
| the fildes has an error | |
Typedefs | |
| typedef struct padico_sysio_s * | padico_sysio_t |
| a NetAccess I/O handle | |
| typedef int(* | padico_sysio_callback_t) (int fd, void *key) |
| a NetAccess SysIO callback | |
Detailed Description
Macro Definition Documentation
◆ PADICO_IO_EVENT_ERROR
◆ PADICO_IO_EVENT_READ
◆ PADICO_IO_EVENT_WRITE
◆ padico_io_t
| #define padico_io_t padico_sysio_t |
Typedef Documentation
◆ padico_sysio_callback_t
◆ padico_sysio_t
Function Documentation
◆ padico_io_activate()
| void padico_io_activate | ( | padico_sysio_t | io | ) |
Activates the I/O handle - when not activated, the callback is not triggered.
Definition at line 278 of file sysio.c.
References done, na_sysio_lock(), na_sysio_rebuild_fds(), and na_sysio_unlock().
Referenced by bsio_start(), padico_na_sysio_init(), psp_sf_connect(), remote_control_connector(), sflibssh2_connect(), sfplain_connect(), sfplain_listen(), sfrfw_gateway_client_callback_connector(), sfsnc_connect(), sfsplice_do_splicing(), sfsrtun_connect(), sfssh2_connect(), sfstun_connect(), socks4client_connect(), ssh2_control_start(), sysio_control_start(), tube_gk_init(), vlink_ps_listen(), vnode_hfd_create(), vnode_hfd_read_post(), vnode_hfd_write_post(), vrp_incoming_construct(), and vrp_outgoing_construct().
◆ padico_io_deactivate()
| void padico_io_deactivate | ( | padico_sysio_t | io | ) |
Deactivate the I/O handle - should be used for temporarly deactivate callback trigger.
Definition at line 288 of file sysio.c.
References done, na_sysio_lock(), na_sysio_rebuild_fds(), and na_sysio_unlock().
Referenced by bsio_stop(), sflibssh2_close(), sflibssh2_destroy(), sfplain_close(), sfrfw_gateway_close(), sfsnc_close(), sfsnc_destroy(), sfsplice_destroy(), sfsrtun_close(), sfssh2_close(), sfssh2_destroy(), sfstun_close(), tube_gk_stop(), vlink_sf_fullshutdown(), and vnode_hfd_close().
◆ padico_io_register()
| padico_sysio_t padico_io_register | ( | int | fd, |
| unsigned int | what, | ||
| padico_sysio_callback_t | callback, | ||
| void * | key | ||
| ) |
Registers a file descriptor for polling.
- Parameters
-
fd File descriptor (should already exist) what The operation that triggers callback – several bits may be OR-ed callback The callback function that will be called uppon I/O event key an argument that will be given to the callback
- Returns
- an I/O handle for future reference
- Note
- after registration, the I/O handle is not activated
- Bug:
- Some troubles in this implementation... Since padico_io_t are static pointers into a dynamic vector, we must be sure that the I/O vector is never resized! It's too strong a constraint for scalability. Static assertions about a dynamic vector are obviously not the way to go. It's enough for testing, though...
Definition at line 205 of file sysio.c.
References padico_sysio_s::activated, assert(), padico_sysio_s::callback, padico_sysio_s::callback_key, done, fd, padico_sysio_s::fd, padico_sysio_mgr_s::ios, key, na_ios, na_sysio_lock(), na_sysio_rebuild_fds(), na_sysio_unlock(), NULL, PADICO_IO_MAX_FD, padico_io_t, padico_sysio_s::status, v, padico_sysio_s::what, and what.
Referenced by bench_sysio_init(), padico_na_sysio_init(), psp_sf_connect(), remote_control_connector(), sflibssh2_connect(), sfplain_bind(), sfplain_connect(), sfrfw_gateway_client_callback_connector(), sfrfw_gateway_server_callback_connector(), sfsnc_connect(), sfsplice_do_splicing(), sfsrtun_create(), sfssh2_connect(), sfstun_create(), socks4client_proxy_connect_notifier(), ssh2_control_start(), sysio_control_start(), tube_gk_init(), vlink_ps_listen(), vnode_hfd_create(), vrp_incoming_construct(), and vrp_outgoing_construct().
◆ padico_io_unregister()
| void padico_io_unregister | ( | padico_sysio_t | io | ) |
Unregister the I/O handle.
- Note
- even if it is not mandatory, it is better to:
- deactivate the io
- perform the required synchronisation (check callback completion)
- finally, unregister.
- Unregister a callback has a high cost. Most of the time, use deactivation; unregister the callback just before closing the file descriptor.
- See also
- padico_io_deactivate()
Definition at line 298 of file sysio.c.
References assert(), done, na_sysio_lock(), na_sysio_rebuild_fds(), and na_sysio_unlock().
Referenced by remote_control_finalize(), sflibssh2_close(), sflibssh2_destroy(), sfplain_close(), sfrfw_gateway_close(), sfsnc_close(), sfsnc_destroy(), sfsplice_destroy(), sfsrtun_close(), sfssh2_close(), sfssh2_destroy(), sfstun_close(), socks4client_proxy_reply_notifier(), sysio_control_socket_close(), vlink_sf_fullshutdown(), vnode_hfd_close(), vrp_incoming_close(), and vrp_outgoing_close().
◆ padico_sysio_accept()
Definition at line 784 of file sysio.c.
References done, na_sysio_tune_socket(), PUK_ABI_FSYS_WRAP, rc, and s.
Referenced by bench_sysio_init(), and vlink_ps_callback_acceptor().
◆ padico_sysio_bound_inet_socket()
Definition at line 887 of file sysio.c.
References done, int, NULL, padico_sysio_socket(), port, PUK_ABI_FSYS_WRAP, rc, s, and socklen_t.
Referenced by bench_sysio_init().
◆ padico_sysio_close()
Definition at line 776 of file sysio.c.
References done, fd, PUK_ABI_FSYS_WRAP, and rc.
Referenced by bench_sysio_init(), sflibss2_start_thread(), sflibssh2_close(), sflibssh2_create(), ssh2_control_destroy(), ssh2_libssh2_init_ssh_connection(), sysio_control_socket_close(), and vlink_ps_close().
◆ padico_sysio_connected_inet_socket()
Definition at line 841 of file sysio.c.
References done, na_sysio_tune_socket(), padico_sysio_socket(), port, PUK_ABI_FSYS_WRAP, rc, and s.
Referenced by bench_sysio_init().
◆ padico_sysio_connected_inet_socket_sockaddr()
Definition at line 867 of file sysio.c.
References done, na_sysio_tune_socket(), padico_sysio_socket(), PUK_ABI_FSYS_WRAP, rc, and s.
Referenced by sflibssh2_socket_connect_ssh_server(), and ssh2_libssh2_connect_server().
◆ padico_sysio_eos()
◆ padico_sysio_errno()
Definition at line 575 of file sysio.c.
References __puk_abi_wrap__errno.
Referenced by sflibssh2_connect(), sfplain_create(), sfsplice_create(), sfsrtun_create(), sfstun_create(), vlink_ps_callback_acceptor(), vlink_ps_reader_worker(), vlink_sysio_reader_worker(), and vlink_sysio_writer_worker().
◆ padico_sysio_getfd()
| int padico_sysio_getfd | ( | padico_sysio_t | io | ) |
◆ padico_sysio_in()
Definition at line 792 of file sysio.c.
References done, padico_sysio_read(), and rc.
Referenced by bench_sysio_reader(), na_sysio_unlock_callback(), psp_sf_callback(), psp_sf_pump(), read_tube(), remote_control_control_callback(), socks4client_proxy_reply_notifier(), ssh2_control_in(), ssh2_control_read_callback(), sysio_control_read_callback(), sysio_control_start(), and vlink_ps_callback_acceptor().
◆ padico_sysio_out()
Definition at line 808 of file sysio.c.
References done, padico_sysio_write(), padico_tm_yield(), and rc.
Referenced by bsio_send(), na_sysio_unlock_force(), psp_sf_end_message(), psp_sf_pack(), remote_control_control_send(), sflibss2_start_thread(), sfrfw_gateway_client_read_callback(), sfrfw_gateway_server_read_callback(), socks4client_send_request(), ssh2_control_out(), sysio_control_start(), vlink_ps_connect(), vlink_ps_send_post(), and write_tube().
◆ padico_sysio_outv()
Definition at line 828 of file sysio.c.
References done, padico_sysio_writev(), and rc.
Referenced by ssh2_control_outv(), and sysio_control_send_common().
◆ padico_sysio_read()
Definition at line 620 of file sysio.c.
References __puk_abi_wrap__errno, assert(), done, na_ios, p, PUK_ABI_FSYS_WRAP, rc, padico_sysio_mgr_s::retry_factor, padico_sysio_mgr_s::retry_slice, padico_sysio_mgr_s::strategy_retry, and SYSIO_MAX_RETRY.
Referenced by padico_sysio_in(), sfrfw_gateway_client_read_callback(), sfrfw_gateway_server_read_callback(), vlink_ps_reader_worker(), and vlink_sysio_reader_worker().
◆ padico_sysio_refresh()
| int padico_sysio_refresh | ( | padico_sysio_t | io | ) |
Waits until at least one polling/callback cycle has been performed on the I/O handle.
Definition at line 262 of file sysio.c.
References done, na_sysio_lock(), na_sysio_unlock(), na_sysio_update_status(), and rc.
Referenced by vnode_hfd_read_post(), and vnode_hfd_write_post().
◆ padico_sysio_shutdown_wr()
◆ padico_sysio_socket()
Definition at line 604 of file sysio.c.
References domain, done, fd, na_sysio_tune_socket(), PUK_ABI_FSYS_WRAP, rc, and type.
Referenced by padico_sysio_bound_inet_socket(), padico_sysio_connected_inet_socket(), padico_sysio_connected_inet_socket_sockaddr(), sfplain_create(), sfsplice_create(), sfsrtun_create(), sfstun_create(), vlink_ps_connect(), and vlink_ps_create().
◆ padico_sysio_stat()
| padico_rc_t padico_sysio_stat | ( | void | ) |
dump internal status of SysIO
Definition at line 1014 of file sysio.c.
References done, padico_na_internal_getios(), padico_sysio_vect_t, rc, and v.
Referenced by padico_sysio_stat_handler().
◆ padico_sysio_write()
Definition at line 699 of file sysio.c.
References __puk_abi_wrap__errno, assert(), done, na_ios, p, PUK_ABI_FSYS_WRAP, rc, padico_sysio_mgr_s::retry_factor, padico_sysio_mgr_s::retry_slice, padico_sysio_mgr_s::strategy_lock, padico_sysio_mgr_s::strategy_retry, and SYSIO_MAX_RETRY.
Referenced by padico_sysio_out(), and vlink_sysio_writer_worker().
◆ padico_sysio_writev()
Definition at line 688 of file sysio.c.
References __puk_abi_wrap__errno, done, PUK_ABI_FSYS_WRAP, and rc.
Referenced by padico_sysio_outv().