Add the lock protected version of __kdbus_domain_user_account(). It will check if the domain is still active before linking users.
Signed-off-by: Djalal Harouni <tix...@opendz.org> --- domain.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/domain.c b/domain.c index a321f31..86fde55 100644 --- a/domain.c +++ b/domain.c @@ -451,6 +451,30 @@ int __kdbus_domain_user_account(struct kdbus_domain *domain, } /** + * kdbus_domain_user_account() - account a kdbus_domain_user object + * into the specified domain + * @domain: The domain of the user + * @user The kdbus_domain_user object of the user + * + * Returns 0 on success. In case of memory allocation failure return + * -ENOMEM, or -ESHUTDOWN if the domain was disconnected. + */ +int kdbus_domain_user_account(struct kdbus_domain *domain, + struct kdbus_domain_user *user) +{ + int ret = -ESHUTDOWN; + + mutex_lock(&domain->lock); + + if (!domain->disconnected) + ret = __kdbus_domain_user_account(domain, user); + + mutex_unlock(&domain->lock); + + return ret; +} + +/** * kdbus_domain_user_find_or_new() - get a kdbus_domain_user object in a domain * @domain: The domain * @uid: The uid of the user; INVALID_UID for an anonymous -- 1.9.3 _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel