From: Djalal Harouni Date: Wed, 30 Jul 2014 20:11:54 +0000 (+0100) Subject: domain: add kdbus_domain_user_account() X-Git-Tag: upstream/0.20140911.160207utc~75 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4ff47b39b30671ccca96cef951a2af12a02cb7df;p=platform%2Fcore%2Fsystem%2Fkdbus-bus.git domain: add kdbus_domain_user_account() Add kdbus_domain_user_account() to account and link users into a domain. This function will take the domain lock, and it will be used as a replacement for kdbus_domain_user_find_or_new(). Signed-off-by: Djalal Harouni --- diff --git a/domain.c b/domain.c index 11d7439..1e2c3c9 100644 --- a/domain.c +++ b/domain.c @@ -521,6 +521,42 @@ exit_free: return ret; } +/** + * kdbus_domain_user_account() - account a kdbus_domain_user object + * into the specified domain + * @domain: The domain of the user + * @uid: The uid of the user; INVALID_UID for an + * anonymous user like a custom endpoint + * @user Pointer to a reference where the accounted + * domain user will be stored. + * + * Return: 0 on success, negative errno on failure. + * + * On success: if there is a uid matching, then use the already + * accounted kdbus_domain_user, increment its reference counter and + * return it in the 'user' argument. Otherwise, allocate a new one, + * link it into the domain, then return it. + * + * On failure: the 'user' argument is not updated. + * + * This function will first check if the domain was not disconnected. + */ +int kdbus_domain_user_account(struct kdbus_domain *domain, + kuid_t uid, + struct kdbus_domain_user **user) +{ + int ret = -ESHUTDOWN; + + mutex_lock(&domain->lock); + + if (!domain->disconnected) + ret = __kdbus_domain_user_account(domain, uid, 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 diff --git a/domain.h b/domain.h index fd2940b..c81589e 100644 --- a/domain.h +++ b/domain.h @@ -103,6 +103,10 @@ int __kdbus_domain_user_account(struct kdbus_domain *domain, kuid_t uid, struct kdbus_domain_user **user); +int kdbus_domain_user_account(struct kdbus_domain *domain, + kuid_t uid, + struct kdbus_domain_user **user); + struct kdbus_domain_user *kdbus_domain_user_find_or_new(struct kdbus_domain *domain, kuid_t uid); struct kdbus_domain_user *kdbus_domain_user_ref(struct kdbus_domain_user *u);