From 83bbba6e1bc42c0d6b72152f2c790d7426bc7cac Mon Sep 17 00:00:00 2001 From: scottc Date: Sun, 28 Jul 2002 11:50:33 +0000 Subject: * cygserver_shm.cc (class server_shmmgr): Remove `cleanup_t' friend declaration. (cleanup_t::cleanup_t): Use the segment's shmid as the key rather than the segment pointer itself. (cleanup_t::segptr): Remove method. (cleanup_t::shmid): New method. (cleanup_t::cleanup): Update for new key value. (server_shmmgr::find (segment_t *)): Remove method. * include/cygwin/cygserver_process.h (cleanup_routine::key): Make method const. --- winsup/cygwin/ChangeLog | 16 ++++++++- winsup/cygwin/cygserver_shm.cc | 46 ++++-------------------- winsup/cygwin/include/cygwin/cygserver_process.h | 2 +- 3 files changed, 23 insertions(+), 41 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 9ae7afc6d0a..0664ce4e9ee 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,16 @@ +2002-07-28 Conrad Scott + + * cygserver_shm.cc (class server_shmmgr): Remove `cleanup_t' + friend declaration. + (cleanup_t::cleanup_t): Use the segment's shmid as the key rather + than the segment pointer itself. + (cleanup_t::segptr): Remove method. + (cleanup_t::shmid): New method. + (cleanup_t::cleanup): Update for new key value. + (server_shmmgr::find (segment_t *)): Remove method. + * include/cygwin/cygserver_process.h (cleanup_routine::key): Make + method const. + 2002-07-27 Conrad Scott * include/cygwin/cygserver_process.h @@ -5,6 +18,7 @@ (cleanup_routine::cleanup_routine): Initialise new field with new argument. (cleanup_routine::operator==): New method. + (cleanup_routine::key): New method. (cleanup_routine::cleanup): Make argument non-const. (process::is_active): New method. (process::remove): Ditto. @@ -25,7 +39,7 @@ (cleanup_t::segptr): New method. (cleanup_t::cleanup): Add error checking and reporting. (server_shmmgr::shmdt): Make argument non-const. - (server_shmmgr::find): New method. + (server_shmmgr::find (segment_t *)): New method. 2002-07-27 Conrad Scott diff --git a/winsup/cygwin/cygserver_shm.cc b/winsup/cygwin/cygserver_shm.cc index 3d0123e1ead..3a36ff45cb6 100755 --- a/winsup/cygwin/cygserver_shm.cc +++ b/winsup/cygwin/cygserver_shm.cc @@ -79,9 +79,6 @@ details. */ class server_shmmgr { - class cleanup_t; - friend class cleanup_t; - private: class attach_t { @@ -147,27 +144,21 @@ private: class cleanup_t : public cleanup_routine { public: - cleanup_t (segment_t *const segptr) - : cleanup_routine (segptr) + cleanup_t (const segment_t *const segptr) + : cleanup_routine (reinterpret_cast(segptr->_shmid)) { assert (key ()); } - segment_t *segptr () { return static_cast(key ()); } + int shmid () const { return reinterpret_cast(key ()); } virtual void cleanup (class process *const client) { - assert (segptr ()); + const int res = shmmgr.shmdt (shmid (), client); - if (!shmmgr.find (segptr ())) - debug_printf ("process cleanup called for non-existent segment"); - else - { - const int res = shmmgr.shmdt (segptr ()->_shmid, client); - - if (res != 0) - debug_printf ("process cleanup failed: %s", strerror (-res)); - } + if (res != 0) + debug_printf ("process cleanup failed [shmid = %d]: %s", + shmid (), strerror (-res)); } }; @@ -208,8 +199,6 @@ private: segment_t *find_by_key (key_t); segment_t *find (int intid, segment_t **previous = NULL); - const segment_t *find (const segment_t *) const; - int new_segment (key_t, size_t, int shmflg, pid_t, uid_t, gid_t); segment_t *new_segment (key_t, size_t, HANDLE); @@ -737,27 +726,6 @@ server_shmmgr::find (const int intid, segment_t **previous) return NULL; } - -/*---------------------------------------------------------------------------* - * server_shmmgr::find () - * - * Used to check that a segptr is still valid. Since it may just be a - * random blob of memory, the routine doesn't try to access any of the - * "object's" fields. - *---------------------------------------------------------------------------*/ - -const server_shmmgr::segment_t * -server_shmmgr::find (const segment_t *segptr) const -{ - assert (segptr); - - for (segment_t *ptr = _segments_head; ptr; ptr = ptr->_next) - if (ptr == segptr) - return segptr; - - return NULL; -} - /*---------------------------------------------------------------------------* * server_shmmgr::new_segment () *---------------------------------------------------------------------------*/ diff --git a/winsup/cygwin/include/cygwin/cygserver_process.h b/winsup/cygwin/include/cygwin/cygserver_process.h index 0706d501e11..13cc133755b 100755 --- a/winsup/cygwin/include/cygwin/cygserver_process.h +++ b/winsup/cygwin/include/cygwin/cygserver_process.h @@ -53,7 +53,7 @@ public: return _key == rhs._key; } - void *key () { return _key; } + void *key () const { return _key; } /* MUST BE SYNCHRONOUS */ virtual void cleanup (class process *) = 0; -- cgit v1.2.1