diff --git a/checkin_notes b/checkin_notes
index 97c3e10478..08a3c6f186 100644
--- a/checkin_notes
+++ b/checkin_notes
@@ -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
diff --git a/client/app_start.C b/client/app_start.C
index c04beefea8..8373d0b0e9 100644
--- a/client/app_start.C
+++ b/client/app_start.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) {
diff --git a/doc/boinc_news.php b/doc/boinc_news.php
index f9a6c4e407..71fefcf773 100644
--- a/doc/boinc_news.php
+++ b/doc/boinc_news.php
@@ -1,6 +1,11 @@
$project_news = array(
+array("May 9, 2008",
+ "BOINC volunteer Werner Klein is
+ interviewed
+ in Sternengucker.org (German)."
+),
array("May 9, 2008",
"The BOINC FAQ Service
is now available in Spanish and French
diff --git a/doc/links.php b/doc/links.php
index f2250ef924..da16283c62 100644
--- a/doc/links.php
+++ b/doc/links.php
@@ -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"),
diff --git a/lib/shmem.C b/lib/shmem.C
index 678ef97747..7ba6c6ddcc 100644
--- a/lib/shmem.C
+++ b/lib/shmem.C
@@ -53,6 +53,7 @@ extern "C" int debug_printf(const char *fmt, ...);
#include
#include
#include
+
// 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) {
@@ -96,10 +100,10 @@ HANDLE create_shmem(LPCTSTR seg_name, int size, void** pp, bool disable_mapview)
} else {
// Create a well-known SID for the Everyone group.
if(!AllocateAndInitializeSid(&SIDAuthWorld, 1,
- SECURITY_WORLD_RID,
- 0, 0, 0, 0, 0, 0, 0,
- &pEveryoneSID))
- {
+ SECURITY_WORLD_RID,
+ 0, 0, 0, 0, 0, 0, 0,
+ &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;
}