Hi,

On Thu, 2015-01-08 at 11:26 -0500, Hannu Mallat wrote:
> Don't wait for a reply from supplicant for D-Bus calls which don't
> have a callback function for processing the reply.
> ---
>  gsupplicant/dbus.c | 23 ++++++++++++++++-------
>  1 file changed, 16 insertions(+), 7 deletions(-)
> 
> diff --git a/gsupplicant/dbus.c b/gsupplicant/dbus.c
> index 2957979..d241fe9 100644
> --- a/gsupplicant/dbus.c
> +++ b/gsupplicant/dbus.c
> @@ -497,16 +497,10 @@ int supplicant_dbus_method_call(const char *path,
>       if (!path || !interface || !method)
>               return -EINVAL;
>  
> -     method_call = g_try_new0(struct method_call_data, 1);
> -     if (!method_call)
> -             return -ENOMEM;
> -
>       message = dbus_message_new_method_call(SUPPLICANT_SERVICE, path,
>                                                       interface, method);
> -     if (!message) {
> -             g_free(method_call);
> +     if (!message)
>               return -ENOMEM;
> -     }
>  
>       dbus_message_set_auto_start(message, FALSE);
>  
> @@ -514,6 +508,21 @@ int supplicant_dbus_method_call(const char *path,
>       if (setup)
>               setup(&iter, user_data);
>  
> +     /* No need to wait for reply if there's no reply function */
> +     if (!function) {
> +             int r = dbus_connection_send(connection, message, NULL)
> +                     ? 0
> +                     : -EIO;
> +             dbus_message_unref(message);
> +             return r;
> +     }

This construct is a bit hairy. Why don't we just set 'result' and 'goto
cleanup' if there is no function set?

> +
> +     method_call = g_try_new0(struct method_call_data, 1);
> +     if (!method_call) {
> +             dbus_message_unref(message);
> +             return -ENOMEM;
> +     }
> +
>       if (!dbus_connection_send_with_reply(connection, message,
>                                               &call, TIMEOUT)) {
>               dbus_message_unref(message);

Cheers,

        Patrik


_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman

Reply via email to