mirror of https://github.com/BOINC/boinc.git
- Client (Windows) change the way core/app shmem segs are created.
Old: get_shmem_seg_name() tries names of the form shm_boinc_N until it finds one for which creating succeeds. Then it detaches (deletes) the segment and records the name. Later, the segment is created again. This creates a race condition if two core clients are running on the same host. It's also kind of silly. New: get_shmem_seg_name() doesn't detach the segment, and we dont have to create it again later. svn path=/trunk/boinc/; revision=15172
This commit is contained in:
parent
b622f64e30
commit
db4164daba
|
@ -3839,3 +3839,20 @@ David May 9 2008
|
|||
sched/
|
||||
sched_send.C
|
||||
server_types.h
|
||||
|
||||
David May 11 2008
|
||||
- Client (Windows) change the way core/app shmem segs are created.
|
||||
Old: get_shmem_seg_name() tries names of the form shm_boinc_N
|
||||
until it finds one for which creating succeeds.
|
||||
Then it detaches (deletes) the segment and records the name.
|
||||
Later, the segment is created again.
|
||||
This creates a race condition if two core clients
|
||||
are running on the same host.
|
||||
It's also kind of silly.
|
||||
New: get_shmem_seg_name() doesn't detach the segment,
|
||||
and we dont have to create it again later.
|
||||
|
||||
client/
|
||||
app_start.C
|
||||
lib/
|
||||
shmem.C
|
||||
|
|
|
@ -79,8 +79,8 @@ using std::vector;
|
|||
|
||||
|
||||
#ifdef _WIN32
|
||||
// Dynamically link to these functions at runtime, otherwise BOINC
|
||||
// cannot run on Win98
|
||||
// Dynamically link to these functions at runtime;
|
||||
// otherwise BOINC cannot run on Win98
|
||||
|
||||
// CreateEnvironmentBlock
|
||||
typedef BOOL (WINAPI *tCEB)(LPVOID *lpEnvironment, HANDLE hToken, BOOL bInherit);
|
||||
|
@ -102,28 +102,24 @@ static void debug_print_argv(char** argv) {
|
|||
}
|
||||
#endif
|
||||
|
||||
// make a unique key for core/app shared memory segment
|
||||
// Make a unique key for core/app shared memory segment.
|
||||
// Windows: also create and attach to the segment.
|
||||
//
|
||||
int ACTIVE_TASK::get_shmem_seg_name() {
|
||||
#ifdef _WIN32
|
||||
int i = 0;
|
||||
char szSharedMemoryName[256];
|
||||
HANDLE hSharedMemoryHandle = 0;
|
||||
int i;
|
||||
char seg_name[256];
|
||||
HANDLE h = 0;
|
||||
|
||||
for (i=0; i<1024; i++) {
|
||||
sprintf(szSharedMemoryName, "%sboinc_%d", SHM_PREFIX, i);
|
||||
hSharedMemoryHandle = create_shmem(szSharedMemoryName, 1024, NULL, true);
|
||||
if (hSharedMemoryHandle) break;
|
||||
sprintf(seg_name, "%sboinc_%d", SHM_PREFIX, i);
|
||||
hSharedMemoryHandle = create_shmem(
|
||||
seg_name, sizeof(SHARED_MEM), (void**)&app_client_shm.shm, false
|
||||
);
|
||||
if (h) break;
|
||||
}
|
||||
|
||||
if (!hSharedMemoryHandle) {
|
||||
return ERR_SHMGET;
|
||||
}
|
||||
detach_shmem(hSharedMemoryHandle, NULL);
|
||||
|
||||
sprintf(szSharedMemoryName, "boinc_%d", i);
|
||||
strcpy(shmem_seg_name, szSharedMemoryName);
|
||||
|
||||
if (!h) return ERR_SHMGET;
|
||||
sprintf(shmem_seg_name, "boinc_%d", i);
|
||||
#else
|
||||
char init_data_path[256];
|
||||
#ifndef __EMX__
|
||||
|
@ -492,19 +488,6 @@ int ACTIVE_TASK::start(bool first_time) {
|
|||
//
|
||||
startup_info.dwFlags = STARTF_FORCEOFFFEEDBACK;
|
||||
|
||||
// create shared mem segment if needed
|
||||
//
|
||||
if (!app_client_shm.shm) {
|
||||
sprintf(buf, "%s%s", SHM_PREFIX, shmem_seg_name);
|
||||
shm_handle = create_shmem(buf, sizeof(SHARED_MEM),
|
||||
(void **)&app_client_shm.shm, false
|
||||
);
|
||||
if (shm_handle == NULL) {
|
||||
strcpy(buf, "Can't create shared memory");
|
||||
retval = ERR_SHMGET;
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
app_client_shm.reset_msgs();
|
||||
|
||||
if (config.run_apps_manually) {
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
<?
|
||||
|
||||
$project_news = array(
|
||||
array("May 9, 2008",
|
||||
"BOINC volunteer Werner Klein is
|
||||
<a href=http://www.sternengucker.org/index.php/artikel/interview-seti-ist-heute-bereits-erfolgreich/>interviewed
|
||||
in Sternengucker.org</a> (German)."
|
||||
),
|
||||
array("May 9, 2008",
|
||||
"The <a href=http://boincfaq.mundayweb.com/>BOINC FAQ Service</a>
|
||||
is now available in Spanish and French
|
||||
|
|
|
@ -243,6 +243,7 @@ language("French", array(
|
|||
));
|
||||
language("German", array(
|
||||
//site("http://www.boinc-gemeinschaft.de/", "BOINC Gemeinschaft"),
|
||||
site("http://www.gridcommunity.de/index.php", "International Grid Community"),
|
||||
site("http://www.swissteam.net/", "SwissTeam.net"),
|
||||
site("http://www.unitedmacs.com/", "United Macs"),
|
||||
site("http://www.rechenkraft.net/", "Rechenkraft"),
|
||||
|
|
34
lib/shmem.C
34
lib/shmem.C
|
@ -53,6 +53,7 @@ extern "C" int debug_printf(const char *fmt, ...);
|
|||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
// MAP_FILE isn't defined on most operating systems, and even then, it
|
||||
// is often defined just for the sake of compatibility. On those that
|
||||
// don't define it, we will....
|
||||
|
@ -70,7 +71,9 @@ extern "C" int debug_printf(const char *fmt, ...);
|
|||
|
||||
#ifdef _WIN32
|
||||
|
||||
HANDLE create_shmem(LPCTSTR seg_name, int size, void** pp, bool disable_mapview) {
|
||||
HANDLE create_shmem(
|
||||
LPCTSTR seg_name, int size, void** pp, bool disable_mapview
|
||||
) {
|
||||
HANDLE hMap = NULL;
|
||||
DWORD dwError = 0;
|
||||
DWORD dwRes = 0;
|
||||
|
@ -83,9 +86,10 @@ HANDLE create_shmem(LPCTSTR seg_name, int size, void** pp, bool disable_mapview)
|
|||
OSVERSIONINFO osvi;
|
||||
char global_seg_name[256];
|
||||
|
||||
// Win9X doesn't like any reference to a security descriptor. So if we
|
||||
// detect that we are running on the Win9X platform pass a NULL value
|
||||
// for it.
|
||||
// Win9X doesn't like any reference to a security descriptor.
|
||||
// So if we detect that we are running on the Win9X platform pass
|
||||
// a NULL value for it.
|
||||
//
|
||||
osvi.dwOSVersionInfoSize = sizeof(osvi);
|
||||
GetVersionEx(&osvi);
|
||||
if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
|
||||
|
@ -98,8 +102,8 @@ HANDLE create_shmem(LPCTSTR seg_name, int size, void** pp, bool disable_mapview)
|
|||
if(!AllocateAndInitializeSid(&SIDAuthWorld, 1,
|
||||
SECURITY_WORLD_RID,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
&pEveryoneSID))
|
||||
{
|
||||
&pEveryoneSID)
|
||||
) {
|
||||
fprintf(stderr, "AllocateAndInitializeSid Error %u\n", GetLastError());
|
||||
goto Cleanup;
|
||||
}
|
||||
|
@ -124,15 +128,15 @@ HANDLE create_shmem(LPCTSTR seg_name, int size, void** pp, bool disable_mapview)
|
|||
|
||||
// Initialize a security descriptor.
|
||||
pSD = (PSECURITY_DESCRIPTOR) LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH);
|
||||
if (NULL == pSD)
|
||||
{
|
||||
if (NULL == pSD) {
|
||||
fprintf(stderr, "LocalAlloc Error %u\n", GetLastError());
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
if (!InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION))
|
||||
{
|
||||
fprintf(stderr, "InitializeSecurityDescriptor Error %u\n", GetLastError());
|
||||
if (!InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION)) {
|
||||
fprintf(stderr, "InitializeSecurityDescriptor Error %u\n",
|
||||
GetLastError()
|
||||
);
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
|
@ -140,9 +144,11 @@ HANDLE create_shmem(LPCTSTR seg_name, int size, void** pp, bool disable_mapview)
|
|||
if (!SetSecurityDescriptorDacl(pSD,
|
||||
TRUE, // bDaclPresent flag
|
||||
pACL,
|
||||
FALSE)) // not a default DACL
|
||||
{
|
||||
fprintf(stderr, "SetSecurityDescriptorDacl Error %u\n", GetLastError());
|
||||
FALSE) // not a default DACL
|
||||
) {
|
||||
fprintf(stderr,
|
||||
"SetSecurityDescriptorDacl Error %u\n", GetLastError()
|
||||
);
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue