equal
deleted
inserted
replaced
4 /** |
4 /** |
5 * @file |
5 * @file |
6 * |
6 * |
7 * Support for transport implementations that use POSIX file descriptor streams. |
7 * Support for transport implementations that use POSIX file descriptor streams. |
8 * |
8 * |
9 * This provides the read/write methods, as well as functions to help implement the event-based behaviour |
9 * This provides the read/write methods, as well as functions to implement the event-based behaviour. |
10 */ |
10 */ |
11 #include "transport_internal.h" |
11 #include "transport_internal.h" |
12 |
12 |
13 #include <event2/event.h> |
13 #include <event2/event.h> |
14 #include <stdbool.h> |
14 #include <stdbool.h> |
94 |
94 |
95 /** |
95 /** |
96 * Initialize the transport_fd to use the given, connected fd, or TRANSPORT_FD_INVALID if we don't yet have an fd. |
96 * Initialize the transport_fd to use the given, connected fd, or TRANSPORT_FD_INVALID if we don't yet have an fd. |
97 * |
97 * |
98 * It is an error to call this if the transport_fd already has an fd set |
98 * It is an error to call this if the transport_fd already has an fd set |
99 i* |
99 * |
100 * @param fd the transport_fd state |
100 * @param fd the transport_fd state |
101 * @param ev_base the libevent base to use |
101 * @param ev_base the libevent base to use |
102 * @param _fd the OS file descriptor, or TRANSPORT_FD_INVALID |
102 * @param _fd the OS file descriptor, or TRANSPORT_FD_INVALID |
103 */ |
103 */ |
104 void transport_fd_init (struct transport_fd *fd, struct event_base *ev_base, int _fd); |
104 void transport_fd_init (struct transport_fd *fd, struct event_base *ev_base, int _fd); |
119 * Enable the specified events, any of { TRANSPORT_READ, TRANSPORT_WRITE }. |
119 * Enable the specified events, any of { TRANSPORT_READ, TRANSPORT_WRITE }. |
120 */ |
120 */ |
121 err_t transport_fd_enable (struct transport_fd *fd, short mask); |
121 err_t transport_fd_enable (struct transport_fd *fd, short mask); |
122 |
122 |
123 /** |
123 /** |
124 * Disable the specifid events, any of { TRANSPORT_READ, TRANSPORT_WRITE }. |
124 * Disable the specified events, any of { TRANSPORT_READ, TRANSPORT_WRITE }. |
125 */ |
125 */ |
126 err_t transport_fd_disable (struct transport_fd *fd, short mask); |
126 err_t transport_fd_disable (struct transport_fd *fd, short mask); |
127 |
127 |
128 /** |
128 /** |
129 * Set the enable/disable state of our events to the given mask. |
129 * Set the enable/disable state of our events to the given mask. |
148 * enabled before, they are not enabled anymore. |
148 * enabled before, they are not enabled anymore. |
149 */ |
149 */ |
150 err_t transport_fd_set (struct transport_fd *fd, int _fd); |
150 err_t transport_fd_set (struct transport_fd *fd, int _fd); |
151 |
151 |
152 /** |
152 /** |
153 * Invoke the transport_callbacks based on the given mask of libevent EV_* bits |
|
154 */ |
|
155 void transport_fd_invoke (struct transport_fd *fd, short what); |
|
156 |
|
157 /** |
|
158 * Close an opened fd, releasing all resources within our state. |
153 * Close an opened fd, releasing all resources within our state. |
159 */ |
154 */ |
160 err_t transport_fd_close (struct transport_fd *fd); |
155 err_t transport_fd_close (struct transport_fd *fd); |
161 |
156 |
162 /** |
157 /** |
163 * Destroy the fd immediately. |
158 * Destroy the fd immediately. |
|
159 * |
|
160 * This logs a warning if the close() fails. |
|
161 * |
|
162 * XXX: this may actually block, I think? SO_LINGER? |
164 */ |
163 */ |
165 void transport_fd_destroy (struct transport_fd *fd); |
164 void transport_fd_destroy (struct transport_fd *fd); |
166 |
165 |
167 #endif |
166 #endif |