[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-ha-dev
Subject:    Re: [Linux-ha-dev] (1) potential alignment problem (2) shmctl problem
From:       Alan Robertson <alanr () unix ! sh>
Date:       2001-05-21 17:40:31
[Download RAW message or body]

David Lee wrote:
> 
> Compilation of heartbeat/heartbeat.c gives many warnings.  One of these
> is:
> 
>    .../heartbeat.c: In function `init_procinfo':
>    .../heartbeat.c:456: warning: cast increases required alignment of target type
> 
> The following patch seems to address it, on Solaris at least.  (Obviously,
> please check, re-check, etc. both for sense and for other OSes):
> 
> ============== snip ============
> *** heartbeat.c.orig    Mon May 21 16:40:34 2001
> --- heartbeat.c Mon May 21 16:54:52 2001
> ***************
> *** 439,445 ****
>   init_procinfo()
>   {
>         int     ipcid;
> !       char *  shm;
>         (void)_heartbeat_c_Id;
>         (void)_heartbeat_h_Id;
>         (void)_ha_msg_h_Id;

My guess is that redeclaring shm is a better fix...
> --- 439,445 ----
>   init_procinfo()
>   {
>         int     ipcid;
> !       struct pstat_shm *      shm;
>         (void)_heartbeat_c_Id;
>         (void)_heartbeat_h_Id;
>         (void)_ha_msg_h_Id;
> ***************
> *** 453,459 ****
>                 return;
>         }
>         if (shm) {
> !               procinfo = (struct pstat_shm*) shm;
>                 memset(shm, 0, PAGE_SIZE);
>         }
> 
> --- 453,459 ----
>                 return;
>         }
>         if (shm) {
> !               procinfo = shm;
>                 memset(shm, 0, PAGE_SIZE);
>         }
> 
> ============== snip ============
> 
> But my eye was then caught by a comment in the source code immediately
> following this:
> 
>         /*
>          * Go ahead and "remove" our shared memory now...
>          *
>          * This is cool because the manual says:
>          *
>          *      IPC_RMID    is used to mark the segment as destroyed. It
>          *      will actually be destroyed after the last detach.
>          */
> 
> So I checked the Solaris man page for shmctl:
> 
>      IPC_RMID
>            Remove the shared memory identifier specified by shmid
>            from  the system and destroy the shared memory segment
>            and data structure associated with  it.  This  command
>            can  be  executed only by a process that has an effec-
>            tive user ID equal to that of super-user,  or  to  the
>            value  of  shm_perm.cuid  or  shm_perm.uid in the data
>            structure associated with shmid.
> 
>      [... Some time later on man page ... ]
> 
>      Shared memory segments must be explicitly removed after  the
>      last reference to them has been removed.
> 
> I confess to having no experience whatsoever of programming shmctl().
> But this seems different from the "cool" version on Linux of which the
> code currently seems to take advantage.
> 
> The quotation above seems common to SunOS 5.3 (ancient) and 5.8 (modern)
> so I presume is common to all version in between...
> 
> Is there a problem lurking in wait to ambush me when I start running
> things...?

Don't worry.  If it really behaves the way you think it does, it won't
lurk...  It'll hit you right away ;-)

	-- Alan Robertson
	   alanr@unix.sh
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev@lists.community.tummy.com
http://lists.community.tummy.com/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic