diff options
author | rbcollins <rbcollins> | 2001-10-07 21:58:19 +0000 |
---|---|---|
committer | rbcollins <rbcollins> | 2001-10-07 21:58:19 +0000 |
commit | 4f314ae7456a93c8003de818664572a744400bef (patch) | |
tree | 61fe229c9aa2a830995732bc38e2d79e536de46d /winsup/cygwin/cygserver_shm.cc | |
parent | 3b4a9f90f3aa605dfd888147097c37b0c384a56f (diff) | |
download | gdb-4f314ae7456a93c8003de818664572a744400bef.tar.gz |
Mon Oct 8 7:41:00 2001 Robert Collins <rbtcollins@hotmail.com>
* cygserver.cc (server_request::process): Rename client_request_shm_get to
client_request_shm.
* cygserver_process.cc (process_cache::add): Rename to add_task.
Use process_cleanup instead of process_request.
(process_cache::remove_process): New method.
(process::process): Initialize new members.
(process::~process): New member.
(process::cleanup): New method.
(process::add_cleanup_routine): New method.
(process_request::process): Rename to process_cleanup.
Call the process object's cleanup method and then delete it.
(process_process_param::request_loop): Remove the signalling process.
* cygserver_shm.cc: Globally rename client_request_shm_get to client_request_shm.
(client_request_shm_get::serve): Handle attach request counting.
* cygserver_shm.h: Globally rename client_request_shm_get to client_request_shm.
(class shm_cleanup): New class.
* shm.cc: Globally rename client_request_shm_get to client_request_shm.
(client_request_shm::client_request_shm): New constructor for attach requests.
(shmat): Use it.
* include/cygwin/cygserver_process.h (class process_request): Rename to
process_cleanup.
(class cleanup_routine): New class.
(class process): New members and methods to allow calling back when the process
terminates.
Diffstat (limited to 'winsup/cygwin/cygserver_shm.cc')
-rwxr-xr-x | winsup/cygwin/cygserver_shm.cc | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/winsup/cygwin/cygserver_shm.cc b/winsup/cygwin/cygserver_shm.cc index 134f810e6db..c29938bb97c 100755 --- a/winsup/cygwin/cygserver_shm.cc +++ b/winsup/cygwin/cygserver_shm.cc @@ -44,9 +44,9 @@ #include <sys/shm.h> #endif //#include "perprocess.h" -#include "cygserver_shm.h" #include <threaded_queue.h> #include <cygwin/cygserver_process.h> +#include "cygserver_shm.h" // FIXME IS THIS CORRECT /* Implementation notes: We use two shared memory regions per key: @@ -70,7 +70,7 @@ getsystemallocgranularity () } -client_request_shm_get::client_request_shm_get ():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; } @@ -152,7 +152,7 @@ static long new_id = 0; static long new_private_key = 0; void -client_request_shm_get::serve (transport_layer_base * conn, +client_request_shm::serve (transport_layer_base * conn, process_cache * cache) { // DWORD sd_size = 4096; @@ -208,6 +208,7 @@ client_request_shm_get::serve (transport_layer_base * conn, char *shmname = NULL, *shmaname = NULL; char stringbuf[29], stringbuf1[29]; + /* TODO: make this code block a function! */ if (parameters.in.type == SHM_REATTACH) { /* just find and fill out the existing shm_id */ @@ -245,6 +246,32 @@ client_request_shm_get::serve (transport_layer_base * conn, CloseHandle (token_handle); return; } + + /* someone attached */ + /* someone can send shm_id's they don't have and currently we will increment those + * attach counts. If someone wants to fix that, please go ahead. + * The problem is that shm_get has nothing to do with the ability to attach. Attach + * requires a permission check, which we get the OS to do in MapViewOfFile. + */ + if (parameters.in.type == SHM_ATTACH) + { + shmnode *tempnode = shm_head; + while (tempnode) + { + if (tempnode->shm_id == parameters.in.shm_id) + { + InterlockedIncrement (&tempnode->shmds->shm_nattch); + header.error_code = 0; + CloseHandle (token_handle); + return; + } + tempnode = tempnode->next; + } + header.error_code = EINVAL; + CloseHandle (token_handle); + return; + } + /* it's a original request from the users */ /* FIXME: enter the checking for existing keys mutex. This mutex _must_ be system wide |