[libsoup/websockets-extension-buffer-error] WebSockets: document how extensions should treat buffers in case of error



commit 7850ff7fa61373264382fc4a21f8ea714d3bdf8f
Author: Claudio Saavedra <csaavedra igalia com>
Date:   Fri Aug 30 14:17:11 2019 +0300

    WebSockets: document how extensions should treat buffers in case of error
    
    In case of error while processing an incoming or outgoing message, an
    extension should return NULL as is customary. This way, in case of
    error, the caller doesn't need to worry about having to deal with
    droppign the reference to the return value if non-NULL.
    
    Make this clear in the class documentation. Also remove an unnecessary
    g_bytes_unref() call from the send_message() error handling.

 libsoup/soup-websocket-connection.c | 2 --
 libsoup/soup-websocket-extension.c  | 4 ++--
 2 files changed, 2 insertions(+), 4 deletions(-)
---
diff --git a/libsoup/soup-websocket-connection.c b/libsoup/soup-websocket-connection.c
index cec4de37..b5f1455f 100644
--- a/libsoup/soup-websocket-connection.c
+++ b/libsoup/soup-websocket-connection.c
@@ -1077,8 +1077,6 @@ process_frame (SoupWebsocketConnection *self)
                filtered_bytes = soup_websocket_extension_process_incoming_message (extension, 
self->pv->incoming->data, filtered_bytes, &error);
                if (error) {
                        emit_error_and_close (self, error, FALSE);
-                       g_bytes_unref (filtered_bytes);
-
                        return FALSE;
                }
        }
diff --git a/libsoup/soup-websocket-extension.c b/libsoup/soup-websocket-extension.c
index b04a4fd8..91ae6951 100644
--- a/libsoup/soup-websocket-extension.c
+++ b/libsoup/soup-websocket-extension.c
@@ -159,7 +159,7 @@ soup_websocket_extension_get_response_params (SoupWebsocketExtension *extension)
  *
  * Extensions using reserved bits of the header will change them in @header.
  *
- * Returns: (transfer full): the message payload data
+ * Returns: (transfer full): the message payload data, or %NULL in case of error
  *
  * Since: 2.68
  */
@@ -196,7 +196,7 @@ soup_websocket_extension_process_outgoing_message (SoupWebsocketExtension *exten
  *
  * Extensions using reserved bits of the header will reset them in @header.
  *
- * Returns: (transfer full): the message payload data
+ * Returns: (transfer full): the message payload data, or %NULL in case of error
  *
  * Since: 2.68
  */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]