Add open_data_buffer()/close_data_buffer() (was get_data_buffer()) methods

Bug #1229821 reported by Alex Yurchenko on 2013-09-24
This bug affects 1 person
Affects Status Importance Assigned to Milestone
wsrep API
Alex Yurchenko

Bug Description

Currently (v24) we have the following call to pass the data to provider:

wsrep_status_t (*append_data)(wsrep_t* wsrep,
                                  wsrep_ws_handle_t* ws_handle,
                                  const struct wsrep_buf* data,
                                  size_t count,
                                  enum wsrep_data_type type,
                                  wsrep_bool_t copy);

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_buffer)(wsrep_t* wsrep,
                                  wsrep_ws_handle_t* ws_handle,
                                  size_t buf_size,
                                  enum wsrep_data_type type,
                                  void** buf);

Which would provide the application with a buffer to copy data to.

Alex Yurchenko (ayurchen) wrote :

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

summary: - Add get_data_buffer() call
+ Add open_data_buffer()/close_data_buffer() (was get_data_buffer())
+ method
summary: Add open_data_buffer()/close_data_buffer() (was get_data_buffer())
- method
+ methods
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers