2002-03-04 Robert Collins <rbtcollins@hotmail.com>
* cygserver_shm.cc (client_request_shm::serve): Implement SHM_DETACH. * shm.cc (shmdt): Implement.
This commit is contained in:
parent
67be0adb71
commit
038c71f10c
@ -290,6 +290,26 @@ client_request_shm::serve (transport_layer_base * conn, process_cache * cache)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Someone detached */
|
||||||
|
if (parameters.in.type == SHM_DETACH)
|
||||||
|
{
|
||||||
|
shmnode *tempnode = shm_head;
|
||||||
|
while (tempnode)
|
||||||
|
{
|
||||||
|
if (tempnode->shm_id == parameters.in.shm_id)
|
||||||
|
{
|
||||||
|
InterlockedDecrement (&tempnode->shmds->shm_nattch);
|
||||||
|
header.error_code = 0;
|
||||||
|
CloseHandle (token_handle);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
tempnode = tempnode->next;
|
||||||
|
}
|
||||||
|
header.error_code = EINVAL;
|
||||||
|
CloseHandle (token_handle);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Someone wants the ID removed. */
|
/* Someone wants the ID removed. */
|
||||||
if (parameters.in.type == SHM_DEL)
|
if (parameters.in.type == SHM_DEL)
|
||||||
{
|
{
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2002-03-04 Robert Collins <rbtcollins@hotmail.com>
|
||||||
|
|
||||||
|
* cygserver_shm.cc (client_request_shm::serve): Implement SHM_DETACH.
|
||||||
|
* shm.cc (shmdt): Implement.
|
||||||
|
|
||||||
2002-03-04 Robert Collins <rbtcollins@hotmail.com>
|
2002-03-04 Robert Collins <rbtcollins@hotmail.com>
|
||||||
|
|
||||||
* cygserver_shm.cc: Run indent.
|
* cygserver_shm.cc: Run indent.
|
||||||
|
@ -290,6 +290,26 @@ client_request_shm::serve (transport_layer_base * conn, process_cache * cache)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Someone detached */
|
||||||
|
if (parameters.in.type == SHM_DETACH)
|
||||||
|
{
|
||||||
|
shmnode *tempnode = shm_head;
|
||||||
|
while (tempnode)
|
||||||
|
{
|
||||||
|
if (tempnode->shm_id == parameters.in.shm_id)
|
||||||
|
{
|
||||||
|
InterlockedDecrement (&tempnode->shmds->shm_nattch);
|
||||||
|
header.error_code = 0;
|
||||||
|
CloseHandle (token_handle);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
tempnode = tempnode->next;
|
||||||
|
}
|
||||||
|
header.error_code = EINVAL;
|
||||||
|
CloseHandle (token_handle);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Someone wants the ID removed. */
|
/* Someone wants the ID removed. */
|
||||||
if (parameters.in.type == SHM_DEL)
|
if (parameters.in.type == SHM_DEL)
|
||||||
{
|
{
|
||||||
|
@ -305,8 +305,37 @@ shmdt (const void *shmaddr)
|
|||||||
/* this should be "rare" so a hefty search is ok. If this is common, then we
|
/* this should be "rare" so a hefty search is ok. If this is common, then we
|
||||||
* should alter the data structs to allow more optimisation
|
* should alter the data structs to allow more optimisation
|
||||||
*/
|
*/
|
||||||
set_errno (ENOTSUP);
|
shmnode *tempnode = shm_head;
|
||||||
return -1;
|
_shmattach *attachnode;
|
||||||
|
while (tempnode)
|
||||||
|
{
|
||||||
|
// FIXME: Race potential
|
||||||
|
attachnode = tempnode->attachhead;
|
||||||
|
while (attachnode && attachnode->data != shmaddr)
|
||||||
|
attachnode = attachnode->next;
|
||||||
|
if (attachnode)
|
||||||
|
break;
|
||||||
|
tempnode = tempnode->next;
|
||||||
|
}
|
||||||
|
if (!tempnode)
|
||||||
|
{
|
||||||
|
// dt cannot be called by an app that hasn't alreadu at'd
|
||||||
|
set_errno (EINVAL);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
UnmapViewOfFile (attachnode->data);
|
||||||
|
/* tell the daemon we have attached */
|
||||||
|
client_request_shm *req =
|
||||||
|
new client_request_shm (SHM_DETACH, tempnode->shm_id);
|
||||||
|
int rc;
|
||||||
|
if ((rc = cygserver_request (req)))
|
||||||
|
{
|
||||||
|
debug_printf ("failed to tell deaemon that we have detached\n");
|
||||||
|
}
|
||||||
|
delete req;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME: who is allowed to perform STAT?
|
//FIXME: who is allowed to perform STAT?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user