mirror of https://github.com/BOINC/boinc.git
Mac/Linux/UNIX: V6 client uses shmget() to run V5 applications
svn path=/trunk/boinc/; revision=13667
This commit is contained in:
parent
774091d490
commit
b2b3cdeff7
41
client/app.C
41
client/app.C
|
@ -180,28 +180,31 @@ void ACTIVE_TASK::cleanup_task() {
|
|||
}
|
||||
#else
|
||||
int retval;
|
||||
|
||||
|
||||
if (app_client_shm.shm) {
|
||||
#ifdef USE_FILE_MAPPED_SHMEM
|
||||
retval = detach_shmem(app_client_shm.shm, sizeof(SHARED_MEM));
|
||||
#else
|
||||
retval = detach_shmem(app_client_shm.shm);
|
||||
#endif
|
||||
if (retval) {
|
||||
msg_printf(NULL, MSG_INTERNAL_ERROR,
|
||||
"Couldn't detach shared memory: %s", boincerror(retval)
|
||||
);
|
||||
#ifndef __EMX__
|
||||
if (app_version->api_major_version() >= 6) {
|
||||
retval = detach_shmem_mmap(app_client_shm.shm, sizeof(SHARED_MEM));
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
retval = detach_shmem(app_client_shm.shm);
|
||||
if (retval) {
|
||||
msg_printf(NULL, MSG_INTERNAL_ERROR,
|
||||
"Couldn't detach shared memory: %s", boincerror(retval)
|
||||
);
|
||||
}
|
||||
retval = destroy_shmem(shmem_seg_name);
|
||||
if (retval) {
|
||||
msg_printf(NULL, MSG_INTERNAL_ERROR,
|
||||
"Couldn't destroy shared memory: %s", boincerror(retval)
|
||||
);
|
||||
}
|
||||
app_client_shm.shm = NULL;
|
||||
gstate.retry_shmem_time = 0;
|
||||
}
|
||||
retval = destroy_shmem(shmem_seg_name);
|
||||
if (retval) {
|
||||
msg_printf(NULL, MSG_INTERNAL_ERROR,
|
||||
"Couldn't destroy shared memory: %s", boincerror(retval)
|
||||
);
|
||||
}
|
||||
app_client_shm.shm = NULL;
|
||||
gstate.retry_shmem_time = 0;
|
||||
}
|
||||
|
||||
|
||||
if (gstate.exit_after_finish) {
|
||||
exit(0);
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
#include <libkern/OSByteOrder.h>
|
||||
#endif
|
||||
|
||||
#ifdef USE_FILE_MAPPED_SHMEM
|
||||
#if(!defined (_WIN32) && !defined (__EMX__))
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
|
@ -146,6 +146,13 @@ int ACTIVE_TASK::get_shmem_seg_name() {
|
|||
|
||||
#else
|
||||
char init_data_path[256];
|
||||
#ifndef __EMX__
|
||||
// shmem_seg_name is not used with mmap() shared memory
|
||||
if (app_version->api_major_version() >= 6) {
|
||||
shmem_seg_name = -1;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
sprintf(init_data_path, "%s/%s", slot_dir, INIT_DATA_FILE);
|
||||
|
||||
// ftok() only works if there's a file at the given location
|
||||
|
@ -578,30 +585,33 @@ int ACTIVE_TASK::start(bool first_time) {
|
|||
// Set up core/app shared memory seg if needed
|
||||
//
|
||||
if (!app_client_shm.shm) {
|
||||
#ifdef USE_FILE_MAPPED_SHMEM
|
||||
sprintf(buf, "%s/%s", slot_dir, MMAPPED_FILE_NAME);
|
||||
if (g_use_sandbox) {
|
||||
if (!boinc_file_exists(buf)) {
|
||||
int fd = open(buf, O_RDWR | O_CREAT, 0660);
|
||||
if (fd >= 0) {
|
||||
close (fd);
|
||||
set_to_project_group(buf);
|
||||
if (app_version->api_major_version() >= 6) {
|
||||
// Use mmap() shared memory
|
||||
sprintf(buf, "%s/%s", slot_dir, MMAPPED_FILE_NAME);
|
||||
if (g_use_sandbox) {
|
||||
if (!boinc_file_exists(buf)) {
|
||||
int fd = open(buf, O_RDWR | O_CREAT, 0660);
|
||||
if (fd >= 0) {
|
||||
close (fd);
|
||||
set_to_project_group(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
retval = create_shmem(
|
||||
buf, sizeof(SHARED_MEM), (void**)&app_client_shm.shm
|
||||
);
|
||||
#else // !defined(USE_FILE_MAPPED_SHMEM)
|
||||
retval = create_shmem(
|
||||
shmem_seg_name, sizeof(SHARED_MEM), gstate.boinc_project_gid,
|
||||
(void**)&app_client_shm.shm
|
||||
);
|
||||
#endif // !defined(USE_FILE_MAPPED_SHMEM)
|
||||
if (retval) {
|
||||
needs_shmem = true;
|
||||
destroy_shmem(shmem_seg_name); // Don't leave an orphan shmem segment
|
||||
return retval;
|
||||
retval = create_shmem_mmap(
|
||||
buf, sizeof(SHARED_MEM), (void**)&app_client_shm.shm
|
||||
);
|
||||
} else {
|
||||
// Use shmget() shared memory
|
||||
retval = create_shmem(
|
||||
shmem_seg_name, sizeof(SHARED_MEM), gstate.boinc_project_gid,
|
||||
(void**)&app_client_shm.shm
|
||||
);
|
||||
|
||||
if (retval) {
|
||||
needs_shmem = true;
|
||||
destroy_shmem(shmem_seg_name); // Don't leave an orphan shmem segment
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
needs_shmem = false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue