Add open_data_buffer()/close_data_buffer() (was get_data_buffer()) methods
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
wsrep API |
New
|
Undecided
|
Alex Yurchenko |
Bug Description
Currently (v24) we have the following call to pass the data to provider:
wsrep_status_t (*append_
This assumes that the caller already has the data in a memory buffer. However this is not always possible (or convenient, e.g. interface to data is read()/write() via file descriptor). To cover such cases and minimize the need for memory copying, provide the following call:
wsrep_status_t (*get_data_
Which would provide the application with a buffer to copy data to.
The proposal in the bug description implies that from the provider POV the whole buffer will be used. This is not always the case, i.e. it is not always possible to predict exactly how big buffer may be needed, like in the case of IO calls (read(), recv(), etc.). An alternative approach would involve explicit closing of buffer. E.g.
wsrep_status_t (*open_ data_buffer) (wsrep_ t* wsrep,
wsrep_ws_ handle_ t* ws_handle,
size_t buf_size, // this is the requested buffer size
enum wsrep_data_type type,
void** buf);
wsrep_status_t (*close_ data_buffer) (wsrep_ t* wsrep,
wsrep_ ws_handle_ t* ws_handle,
const void* buf,
size_ t buf_size); // this time we pass the real size of data in the buffer