Mac/Linux/UNIX: V6 client uses shmget() to run V5 applications

svn path=/trunk/boinc/; revision=13667
This commit is contained in:
Charlie Fenton 2007-09-26 10:16:04 +00:00
parent 774091d490
commit b2b3cdeff7
2 changed files with 55 additions and 42 deletions

View File

@ -182,11 +182,13 @@ void ACTIVE_TASK::cleanup_task() {
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);
#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)
@ -201,6 +203,7 @@ void ACTIVE_TASK::cleanup_task() {
app_client_shm.shm = NULL;
gstate.retry_shmem_time = 0;
}
}
if (gstate.exit_after_finish) {
exit(0);

View File

@ -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,7 +585,8 @@ 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
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)) {
@ -589,20 +597,22 @@ int ACTIVE_TASK::start(bool first_time) {
}
}
}
retval = create_shmem(
retval = create_shmem_mmap(
buf, sizeof(SHARED_MEM), (void**)&app_client_shm.shm
);
#else // !defined(USE_FILE_MAPPED_SHMEM)
} else {
// Use shmget() shared memory
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;
}
}
needs_shmem = false;
}
app_client_shm.reset_msgs();