Title: #152: Add a tevent wrapper around libcurl's asynchronous interface
On Tue, Feb 14, 2017 at 05:57:32AM -0800, Pavel Březina wrote:
Thank you. So far I'm reading `secrets` code trying to figure out
my needs to comment on `curl` implementation. Here are some comments on the `iobuf`
1. `struct sss_iobuf` should be opaque
Done. I previously let the structure transparent so that users can
allocate an iobuf on stack, but it's true that with sssd's async
processing this is only useful in tests.
2. I'm expecting `sss_iobuf_init()` to also allocate `iobuf`
context. How about:
* Creates a new buffer with size @size and maximum capacity @max_capacity and copy
@data to this buffer.
struct sss_iobuf *sss_iobuf_init(TALLOC_CTX *mem_ctx, uint8_t *data, size_t size, size_t
* Creates a new read-only buffer with size @size and copy @data to this buffer.
struct sss_iobuf *sss_iobuf_init_readonly(TALLOC_CTX *mem_ctx, uint8_t *data, size_t
OK, I implemented these two.
* Creates a new empty buffer with initial size @size and maximum capacity
@max_capacity. Buffer is initialized to zeros.
struct sss_iobuf *sss_iobuf_init_empty(TALLOC_CTX *mem_ctx, size_t initial_size, size_t
But I didn't see much reason for this one. Either you want to create an
empty io buffer for writing, or initialize one with data for reading.
Non-empty buffers should memcpy data.
And here are two requirements for using this as a replacement for `sss_packet`:
1. Maximum capacity should not be always enforced, consider treating `capacity == 0` as
unlimited. I will definitely want to replace `sss_packet` at one point and you don't
always know total size there.
OK, added. The buffer doesn't grow indefinitely, but up to SIZE_MAX/2
which should be enough for everybody(TM) without completely eating up
2. Once capacity is unlimited, multiplying the size by factor two indefinitely to gain
enough space to will become dangerous. Can we grow the buffer by small chunks instead? See
`sss_packet_grow` for an example.
Well, it's not dangerous if you intent to grow indefinitely and in most
cases you should specify a reasonable limit anyway (megabytes maybe).
I'm not dead-set on this, I just don't see the issue I guess.
See the full comment at https://github.com/SSSD/sssd/pull/152#issuecomment-280060216