2002-03-04 Robert Collins <rbtcollins@hotmail.com>
* cygserver_shm.cc: Run indent. (deleted_head): New global for storing shm id's pending deletion. (client_request_shm::serve): Return ENOSYS for invalid request types. Implement SHM_DEL - delete a shm id. * cygserver_shm.h (SHM_DEL): New type value. * shm.cc (delete_inprocess_shmds): New function, does what it's name implies. (shmctl): Implement shm_rmid control type.
This commit is contained in:
parent
74c3173ade
commit
67be0adb71
|
@ -70,7 +70,8 @@ getsystemallocgranularity ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
client_request_shm::client_request_shm ():client_request (CYGSERVER_REQUEST_SHM_GET, sizeof (parameters))
|
client_request_shm::client_request_shm ():client_request (CYGSERVER_REQUEST_SHM_GET,
|
||||||
|
sizeof (parameters))
|
||||||
{
|
{
|
||||||
buffer = (char *) ¶meters;
|
buffer = (char *) ¶meters;
|
||||||
}
|
}
|
||||||
|
@ -80,10 +81,13 @@ client_request_shm::client_request_shm ():client_request (CYGSERVER_REQUEST_SHM_
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
extern "C" void *
|
extern
|
||||||
|
"C" void *
|
||||||
shmat (int shmid, const void *shmaddr, int parameters.in.shmflg)
|
shmat (int shmid, const void *shmaddr, int parameters.in.shmflg)
|
||||||
{
|
{
|
||||||
class shmid_ds *shm = (class shmid_ds *) shmid; //FIXME: verifyable object test
|
class shmid_ds *
|
||||||
|
shm = (class shmid_ds *)
|
||||||
|
shmid; //FIXME: verifyable object test
|
||||||
|
|
||||||
if (shmaddr)
|
if (shmaddr)
|
||||||
{
|
{
|
||||||
|
@ -92,7 +96,9 @@ shmat (int shmid, const void *shmaddr, int parameters.in.shmflg)
|
||||||
return (void *) -1;
|
return (void *) -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *rv = MapViewOfFile (shm->attachmap,
|
void *
|
||||||
|
rv =
|
||||||
|
MapViewOfFile (shm->attachmap,
|
||||||
|
|
||||||
|
|
||||||
(parameters.in.shmflg & SHM_RDONLY) ?
|
(parameters.in.shmflg & SHM_RDONLY) ?
|
||||||
|
@ -111,7 +117,10 @@ shmat (int shmid, const void *shmaddr, int parameters.in.shmflg)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
InterlockedIncrement (&shm->shm_nattch);
|
InterlockedIncrement (&shm->shm_nattch);
|
||||||
_shmattach *attachnode = new _shmattach;
|
_shmattach *
|
||||||
|
attachnode =
|
||||||
|
new
|
||||||
|
_shmattach;
|
||||||
|
|
||||||
attachnode->data = rv;
|
attachnode->data = rv;
|
||||||
attachnode->next =
|
attachnode->next =
|
||||||
|
@ -136,7 +145,8 @@ shmat (int shmid, const void *shmaddr, int parameters.in.shmflg)
|
||||||
/* FIXME: on NT we should check everything against the SD. On 95 we just emulate.
|
/* FIXME: on NT we should check everything against the SD. On 95 we just emulate.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern GENERIC_MAPPING access_mapping;
|
extern GENERIC_MAPPING
|
||||||
|
access_mapping;
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
check_and_dup_handle (HANDLE from_process, HANDLE to_process,
|
check_and_dup_handle (HANDLE from_process, HANDLE to_process,
|
||||||
|
@ -146,14 +156,22 @@ check_and_dup_handle (HANDLE from_process, HANDLE to_process,
|
||||||
HANDLE * to_handle_ptr, BOOL bInheritHandle);
|
HANDLE * to_handle_ptr, BOOL bInheritHandle);
|
||||||
|
|
||||||
//FIXME: where should this live
|
//FIXME: where should this live
|
||||||
static shmnode *shm_head = NULL;
|
static shmnode *
|
||||||
|
shm_head =
|
||||||
|
NULL;
|
||||||
|
//FIXME: ditto.
|
||||||
|
static shmnode *
|
||||||
|
deleted_head = NULL;
|
||||||
/* must be long for InterlockedIncrement */
|
/* must be long for InterlockedIncrement */
|
||||||
static long new_id = 0;
|
static long
|
||||||
static long new_private_key = 0;
|
new_id =
|
||||||
|
0;
|
||||||
|
static long
|
||||||
|
new_private_key =
|
||||||
|
0;
|
||||||
|
|
||||||
void
|
void
|
||||||
client_request_shm::serve (transport_layer_base * conn,
|
client_request_shm::serve (transport_layer_base * conn, process_cache * cache)
|
||||||
process_cache * cache)
|
|
||||||
{
|
{
|
||||||
// DWORD sd_size = 4096;
|
// DWORD sd_size = 4096;
|
||||||
// char sd_buf[4096];
|
// char sd_buf[4096];
|
||||||
|
@ -272,8 +290,37 @@ client_request_shm::serve (transport_layer_base * conn,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* it's a original request from the users */
|
/* Someone wants the ID removed. */
|
||||||
|
if (parameters.in.type == SHM_DEL)
|
||||||
|
{
|
||||||
|
shmnode **tempnode = &shm_head;
|
||||||
|
while (*tempnode)
|
||||||
|
{
|
||||||
|
if ((*tempnode)->shm_id == parameters.in.shm_id)
|
||||||
|
{
|
||||||
|
// unlink from the accessible node list
|
||||||
|
shmnode *temp2 = *tempnode;
|
||||||
|
*tempnode = temp2->next;
|
||||||
|
// link into the deleted list
|
||||||
|
temp2->next = deleted_head;
|
||||||
|
deleted_head = temp2;
|
||||||
|
|
||||||
|
// FIXME: when/where do we delete the handles?
|
||||||
|
|
||||||
|
header.error_code = 0;
|
||||||
|
CloseHandle (token_handle);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
tempnode = &(*tempnode)->next;
|
||||||
|
}
|
||||||
|
header.error_code = EINVAL;
|
||||||
|
CloseHandle (token_handle);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (parameters.in.type == SHM_CREATE)
|
||||||
|
{
|
||||||
/* FIXME: enter the checking for existing keys mutex. This mutex _must_ be system wide
|
/* FIXME: enter the checking for existing keys mutex. This mutex _must_ be system wide
|
||||||
* to prevent races on shmget.
|
* to prevent races on shmget.
|
||||||
*/
|
*/
|
||||||
|
@ -297,7 +344,8 @@ client_request_shm::serve (transport_layer_base * conn,
|
||||||
shmname = stringbuf;
|
shmname = stringbuf;
|
||||||
snprintf (stringbuf1, 29, "CYGWINSHMD0x%0qx", parameters.in.key);
|
snprintf (stringbuf1, 29, "CYGWINSHMD0x%0qx", parameters.in.key);
|
||||||
shmaname = stringbuf1;
|
shmaname = stringbuf1;
|
||||||
debug_printf ("system id strings are \n%s\n%s\n", shmname, shmaname);
|
debug_printf ("system id strings are \n%s\n%s\n", shmname,
|
||||||
|
shmaname);
|
||||||
debug_printf ("key input value is 0x%0qx\n", parameters.in.key);
|
debug_printf ("key input value is 0x%0qx\n", parameters.in.key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,10 +400,9 @@ client_request_shm::serve (transport_layer_base * conn,
|
||||||
* let them attempt the open.
|
* let them attempt the open.
|
||||||
*/
|
*/
|
||||||
parameters.out.shm_id = tempnode->shm_id;
|
parameters.out.shm_id = tempnode->shm_id;
|
||||||
if (check_and_dup_handle (GetCurrentProcess (), from_process_handle,
|
if (check_and_dup_handle
|
||||||
token_handle,
|
(GetCurrentProcess (), from_process_handle, token_handle,
|
||||||
DUPLICATE_SAME_ACCESS,
|
DUPLICATE_SAME_ACCESS, tempnode->filemap,
|
||||||
tempnode->filemap,
|
|
||||||
¶meters.out.filemap, TRUE) != 0)
|
¶meters.out.filemap, TRUE) != 0)
|
||||||
{
|
{
|
||||||
printf ("error duplicating filemap handle (%lu)\n",
|
printf ("error duplicating filemap handle (%lu)\n",
|
||||||
|
@ -365,10 +412,9 @@ client_request_shm::serve (transport_layer_base * conn,
|
||||||
CloseHandle (token_handle);
|
CloseHandle (token_handle);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (check_and_dup_handle (GetCurrentProcess (), from_process_handle,
|
if (check_and_dup_handle
|
||||||
token_handle,
|
(GetCurrentProcess (), from_process_handle, token_handle,
|
||||||
DUPLICATE_SAME_ACCESS,
|
DUPLICATE_SAME_ACCESS, tempnode->attachmap,
|
||||||
tempnode->attachmap,
|
|
||||||
¶meters.out.attachmap, TRUE) != 0)
|
¶meters.out.attachmap, TRUE) != 0)
|
||||||
{
|
{
|
||||||
printf ("error duplicating attachmap handle (%lu)\n",
|
printf ("error duplicating attachmap handle (%lu)\n",
|
||||||
|
@ -403,7 +449,8 @@ client_request_shm::serve (transport_layer_base * conn,
|
||||||
if (filemap == NULL)
|
if (filemap == NULL)
|
||||||
{
|
{
|
||||||
/* We failed to open the filemapping ? */
|
/* We failed to open the filemapping ? */
|
||||||
system_printf ("failed to open file mapping: %lu\n", GetLastError ());
|
system_printf ("failed to open file mapping: %lu\n",
|
||||||
|
GetLastError ());
|
||||||
// free the mutex
|
// free the mutex
|
||||||
// we can assume that it exists, and that it was an access problem.
|
// we can assume that it exists, and that it was an access problem.
|
||||||
header.error_code = EACCES;
|
header.error_code = EACCES;
|
||||||
|
@ -528,7 +575,8 @@ client_request_shm::serve (transport_layer_base * conn,
|
||||||
tempnode->filemap, ¶meters.out.filemap,
|
tempnode->filemap, ¶meters.out.filemap,
|
||||||
TRUE) != 0)
|
TRUE) != 0)
|
||||||
{
|
{
|
||||||
printf ("error duplicating filemap handle (%lu)\n", GetLastError ());
|
printf ("error duplicating filemap handle (%lu)\n",
|
||||||
|
GetLastError ());
|
||||||
header.error_code = EACCES;
|
header.error_code = EACCES;
|
||||||
CloseHandle (token_handle);
|
CloseHandle (token_handle);
|
||||||
/* mutex et al */
|
/* mutex et al */
|
||||||
|
@ -537,10 +585,11 @@ client_request_shm::serve (transport_layer_base * conn,
|
||||||
if (check_and_dup_handle (GetCurrentProcess (), from_process_handle,
|
if (check_and_dup_handle (GetCurrentProcess (), from_process_handle,
|
||||||
token_handle,
|
token_handle,
|
||||||
DUPLICATE_SAME_ACCESS,
|
DUPLICATE_SAME_ACCESS,
|
||||||
tempnode->attachmap, ¶meters.out.attachmap,
|
tempnode->attachmap,
|
||||||
TRUE) != 0)
|
¶meters.out.attachmap, TRUE) != 0)
|
||||||
{
|
{
|
||||||
printf ("error duplicating attachmap handle (%lu)\n", GetLastError ());
|
printf ("error duplicating attachmap handle (%lu)\n",
|
||||||
|
GetLastError ());
|
||||||
header.error_code = EACCES;
|
header.error_code = EACCES;
|
||||||
CloseHandle (from_process_handle);
|
CloseHandle (from_process_handle);
|
||||||
CloseHandle (token_handle);
|
CloseHandle (token_handle);
|
||||||
|
@ -548,5 +597,13 @@ client_request_shm::serve (transport_layer_base * conn,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CloseHandle (token_handle);
|
CloseHandle (token_handle);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
header.error_code = ENOSYS;
|
||||||
|
CloseHandle (token_handle);
|
||||||
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ details. */
|
||||||
#define SHM_REATTACH 1
|
#define SHM_REATTACH 1
|
||||||
#define SHM_ATTACH 2
|
#define SHM_ATTACH 2
|
||||||
#define SHM_DETACH 3
|
#define SHM_DETACH 3
|
||||||
|
#define SHM_DEL 4
|
||||||
|
|
||||||
|
|
||||||
class client_request_shm : public client_request
|
class client_request_shm : public client_request
|
||||||
|
|
|
@ -1,3 +1,13 @@
|
||||||
|
2002-03-04 Robert Collins <rbtcollins@hotmail.com>
|
||||||
|
|
||||||
|
* cygserver_shm.cc: Run indent.
|
||||||
|
(deleted_head): New global for storing shm id's pending deletion.
|
||||||
|
(client_request_shm::serve): Return ENOSYS for invalid request types.
|
||||||
|
Implement SHM_DEL - delete a shm id.
|
||||||
|
* cygserver_shm.h (SHM_DEL): New type value.
|
||||||
|
* shm.cc (delete_inprocess_shmds): New function, does what it's name implies.
|
||||||
|
(shmctl): Implement shm_rmid control type.
|
||||||
|
|
||||||
2002-03-04 Robert Collins <rbtcollins@hotmail.com>
|
2002-03-04 Robert Collins <rbtcollins@hotmail.com>
|
||||||
|
|
||||||
* Makefile.in (install): Remove install-bin to allow make install to work.
|
* Makefile.in (install): Remove install-bin to allow make install to work.
|
||||||
|
|
|
@ -70,7 +70,8 @@ getsystemallocgranularity ()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
client_request_shm::client_request_shm ():client_request (CYGSERVER_REQUEST_SHM_GET, sizeof (parameters))
|
client_request_shm::client_request_shm ():client_request (CYGSERVER_REQUEST_SHM_GET,
|
||||||
|
sizeof (parameters))
|
||||||
{
|
{
|
||||||
buffer = (char *) ¶meters;
|
buffer = (char *) ¶meters;
|
||||||
}
|
}
|
||||||
|
@ -80,10 +81,13 @@ client_request_shm::client_request_shm ():client_request (CYGSERVER_REQUEST_SHM_
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
extern "C" void *
|
extern
|
||||||
|
"C" void *
|
||||||
shmat (int shmid, const void *shmaddr, int parameters.in.shmflg)
|
shmat (int shmid, const void *shmaddr, int parameters.in.shmflg)
|
||||||
{
|
{
|
||||||
class shmid_ds *shm = (class shmid_ds *) shmid; //FIXME: verifyable object test
|
class shmid_ds *
|
||||||
|
shm = (class shmid_ds *)
|
||||||
|
shmid; //FIXME: verifyable object test
|
||||||
|
|
||||||
if (shmaddr)
|
if (shmaddr)
|
||||||
{
|
{
|
||||||
|
@ -92,7 +96,9 @@ shmat (int shmid, const void *shmaddr, int parameters.in.shmflg)
|
||||||
return (void *) -1;
|
return (void *) -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *rv = MapViewOfFile (shm->attachmap,
|
void *
|
||||||
|
rv =
|
||||||
|
MapViewOfFile (shm->attachmap,
|
||||||
|
|
||||||
|
|
||||||
(parameters.in.shmflg & SHM_RDONLY) ?
|
(parameters.in.shmflg & SHM_RDONLY) ?
|
||||||
|
@ -111,7 +117,10 @@ shmat (int shmid, const void *shmaddr, int parameters.in.shmflg)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
InterlockedIncrement (&shm->shm_nattch);
|
InterlockedIncrement (&shm->shm_nattch);
|
||||||
_shmattach *attachnode = new _shmattach;
|
_shmattach *
|
||||||
|
attachnode =
|
||||||
|
new
|
||||||
|
_shmattach;
|
||||||
|
|
||||||
attachnode->data = rv;
|
attachnode->data = rv;
|
||||||
attachnode->next =
|
attachnode->next =
|
||||||
|
@ -136,7 +145,8 @@ shmat (int shmid, const void *shmaddr, int parameters.in.shmflg)
|
||||||
/* FIXME: on NT we should check everything against the SD. On 95 we just emulate.
|
/* FIXME: on NT we should check everything against the SD. On 95 we just emulate.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern GENERIC_MAPPING access_mapping;
|
extern GENERIC_MAPPING
|
||||||
|
access_mapping;
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
check_and_dup_handle (HANDLE from_process, HANDLE to_process,
|
check_and_dup_handle (HANDLE from_process, HANDLE to_process,
|
||||||
|
@ -146,14 +156,22 @@ check_and_dup_handle (HANDLE from_process, HANDLE to_process,
|
||||||
HANDLE * to_handle_ptr, BOOL bInheritHandle);
|
HANDLE * to_handle_ptr, BOOL bInheritHandle);
|
||||||
|
|
||||||
//FIXME: where should this live
|
//FIXME: where should this live
|
||||||
static shmnode *shm_head = NULL;
|
static shmnode *
|
||||||
|
shm_head =
|
||||||
|
NULL;
|
||||||
|
//FIXME: ditto.
|
||||||
|
static shmnode *
|
||||||
|
deleted_head = NULL;
|
||||||
/* must be long for InterlockedIncrement */
|
/* must be long for InterlockedIncrement */
|
||||||
static long new_id = 0;
|
static long
|
||||||
static long new_private_key = 0;
|
new_id =
|
||||||
|
0;
|
||||||
|
static long
|
||||||
|
new_private_key =
|
||||||
|
0;
|
||||||
|
|
||||||
void
|
void
|
||||||
client_request_shm::serve (transport_layer_base * conn,
|
client_request_shm::serve (transport_layer_base * conn, process_cache * cache)
|
||||||
process_cache * cache)
|
|
||||||
{
|
{
|
||||||
// DWORD sd_size = 4096;
|
// DWORD sd_size = 4096;
|
||||||
// char sd_buf[4096];
|
// char sd_buf[4096];
|
||||||
|
@ -272,8 +290,37 @@ client_request_shm::serve (transport_layer_base * conn,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* it's a original request from the users */
|
/* Someone wants the ID removed. */
|
||||||
|
if (parameters.in.type == SHM_DEL)
|
||||||
|
{
|
||||||
|
shmnode **tempnode = &shm_head;
|
||||||
|
while (*tempnode)
|
||||||
|
{
|
||||||
|
if ((*tempnode)->shm_id == parameters.in.shm_id)
|
||||||
|
{
|
||||||
|
// unlink from the accessible node list
|
||||||
|
shmnode *temp2 = *tempnode;
|
||||||
|
*tempnode = temp2->next;
|
||||||
|
// link into the deleted list
|
||||||
|
temp2->next = deleted_head;
|
||||||
|
deleted_head = temp2;
|
||||||
|
|
||||||
|
// FIXME: when/where do we delete the handles?
|
||||||
|
|
||||||
|
header.error_code = 0;
|
||||||
|
CloseHandle (token_handle);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
tempnode = &(*tempnode)->next;
|
||||||
|
}
|
||||||
|
header.error_code = EINVAL;
|
||||||
|
CloseHandle (token_handle);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (parameters.in.type == SHM_CREATE)
|
||||||
|
{
|
||||||
/* FIXME: enter the checking for existing keys mutex. This mutex _must_ be system wide
|
/* FIXME: enter the checking for existing keys mutex. This mutex _must_ be system wide
|
||||||
* to prevent races on shmget.
|
* to prevent races on shmget.
|
||||||
*/
|
*/
|
||||||
|
@ -297,7 +344,8 @@ client_request_shm::serve (transport_layer_base * conn,
|
||||||
shmname = stringbuf;
|
shmname = stringbuf;
|
||||||
snprintf (stringbuf1, 29, "CYGWINSHMD0x%0qx", parameters.in.key);
|
snprintf (stringbuf1, 29, "CYGWINSHMD0x%0qx", parameters.in.key);
|
||||||
shmaname = stringbuf1;
|
shmaname = stringbuf1;
|
||||||
debug_printf ("system id strings are \n%s\n%s\n", shmname, shmaname);
|
debug_printf ("system id strings are \n%s\n%s\n", shmname,
|
||||||
|
shmaname);
|
||||||
debug_printf ("key input value is 0x%0qx\n", parameters.in.key);
|
debug_printf ("key input value is 0x%0qx\n", parameters.in.key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,10 +400,9 @@ client_request_shm::serve (transport_layer_base * conn,
|
||||||
* let them attempt the open.
|
* let them attempt the open.
|
||||||
*/
|
*/
|
||||||
parameters.out.shm_id = tempnode->shm_id;
|
parameters.out.shm_id = tempnode->shm_id;
|
||||||
if (check_and_dup_handle (GetCurrentProcess (), from_process_handle,
|
if (check_and_dup_handle
|
||||||
token_handle,
|
(GetCurrentProcess (), from_process_handle, token_handle,
|
||||||
DUPLICATE_SAME_ACCESS,
|
DUPLICATE_SAME_ACCESS, tempnode->filemap,
|
||||||
tempnode->filemap,
|
|
||||||
¶meters.out.filemap, TRUE) != 0)
|
¶meters.out.filemap, TRUE) != 0)
|
||||||
{
|
{
|
||||||
printf ("error duplicating filemap handle (%lu)\n",
|
printf ("error duplicating filemap handle (%lu)\n",
|
||||||
|
@ -365,10 +412,9 @@ client_request_shm::serve (transport_layer_base * conn,
|
||||||
CloseHandle (token_handle);
|
CloseHandle (token_handle);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (check_and_dup_handle (GetCurrentProcess (), from_process_handle,
|
if (check_and_dup_handle
|
||||||
token_handle,
|
(GetCurrentProcess (), from_process_handle, token_handle,
|
||||||
DUPLICATE_SAME_ACCESS,
|
DUPLICATE_SAME_ACCESS, tempnode->attachmap,
|
||||||
tempnode->attachmap,
|
|
||||||
¶meters.out.attachmap, TRUE) != 0)
|
¶meters.out.attachmap, TRUE) != 0)
|
||||||
{
|
{
|
||||||
printf ("error duplicating attachmap handle (%lu)\n",
|
printf ("error duplicating attachmap handle (%lu)\n",
|
||||||
|
@ -403,7 +449,8 @@ client_request_shm::serve (transport_layer_base * conn,
|
||||||
if (filemap == NULL)
|
if (filemap == NULL)
|
||||||
{
|
{
|
||||||
/* We failed to open the filemapping ? */
|
/* We failed to open the filemapping ? */
|
||||||
system_printf ("failed to open file mapping: %lu\n", GetLastError ());
|
system_printf ("failed to open file mapping: %lu\n",
|
||||||
|
GetLastError ());
|
||||||
// free the mutex
|
// free the mutex
|
||||||
// we can assume that it exists, and that it was an access problem.
|
// we can assume that it exists, and that it was an access problem.
|
||||||
header.error_code = EACCES;
|
header.error_code = EACCES;
|
||||||
|
@ -528,7 +575,8 @@ client_request_shm::serve (transport_layer_base * conn,
|
||||||
tempnode->filemap, ¶meters.out.filemap,
|
tempnode->filemap, ¶meters.out.filemap,
|
||||||
TRUE) != 0)
|
TRUE) != 0)
|
||||||
{
|
{
|
||||||
printf ("error duplicating filemap handle (%lu)\n", GetLastError ());
|
printf ("error duplicating filemap handle (%lu)\n",
|
||||||
|
GetLastError ());
|
||||||
header.error_code = EACCES;
|
header.error_code = EACCES;
|
||||||
CloseHandle (token_handle);
|
CloseHandle (token_handle);
|
||||||
/* mutex et al */
|
/* mutex et al */
|
||||||
|
@ -537,10 +585,11 @@ client_request_shm::serve (transport_layer_base * conn,
|
||||||
if (check_and_dup_handle (GetCurrentProcess (), from_process_handle,
|
if (check_and_dup_handle (GetCurrentProcess (), from_process_handle,
|
||||||
token_handle,
|
token_handle,
|
||||||
DUPLICATE_SAME_ACCESS,
|
DUPLICATE_SAME_ACCESS,
|
||||||
tempnode->attachmap, ¶meters.out.attachmap,
|
tempnode->attachmap,
|
||||||
TRUE) != 0)
|
¶meters.out.attachmap, TRUE) != 0)
|
||||||
{
|
{
|
||||||
printf ("error duplicating attachmap handle (%lu)\n", GetLastError ());
|
printf ("error duplicating attachmap handle (%lu)\n",
|
||||||
|
GetLastError ());
|
||||||
header.error_code = EACCES;
|
header.error_code = EACCES;
|
||||||
CloseHandle (from_process_handle);
|
CloseHandle (from_process_handle);
|
||||||
CloseHandle (token_handle);
|
CloseHandle (token_handle);
|
||||||
|
@ -548,5 +597,13 @@ client_request_shm::serve (transport_layer_base * conn,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CloseHandle (token_handle);
|
CloseHandle (token_handle);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
header.error_code = ENOSYS;
|
||||||
|
CloseHandle (token_handle);
|
||||||
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ details. */
|
||||||
#define SHM_REATTACH 1
|
#define SHM_REATTACH 1
|
||||||
#define SHM_ATTACH 2
|
#define SHM_ATTACH 2
|
||||||
#define SHM_DETACH 3
|
#define SHM_DETACH 3
|
||||||
|
#define SHM_DEL 4
|
||||||
|
|
||||||
|
|
||||||
class client_request_shm : public client_request
|
class client_request_shm : public client_request
|
||||||
|
|
|
@ -134,6 +134,34 @@ build_inprocess_shmds (HANDLE hfilemap, HANDLE hattachmap, key_t key,
|
||||||
return tempnode;
|
return tempnode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
delete_inprocess_shmds (shmnode **nodeptr)
|
||||||
|
{
|
||||||
|
shmnode *node = *nodeptr;
|
||||||
|
|
||||||
|
// remove from the list
|
||||||
|
if (node == shm_head)
|
||||||
|
shm_head = shm_head->next;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shmnode *tempnode = shm_head;
|
||||||
|
while (tempnode && tempnode->next != node)
|
||||||
|
tempnode = tempnode->next;
|
||||||
|
if (tempnode)
|
||||||
|
tempnode->next = node->next;
|
||||||
|
// else log the unexpected !
|
||||||
|
}
|
||||||
|
|
||||||
|
// release the shared data view
|
||||||
|
UnmapViewOfFile (node->shmds);
|
||||||
|
CloseHandle (node->filemap);
|
||||||
|
CloseHandle (node->attachmap);
|
||||||
|
|
||||||
|
// free the memory
|
||||||
|
delete node;
|
||||||
|
nodeptr = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
int __stdcall
|
int __stdcall
|
||||||
fixup_shms_after_fork ()
|
fixup_shms_after_fork ()
|
||||||
{
|
{
|
||||||
|
@ -352,7 +380,6 @@ shmctl (int shmid, int cmd, struct shmid_ds *buf)
|
||||||
* and each process, as they touch this area detaches. eventually only the
|
* and each process, as they touch this area detaches. eventually only the
|
||||||
* daemon has an attach. The daemon gets asked to detach immediately.
|
* daemon has an attach. The daemon gets asked to detach immediately.
|
||||||
*/
|
*/
|
||||||
#if 0
|
|
||||||
//waiting for the daemon to handle terminating process's
|
//waiting for the daemon to handle terminating process's
|
||||||
client_request_shm *req =
|
client_request_shm *req =
|
||||||
new client_request_shm (SHM_DEL, shmid, GetCurrentProcessId ());
|
new client_request_shm (SHM_DEL, shmid, GetCurrentProcessId ());
|
||||||
|
@ -374,7 +401,8 @@ shmctl (int shmid, int cmd, struct shmid_ds *buf)
|
||||||
/* the daemon has deleted it's references */
|
/* the daemon has deleted it's references */
|
||||||
/* now for us */
|
/* now for us */
|
||||||
|
|
||||||
#endif
|
// FIXME: create a destructor
|
||||||
|
delete_inprocess_shmds (&tempnode);
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue