Local sockets: Local stream sockets had problem of double releasing pipes (both server and client attempt release), which causes wrong pipe pair being closed in multi-client case. Solve by adding per connection instance ID to pipe names. From Jussi Kivilinna (2015-05-12).

This commit is contained in:
Gregory Nutt
2015-05-12 07:47:32 -06:00
parent 3c1af2feed
commit 0f5c35260b
5 changed files with 47 additions and 4 deletions
+21
View File
@@ -59,6 +59,26 @@
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: local_generate_instance_id
****************************************************************************/
static int32_t local_generate_instance_id(void)
{
static int32_t g_next_instance_id = 0;
int32_t id;
/* Called from local_connect with net_lock held. */
id = g_next_instance_id++;
if (g_next_instance_id < 0)
{
g_next_instance_id = 0;
}
return id;
}
/****************************************************************************
* Name: _local_semtake() and _local_semgive()
*
@@ -286,6 +306,7 @@ int psock_local_connect(FAR struct socket *psock,
client->lc_proto = conn->lc_proto;
strncpy(client->lc_path, unaddr->sun_path, UNIX_PATH_MAX-1);
client->lc_path[UNIX_PATH_MAX-1] = '\0';
client->lc_instance_id = local_generate_instance_id();
/* The client is now bound to an address */