- client: Unix: if can't create client lock file,

report ERR_OPEN rather than ERR_ALREADY_RUNNING
    fixes #970

svn path=/trunk/boinc/; revision=20051
This commit is contained in:
David Anderson 2009-12-31 02:15:26 +00:00
parent e485a2581d
commit fd1d46d17f
5 changed files with 26 additions and 8 deletions

View File

@ -10752,3 +10752,12 @@ David 24 Dec 2009
user/
view_profile.php
create_profile.php
David 30 Dec 2009
- client: Unix: if can't create client lock file,
report ERR_OPEN rather than ERR_ALREADY_RUNNING
fixes #970
lib/
util.cpp
filesys.cpp

View File

@ -208,6 +208,7 @@ function language_form() {
."<option value=es>Espa&ntilde;ol (Spanish)"
."<option value=fr>Fran&ccedil;ais (French)"
."<option value=el>Ελληνικά (Greek)"
."<option value=it>Italiano (Italian)"
."<option value=ja>日本語 (Japanese)"
."<option value=ko>한국어 (Korean)"
//."<option value=lt>Lietuvių (Lithuanian)"

View File

@ -63,6 +63,10 @@ span.section_title{
text-align: center;
}
span.news_title,
span.inboxunread {
font-weight: bold;
}
span.note{
font-weight: normal;

View File

@ -674,10 +674,10 @@ int FILE_LOCK::lock(const char* filename) {
}
struct flock fl;
fl.l_type=F_WRLCK;
fl.l_whence=SEEK_SET;
fl.l_start=0;
fl.l_len=0;
fl.l_type = F_WRLCK;
fl.l_whence = SEEK_SET;
fl.l_start = 0;
fl.l_len = 0;
if (fcntl(fd, F_SETLK, &fl) == -1) {
return ERR_FCNTL;
}

View File

@ -499,7 +499,7 @@ static int get_client_mutex(const char*) {
if (IsWindows2000Compatible()) {
strcpy(buf, "Global\\");
}
strcat( buf, RUN_MUTEX);
strcat(buf, RUN_MUTEX);
HANDLE h = CreateMutexA(NULL, true, buf);
if ((h==0) || (GetLastError() == ERROR_ALREADY_EXISTS)) {
@ -511,8 +511,11 @@ static int get_client_mutex(const char* dir) {
static FILE_LOCK file_lock;
sprintf(path, "%s/%s", dir, LOCK_FILE_NAME);
if (file_lock.lock(path)) {
int retval = file_lock.lock(path);
if (retval == ERR_FCNTL) {
return ERR_ALREADY_RUNNING;
} else if (retval) {
return retval;
}
#endif
return 0;
@ -520,13 +523,14 @@ static int get_client_mutex(const char* dir) {
int wait_client_mutex(const char* dir, double timeout) {
double start = dtime();
int retval = 0;
while (1) {
int retval = get_client_mutex(dir);
retval = get_client_mutex(dir);
if (!retval) return 0;
boinc_sleep(1);
if (dtime() - start > timeout) break;
}
return ERR_ALREADY_RUNNING;
return retval;
}
bool boinc_is_finite(double x) {