1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-13 13:18:06 +03:00
samba-mirror/ctdb/libctdb/io_elem.h
Rusty Russell 30f4d01df1 libctdb: uniform callbacks, _recv functions to pull out data.
This is a bit tricky for those cases where we need to do multiple or
zero I/Os (eg. attachdb and readrecordlock), but works well for the
simple cases.

(This used to be ctdb commit ebe4dd724338c156423cfdcc10a75b68c2084cde)
2010-05-24 13:17:36 +09:30

36 lines
1.1 KiB
C

#ifndef _LIBCTDB_IO_ELEM_H
#define _LIBCTDB_IO_ELEM_H
#include <stdbool.h>
/* Packets are of form: <u32 length><data>. */
/* Create a new queue element of at least len bytes (for reading or writing).
* Len may be rounded up for alignment. */
struct io_elem *new_io_elem(size_t len);
/* Free a queue element. */
void free_io_elem(struct io_elem *io);
/* If finished, this returns the request header, otherwise NULL. */
bool io_elem_finished(const struct io_elem *io);
/* Reset an io_elem to the start. */
void io_elem_reset(struct io_elem *io);
/* Access to raw data: if len is non-NULL it is filled in. */
void *io_elem_data(const struct io_elem *io, size_t *len);
/* Initialise the struct ctdb_req_header at the front of the I/O. */
void io_elem_init_req_header(struct io_elem *io,
uint32_t operation,
uint32_t destnode,
uint32_t reqid);
/* Returns -1 if we hit an error. Otherwise bytes read. */
int read_io_elem(int fd, struct io_elem *io);
/* Returns -1 if we hit an error. Otherwise bytes written. */
int write_io_elem(int fd, struct io_elem *io);
#endif /* _LIBCTDB_IO_ELEM_H */