From 2de5e86aff554c333f51173dfb8f87b3ed20ad51 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Khan Date: Mon, 11 Mar 2024 15:28:35 -0700 Subject: [PATCH] Update docs to clarify `aws_io_message` Cleanup Rules (#633) --- include/aws/io/channel.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/aws/io/channel.h b/include/aws/io/channel.h index aca73d7c6..1f8401f9a 100644 --- a/include/aws/io/channel.h +++ b/include/aws/io/channel.h @@ -54,6 +54,8 @@ struct aws_channel_handler_vtable { /** * Called by the channel when a message is available for processing in the read direction. It is your * responsibility to call aws_mem_release(message->allocator, message); on message when you are finished with it. + * You must only call `aws_mem_release(message->allocator, message);` if the `process_read_message` + * returns AWS_OP_SUCCESS. In case of an error, you must not clean up the message and should just raise the error. * * Also keep in mind that your slot's internal window has been decremented. You'll want to call * aws_channel_slot_increment_read_window() at some point in the future if you want to keep receiving data. @@ -65,6 +67,8 @@ struct aws_channel_handler_vtable { /** * Called by the channel when a message is available for processing in the write direction. It is your * responsibility to call aws_mem_release(message->allocator, message); on message when you are finished with it. + * You must only call `aws_mem_release(message->allocator, message);` if the `process_read_message` + * returns AWS_OP_SUCCESS. In case of an error, you must not clean up the message and should just raise the error. */ int (*process_write_message)( struct aws_channel_handler *handler,