GNOME Bugzilla – Bug 738259
GDBusInterfaceVTable: clarify memory handling for the method() virtual function
Last modified: 2014-10-28 17:59:00 UTC
There are two consistent interpretations that could be taken for memory handling of the 'invocation' parameter passed to the method_call() virtual function of GDBusInterfaceVTable - A reference is passed (transfer full) to the method_call() virtual function, and that reference is then passed (transfer full) to the return_value/error functions on GDBusMethodInvocation. - An internal reference is retained from the point where method_call() is called until the return_value/error function is called. Since the return_value/error functions were already marked (transfer full), we use the first interpretation, annotate the invocation parameter of method call as (transfer full) and describe this in the documentation, along with the idea that you are always supposed to call one of the return_value/error functions. See bug 738122 for the leak this caused in GJS.
Created attachment 288168 [details] [review] GDBusInterfaceVTable: clarify memory handling for the method() virtual function
Review of attachment 288168 [details] [review]: As much as I'd love to revert this nonsense, we're probably stuck at this point in time. Thanks for the fix and clarification -- feel free to commit with the minor tweak mentioned. ::: gio/gdbusconnection.h @@ +347,3 @@ + * function is transferred to your handler; you must then call one of the + * methods of #GDBusMethodInvocation to return a reply (possibly empty), + * or an error. These functions also take ownership of the passed- Maybe worth adding a mention that it's possible to do this some time after the method call has returned (ie: async handling).
Pushed with some added language in the documentation that you can call the return function immediately or later. Attachment 288168 [details] pushed as 66fc112 - GDBusInterfaceVTable: clarify memory handling for the method() virtual function