1 #ifndef _LIBCTDB_IO_ELEM_H
2 #define _LIBCTDB_IO_ELEM_H
5 /* Packets are of form: <u32 length><data>. */
7 /* Create a new queue element of at least len bytes (for reading or writing).
8 * Len may be rounded up for alignment. */
9 struct io_elem
*new_io_elem(size_t len
);
11 /* Free a queue element. */
12 void free_io_elem(struct io_elem
*io
);
14 /* If finished, this returns the request header, otherwise NULL. */
15 bool io_elem_finished(const struct io_elem
*io
);
17 /* Reset an io_elem to the start. */
18 void io_elem_reset(struct io_elem
*io
);
20 /* Access to raw data: if len is non-NULL it is filled in. */
21 void *io_elem_data(const struct io_elem
*io
, size_t *len
);
23 /* Initialise the struct ctdb_req_header at the front of the I/O. */
24 void io_elem_init_req_header(struct io_elem
*io
,
29 /* Returns -1 if we hit an error. Otherwise bytes read. */
30 int read_io_elem(int fd
, struct io_elem
*io
);
32 /* Returns -1 if we hit an error. Otherwise bytes written. */
33 int write_io_elem(int fd
, struct io_elem
*io
);
35 /* Queues a received io element for later processing */
36 void io_elem_queue(struct ctdb_connection
*ctdb
, struct io_elem
*io
);
38 /* Removes an element from the queue */
39 void io_elem_dequeue(struct ctdb_connection
*ctdb
, struct io_elem
*io
);
41 #endif /* _LIBCTDB_IO_ELEM_H */