Client spamming server hotfix

svn path=/trunk/boinc/; revision=3713
This commit is contained in:
Rom Walton 2004-06-29 05:10:15 +00:00
parent 7c2bed2ee3
commit 5e5b183b41
3 changed files with 27 additions and 1 deletions

View File

@ -14229,3 +14229,12 @@ David 27 June 2004
hostinfo_unix.C
lib/
app_ipc.h
Rom 27 June 2004
- Prevent the reuse of shared memory segments with ones that are already
in use on Windows.
client/
app.C
lib/
shmem.C

View File

@ -243,7 +243,23 @@ int ACTIVE_TASK::write_app_init_file(APP_INIT_DATA& aid) {
// make a unique key for core/app shared memory segment
//
#ifdef _WIN32
sprintf(aid.comm_obj_name, "boinc_%d", slot);
int i = 0;
char szSharedMemoryName[256];
HANDLE hSharedMemoryHandle;
do {
memset(szSharedMemoryName, '\0', sizeof(szSharedMemoryName));
sprintf(szSharedMemoryName, "boinc_%d", slot);
i++;
} while((!(hSharedMemoryHandle = create_shmem(szSharedMemoryName, 1024, NULL))) || (1024 < i));
if (hSharedMemoryHandle)
CloseHandle(hSharedMemoryHandle);
if (1024 < i)
return ERR_SEMOP;
strcpy(aid.comm_obj_name, szSharedMemoryName);
#elif HAVE_SYS_IPC_H
aid.shm_key = ftok(init_data_path, slot);
#else

View File

@ -57,6 +57,7 @@ HANDLE create_shmem(LPCTSTR seg_name, int size, void** pp) {
hSharedMem = CreateFileMapping(INVALID_HANDLE_VALUE, &security,
PAGE_READWRITE, 0, size, seg_name);
if (!hSharedMem) return NULL;
if (hSharedMem && (ERROR_ALREADY_EXISTS == GetLastError())) return NULL;
pMemPtr = MapViewOfFile( hSharedMem, FILE_MAP_ALL_ACCESS, 0, 0, 0 );
*pp = pMemPtr;