Browse Source

handle write protected session files and saving clients

tags/v1.6.0
Nils 3 years ago
parent
commit
2ff0b51df2
2 changed files with 26 additions and 8 deletions
  1. +3
    -0
      CHANGELOG
  2. +23
    -8
      src/nsmd.cpp

+ 3
- 0
CHANGELOG View File

@@ -14,7 +14,10 @@ nsmd now follows the XDG Base Directory Specifications:
Lockfiles now each contain the session path, the osc NSM_URL and the nsmd PID
One daemon file for each currently running nsmd is created in $XDG_RUNTIME_DIR/nsm/d/ containing the osc url. This enables discovery of running daemons.
New section in the API documentation for the above.
Handle write-protected session files and related errors on save. They will not crash the daemon anymore.
Fixes and guards against trying to load non-existing sessions and creating new sessions under existing names
Handle various crashes-on-exit and replace them with controlled exits.


## 2022-01-15 1.5.3
Add [jackpatch] to terminal log output of jackpatch.


+ 23
- 8
src/nsmd.cpp View File

@@ -1039,17 +1039,22 @@ OSC_HANDLER( announce )
return 0;
}

void
int
save_session_file ( )
{
char *session_file = NULL;
asprintf( &session_file, "%s/session.nsm", session_path );

FILE *fp = fopen( session_file, "w+" );
FILE *fp = fopen( session_file, "w" );

free( session_file );
if ( fp == NULL ) {
WARNING( "No write access to %s with error: %s.", session_file, strerror( errno ) );
free( session_file );
//No need to fclose because fp is null and was never opened.
return 1; //error
}

/* FIXME: handle errors. */
free( session_file );

for ( std::list<Client*>::iterator i = client.begin();
i != client.end();
@@ -1059,6 +1064,7 @@ save_session_file ( )
}

fclose( fp );
return 0; //all ok
}

Client *
@@ -1190,6 +1196,16 @@ command_all_clients_to_save ( )
{
GUIMSG( "Commanding attached clients to save." );

int save_error = save_session_file();

if ( save_error == 1 ) {
GUIMSG( "...but the session file is write protected. Will not forward save command to clients." );
WARNING( "Aborting client save commands because the session file is write protected" );
return;
}



for ( std::list<Client*>::iterator i = client.begin();
i != client.end();
++i )
@@ -1198,8 +1214,6 @@ command_all_clients_to_save ( )
}

wait_for_replies();

save_session_file();
}
}

@@ -2580,7 +2594,7 @@ wait ( long timeout )
void
handle_signal_clean_exit ( int signal )
{
MESSAGE( "Caught SIGNAL %i. Stopping nsmd.", signal);
WARNING( "Caught SIGNAL %i. Stopping nsmd.", signal);
// We want a clean exit even when things go wrong.
close_session();
free( session_root );
@@ -2793,7 +2807,8 @@ int main(int argc, char *argv[])

if ( osc_server->init( LO_UDP, osc_port ) )
{
FATAL( "Failed to create OSC server." );
WARNING( "Failed to create OSC server. Exiting." );
exit( 1 );
}

char * url = osc_server->url();


Loading…
Cancel
Save