mirror of https://github.com/BOINC/boinc.git
*** empty log message ***
svn path=/trunk/boinc/; revision=4162
This commit is contained in:
parent
d3deb5bb0c
commit
7e98b4285f
|
@ -17086,3 +17086,16 @@ Rom 5 Sep 2004
|
|||
- Tag for 4.08 release, all platforms
|
||||
boinc_core_release_4_08
|
||||
|
||||
David 6 Sept 2004
|
||||
- The Windows GUI and CLI versions were using different mechanisms
|
||||
to ensure that only one instance of BOINC is running.
|
||||
Factored this into a function check_unique_instance(),
|
||||
which is used by all versions.
|
||||
|
||||
client/
|
||||
file_names.C,h
|
||||
main.C
|
||||
win/
|
||||
wingui_mainwindow.cpp
|
||||
lib/
|
||||
error_numbers.h
|
||||
|
|
|
@ -121,3 +121,22 @@ void get_account_filename(char* master_url, char* path) {
|
|||
bool is_account_file(char* filename) {
|
||||
return (strstr(filename, "account_") == filename);
|
||||
}
|
||||
|
||||
int check_unique_instance() {
|
||||
#if 1
|
||||
if (lock_file(LOCK_FILE_NAME)) {
|
||||
return ERR_ALREADY_RUNNING;
|
||||
}
|
||||
#else
|
||||
key_t key;
|
||||
char path[256];
|
||||
getcwd(path, 256);
|
||||
retval = get_key(path, 'a', key);
|
||||
if (!retval) retval = create_semaphore(key);
|
||||
if (!retval) retval = lock_semaphore(key);
|
||||
if (retval) {
|
||||
return ERR_ALREADY_RUNNING;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ extern int make_slot_dir(int);
|
|||
extern void get_account_filename(char* master_url, char* path);
|
||||
extern bool is_account_file(char*);
|
||||
extern void escape_project_url(char *in, char* out);
|
||||
extern int check_unique_instance();
|
||||
|
||||
#define MAX_STDERR_FILE_SIZE 1024*1024
|
||||
#define MAX_STDOUT_FILE_SIZE 1024*1024
|
||||
|
|
|
@ -223,26 +223,6 @@ int boinc_main_loop(int argc, char** argv) {
|
|||
double dt;
|
||||
|
||||
setbuf(stdout, 0);
|
||||
#if 1
|
||||
if (lock_file(LOCK_FILE_NAME)) {
|
||||
fprintf(stderr,
|
||||
"Can't lock file - either another copy of BOINC is running,\n"
|
||||
"or this user doesn't have permission to lock the file.\n"
|
||||
);
|
||||
exit(1);
|
||||
}
|
||||
#else
|
||||
key_t key;
|
||||
char path[256];
|
||||
getcwd(path, 256);
|
||||
retval = get_key(path, 'a', key);
|
||||
if (!retval) retval = create_semaphore(key);
|
||||
if (!retval) retval = lock_semaphore(key);
|
||||
if (retval) {
|
||||
fprintf(stderr, "Another copy of BOINC is already running\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
boinc_init_diagnostics(
|
||||
BOINC_DIAG_DUMPCALLSTACKENABLED |
|
||||
|
@ -250,6 +230,12 @@ int boinc_main_loop(int argc, char** argv) {
|
|||
BOINC_DIAG_TRACETOSTDERR
|
||||
);
|
||||
|
||||
retval = check_unique_instance();
|
||||
if (retval) {
|
||||
msg_printf(NULL, MSG_INFO, "Another instance of BOINC is running");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Unix/Linux console controls
|
||||
#ifndef WIN32
|
||||
// Handle quit signals gracefully
|
||||
|
|
|
@ -63,6 +63,13 @@ BOOL CMyApp::InitInstance()
|
|||
MessageBox(NULL, e.what(), "BOINC GUI Diagnostic Error", MB_OK);
|
||||
}
|
||||
|
||||
int retval = check_unique_instance();
|
||||
if (retval) {
|
||||
TRACE(TEXT("Another instance of BOINC is running\n"));
|
||||
UINT nShowMsg = RegisterWindowMessage(SHOW_WIN_MSG);
|
||||
PostMessage(HWND_BROADCAST, nShowMsg, 0, 0);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Initialize WinSock
|
||||
if ( WinsockInitialize() != 0 ) {
|
||||
|
@ -70,15 +77,6 @@ BOOL CMyApp::InitInstance()
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
HANDLE h = CreateMutex(NULL, true, RUN_MUTEX);
|
||||
if ((h==0)|| GetLastError() == ERROR_ALREADY_EXISTS) {
|
||||
TRACE(TEXT("couldn't create mutex; h=%x, e=%d\n"), h, GetLastError());
|
||||
UINT nShowMsg = RegisterWindowMessage(SHOW_WIN_MSG);
|
||||
PostMessage(HWND_BROADCAST, nShowMsg, 0, 0);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
m_pMainWnd = new CMainWindow();
|
||||
TRACE(TEXT("not already running; %d projects\n"), gstate.projects.size());
|
||||
if(gstate.projects.size() == 0) {
|
||||
|
|
|
@ -141,3 +141,4 @@
|
|||
#define ERR_NO_OPTION -191
|
||||
#define ERR_MKDIR -192
|
||||
#define ERR_INVALID_EVENT -193
|
||||
#define ERR_ALREADY_RUNNING -194
|
||||
|
|
Loading…
Reference in New Issue