~minos-archive/minos/connman

« back to all changes in this revision

Viewing changes to vpn/vpn-provider.c

  • Committer: Javier Lopez
  • Date: 2015-08-31 21:00:17 UTC
  • Revision ID: git-v1:082d67c050639ca3b4122ee3abb4b6edd41432d1
automatic sync 01-09-2015:00:00

Show diffs side-by-side

added added

removed removed

Lines of Context:
501
501
        return NULL;
502
502
}
503
503
 
 
504
static DBusMessage *do_connect2(DBusConnection *conn, DBusMessage *msg,
 
505
                                                                void *data)
 
506
{
 
507
        return do_connect(conn, msg, data);
 
508
}
 
509
 
504
510
static DBusMessage *do_disconnect(DBusConnection *conn, DBusMessage *msg,
505
511
                                                                void *data)
506
512
{
527
533
                        GDBUS_ARGS({ "name", "s" }), NULL,
528
534
                        clear_property) },
529
535
        { GDBUS_ASYNC_METHOD("Connect", NULL, NULL, do_connect) },
 
536
        { GDBUS_ASYNC_METHOD("Connect2",
 
537
                        GDBUS_ARGS({ "dbus_sender", "s" }),
 
538
                        NULL, do_connect2) },
530
539
        { GDBUS_METHOD("Disconnect", NULL, NULL, do_disconnect) },
531
540
        { },
532
541
};
549
558
                provider->host_ip = g_strdupv(results);
550
559
 
551
560
        vpn_provider_unref(provider);
 
561
 
 
562
        /* Remove the resolver here so that it will not be left
 
563
         * hanging around and cause double free in unregister_provider()
 
564
         */
 
565
        g_resolv_unref(provider->resolv);
 
566
        provider->resolv = NULL;
552
567
}
553
568
 
554
569
static void provider_resolv_host_addr(struct vpn_provider *provider)
1081
1096
        DBG("provider %p", provider);
1082
1097
 
1083
1098
        if (provider->driver && provider->driver->connect) {
 
1099
                const char *dbus_sender = dbus_message_get_sender(msg);
 
1100
 
1084
1101
                dbus_message_ref(msg);
 
1102
 
 
1103
                if (dbus_message_has_signature(msg,
 
1104
                                                DBUS_TYPE_STRING_AS_STRING)) {
 
1105
                        const char *sender = NULL;
 
1106
 
 
1107
                        dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING,
 
1108
                                        &sender, DBUS_TYPE_INVALID);
 
1109
                        if (sender && sender[0])
 
1110
                                dbus_sender = sender;
 
1111
                }
 
1112
 
1085
1113
                err = provider->driver->connect(provider, connect_cb,
1086
 
                                                dbus_message_get_sender(msg),
1087
 
                                                msg);
 
1114
                                                dbus_sender, msg);
1088
1115
        } else
1089
1116
                return -EOPNOTSUPP;
1090
1117
 
1560
1587
                break;
1561
1588
        }
1562
1589
 
 
1590
        if (provider->driver && provider->driver->set_state)
 
1591
                provider->driver->set_state(provider, provider->state);
 
1592
 
1563
1593
        return 0;
1564
1594
}
1565
1595
 
1605
1635
 
1606
1636
        connection_unregister(provider);
1607
1637
 
 
1638
        /* If the provider has any DNS resolver queries pending,
 
1639
         * they need to be cleared here because the unref will not
 
1640
         * be able to do that (because the provider_resolv_host_addr()
 
1641
         * has increased the ref count by 1). This is quite rare as
 
1642
         * normally the resolving either returns a value or has a
 
1643
         * timeout which clears the memory. Typically resolv_result() will
 
1644
         * unref the provider but in this case that call has not yet
 
1645
         * happened.
 
1646
         */
 
1647
        if (provider->resolv)
 
1648
                vpn_provider_unref(provider);
 
1649
 
1608
1650
        vpn_provider_unref(provider);
1609
1651
}
1610
1652