[systemd-devel] [PATCH] names: return EADDRINUSE if name is owned by a different connection and can't be released

Daniel Mack daniel at zonque.org
Mon Feb 9 22:33:41 PST 2015


On 02/09/2015 10:53 AM, Lukasz Skalski wrote:
> This patch fixes also problem with "ReleaseName" call in
> systemd-bus-proxyd.

Applied, thanks!


> 
> diff --git a/names.c b/names.c
> index 5f57aa3..e85ba45 100644
> --- a/names.c
> +++ b/names.c
> @@ -266,6 +266,7 @@ static int kdbus_name_release(struct kdbus_name_registry *reg,
>  		 * for items for connection.
>  		 */
>  
> +		ret = -EADDRINUSE;
>  		list_for_each_entry_safe(q, tmp, &e->queue_list, entry_entry) {
>  			if (q->conn != conn)
>  				continue;
> diff --git a/test/test-names.c b/test/test-names.c
> index 00c8ba0..66ebb47 100644
> --- a/test/test-names.c
> +++ b/test/test-names.c
> @@ -54,6 +54,7 @@ static int conn_is_name_owner(const struct kdbus_conn *conn,
>  
>  int kdbus_test_name_basic(struct kdbus_test_env *env)
>  {
> +	struct kdbus_conn *conn;
>  	char *name, *dot_name, *invalid_name, *wildcard_name;
>  	int ret;
>  
> @@ -62,6 +63,14 @@ int kdbus_test_name_basic(struct kdbus_test_env *env)
>  	invalid_name = "foo";
>  	wildcard_name = "foo.bla.bl.*";
>  
> +	/* create a 2nd connection */
> +	conn = kdbus_hello(env->buspath, 0, NULL, 0);
> +	ASSERT_RETURN(conn != NULL);
> +
> +	/* acquire name "foo.bar.xxx" name */
> +	ret = kdbus_name_acquire(conn, "foo.bar.xxx", NULL);
> +	ASSERT_RETURN(ret == 0);
> +
>  	/* Name is not valid, must fail */
>  	ret = kdbus_name_acquire(env->conn, dot_name, NULL);
>  	ASSERT_RETURN(ret == -EINVAL);
> @@ -92,7 +101,7 @@ int kdbus_test_name_basic(struct kdbus_test_env *env)
>  
>  	/* check that we can't release a name that we don't own */
>  	ret = kdbus_name_release(env->conn, "foo.bar.xxx");
> -	ASSERT_RETURN(ret == -ESRCH);
> +	ASSERT_RETURN(ret == -EADDRINUSE);
>  
>  	/* Name is not valid, must fail */
>  	ret = kdbus_name_release(env->conn, dot_name);
> @@ -104,6 +113,8 @@ int kdbus_test_name_basic(struct kdbus_test_env *env)
>  	ret = kdbus_name_release(env->conn, wildcard_name);
>  	ASSERT_RETURN(ret == -ESRCH);
>  
> +	kdbus_conn_free(conn);
> +
>  	return TEST_OK;
>  }
>  
> 



More information about the systemd-devel mailing list