Browse Source

Merge remote-tracking branch 'upstream/master' into optional-gui

pull/29/head
brummer10 4 years ago
parent
commit
96524d0ece
2 changed files with 21 additions and 5 deletions
  1. +1
    -0
      CHANGELOG
  2. +20
    -5
      src/nsmd.cpp

+ 1
- 0
CHANGELOG View File

@@ -1,4 +1,5 @@
v1.4
ClientId generation now prevent collision with existing IDs.
nsmd command line option --load-session to directly load one (Berkelder, Rik)
Better detection of clients that failed to launch leads to faster session startup (by 5 seconds)
Users get informed by label if an executable is not present on the system or permission denied


+ 20
- 5
src/nsmd.cpp View File

@@ -542,15 +542,30 @@ get_client_by_address ( lo_address addr )


char *
generate_client_id ( Client *c )
generate_client_id ( void )
{
/* Before v1.4 this returned "n" + 4 random upper-case letters, which could lead to collisions.
We changed behaviour to still generate 4 letters, but check for collision with existing IDs.

Loaded client IDs are not checked, just copied from session.nsm because loading happens before
any generation of new clients. Loaded clients are part of further checks of course.

There is a theoretical limit when all 26^4 IDs are in use which will lead to an infinite loop
of generation. We risk to leave this unhandled. */

char id_str[6];

id_str[0] = 'n';
id_str[5] = 0;

for ( int i = 1; i < 5; i++)
id_str[i] = 'A' + (rand() % 25);
while ( true )
{
for ( int i = 1; i < 5; i++ )
id_str[i] = 'A' + (rand() % 25);

if ( get_client_by_id(&client, id_str )==NULL ) // found a free id
break;
}

return strdup(id_str);
}
@@ -671,7 +686,7 @@ launch ( const char *executable, const char *client_id )
if ( client_id )
c->client_id = strdup( client_id );
else
c->client_id = generate_client_id( c );
c->client_id = generate_client_id();

client.push_back( c );
}
@@ -911,7 +926,7 @@ OSC_HANDLER( announce )
{
c = new Client();
c->executable_path = strdup( executable_path );
c->client_id = generate_client_id( c );
c->client_id = generate_client_id();
}
else
expected_client = true;


Loading…
Cancel
Save