[systemd-devel] [PATCH] names: Acquiring name by activator connection logic fixed

Daniel Mack daniel at zonque.org
Thu Feb 20 04:48:04 PST 2014


On 02/20/2014 12:33 PM, Michal Eljasiewicz wrote:
> This fix allows to register activator connection when
> normal connection already exists for that name.
> Also, when activator connection registers for a second name
> (different than first one) name lookup will
> result in no entry found and checking for multiple names
> will not occur. So checking needs to be done earlier.
> 
> Signed-off-by: Michal Eljasiewicz <m.eljasiewic at samsung.com>

Makes sense. Applied, thanks!


Daniel


> ---
>  names.c | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/names.c b/names.c
> index c43960a..22ead9f 100644
> --- a/names.c
> +++ b/names.c
> @@ -399,6 +399,13 @@ int kdbus_name_acquire(struct kdbus_name_registry *reg,
>  
>  	mutex_lock(&conn->bus->lock);
>  	mutex_lock(&reg->entries_lock);
> +
> +	/* an activator can only own a single name */
> +	if ((conn->flags & KDBUS_HELLO_ACTIVATOR) && conn->names > 0) {
> +		ret = -EALREADY;
> +		goto exit_unlock;
> +	}
> +
>  	e = __kdbus_name_lookup(reg, hash, name);
>  	if (e) {
>  		/* connection already owns that name */
> @@ -407,9 +414,10 @@ int kdbus_name_acquire(struct kdbus_name_registry *reg,
>  			goto exit_unlock;
>  		}
>  
> -		/* an activator can only own a single name */
> -		if (conn->flags & KDBUS_HELLO_ACTIVATOR) {
> -			ret = -EALREADY;
> +		/* activator registers for name that is already owned */
> +		if (conn->flags & KDBUS_HELLO_ACTIVATOR &&
> +		    e->activator == NULL) {
> +			e->activator = kdbus_conn_ref(conn);
>  			goto exit_unlock;
>  		}
>  
> 



More information about the systemd-devel mailing list