diff --git a/common/JackLockedEngine.h b/common/JackLockedEngine.h index 941cca9a..c2de8512 100644 --- a/common/JackLockedEngine.h +++ b/common/JackLockedEngine.h @@ -30,14 +30,14 @@ namespace Jack #define TRY_CALL \ try { \ - + #define CATCH_EXCEPTION_RETURN \ } catch(std::bad_alloc& e) { \ jack_error("Memory allocation error..."); \ return -1; \ } catch(JackTemporaryException& e) { \ jack_error("JackTemporaryException : now quits..."); \ - kill(JackTools::GetPID(), SIGINT); \ + JackTools::KillServer(); \ return -1; \ } catch (...) { \ jack_error("Unknown error..."); \ @@ -54,7 +54,7 @@ namespace Jack /*! \brief Locked Engine, access to methods is serialized using a mutex. */ - + class SERVER_EXPORT JackLockedEngine : public JackLockAble { private: @@ -205,7 +205,7 @@ class SERVER_EXPORT JackLockedEngine : public JackLockAble return fEngine.PortDisconnect(refnum, src, dst); CATCH_EXCEPTION_RETURN } - + int PortRename(int refnum, jack_port_id_t port, const char* name) { TRY_CALL @@ -263,7 +263,7 @@ class SERVER_EXPORT JackLockedEngine : public JackLockAble fEngine.NotifyFreewheel(onoff); CATCH_ENGINE_EXCEPTION } - + void NotifyFailure(int code, const char* reason) { TRY_CALL @@ -271,7 +271,7 @@ class SERVER_EXPORT JackLockedEngine : public JackLockAble fEngine.NotifyFailure(code, reason); CATCH_ENGINE_EXCEPTION } - + int GetClientPID(const char* name) { TRY_CALL @@ -279,7 +279,7 @@ class SERVER_EXPORT JackLockedEngine : public JackLockAble return fEngine.GetClientPID(name); CATCH_EXCEPTION_RETURN } - + int GetClientRefNum(const char* name) { TRY_CALL @@ -287,7 +287,7 @@ class SERVER_EXPORT JackLockedEngine : public JackLockAble return fEngine.GetClientRefNum(name); CATCH_EXCEPTION_RETURN } - + }; } // end of namespace diff --git a/common/JackTools.cpp b/common/JackTools.cpp index cc8c67c3..f726f152 100644 --- a/common/JackTools.cpp +++ b/common/JackTools.cpp @@ -33,10 +33,19 @@ using namespace std; namespace Jack { + void JackTools::KillServer() + { +#ifdef WIN32 + exit(1); +#else + kill(GetPID(), SIGINT); +#endif + } + #define DEFAULT_TMP_DIR "/tmp" char* jack_tmpdir = (char*)DEFAULT_TMP_DIR; - int JackTools::GetPID() + int JackTools::GetPID() { #ifdef WIN32 return _getpid(); @@ -45,7 +54,7 @@ namespace Jack { #endif } - int JackTools::GetUID() + int JackTools::GetUID() { #ifdef WIN32 return _getpid(); @@ -55,7 +64,7 @@ namespace Jack { #endif } - const char* JackTools::DefaultServerName() + const char* JackTools::DefaultServerName() { const char* server_name; if ((server_name = getenv("JACK_DEFAULT_SERVER")) == NULL) @@ -66,25 +75,25 @@ namespace Jack { /* returns the name of the per-user subdirectory of jack_tmpdir */ #ifdef WIN32 - char* JackTools::UserDir() + char* JackTools::UserDir() { return ""; } - char* JackTools::ServerDir(const char* server_name, char* server_dir) + char* JackTools::ServerDir(const char* server_name, char* server_dir) { return ""; } void JackTools::CleanupFiles(const char* server_name) {} - int JackTools::GetTmpdir() + int JackTools::GetTmpdir() { return 0; } #else - char* JackTools::UserDir() + char* JackTools::UserDir() { static char user_dir[JACK_PATH_MAX + 1] = ""; @@ -101,7 +110,7 @@ namespace Jack { } /* returns the name of the per-server subdirectory of jack_user_dir() */ - char* JackTools::ServerDir(const char* server_name, char* server_dir) + char* JackTools::ServerDir(const char* server_name, char* server_dir) { /* format the path name into the suppled server_dir char array, * assuming that server_dir is at least as large as JACK_PATH_MAX + 1 */ @@ -110,7 +119,7 @@ namespace Jack { return server_dir; } - void JackTools::CleanupFiles(const char* server_name) + void JackTools::CleanupFiles(const char* server_name) { DIR* dir; struct dirent *dirent; @@ -169,7 +178,7 @@ namespace Jack { } } - int JackTools::GetTmpdir() + int JackTools::GetTmpdir() { FILE* in; size_t len; @@ -201,7 +210,7 @@ namespace Jack { } #endif - void JackTools::RewriteName(const char* name, char* new_name) + void JackTools::RewriteName(const char* name, char* new_name) { size_t i; for (i = 0; i < strlen(name); i++) { @@ -212,7 +221,7 @@ namespace Jack { } new_name[i] = '\0'; } - + #ifdef WIN32 void BuildClientPath(char* path_to_so, int path_len, const char* so_name) @@ -251,7 +260,7 @@ void PrintLoadError(const char* so_name) #else -void PrintLoadError(const char* so_name) +void PrintLoadError(const char* so_name) { jack_log("error loading %s err = %s", so_name, dlerror()); } @@ -264,7 +273,7 @@ void BuildClientPath(char* path_to_so, int path_len, const char* so_name) internal_dir = ADDON_DIR; } } - + snprintf(path_to_so, path_len, "%s/%s.so", internal_dir, so_name); } diff --git a/common/JackTools.h b/common/JackTools.h index 820f91ba..abb4e25c 100644 --- a/common/JackTools.h +++ b/common/JackTools.h @@ -55,6 +55,8 @@ namespace Jack static int GetPID(); static int GetUID(); + static void KillServer(); + static char* UserDir(); static char* ServerDir ( const char* server_name, char* server_dir ); static const char* DefaultServerName(); @@ -201,10 +203,10 @@ namespace Jack return 0; } }; - + void BuildClientPath(char* path_to_so, int path_len, const char* so_name); void PrintLoadError(const char* so_name); - + } #endif