From:	ADVAX::"mcnc!VM1.NoDak.EDU!bill%WAIKATO.AC.NZ"  6-JUL-1990 09:04:01.90
To:	Multiple recipients of list ANU-NEWS <ANU-NEWS@NDSUVM1>
CC:	
Subj:	Correction to Shutdown Code

Received: by ADVAX.DECnet (utk-mail11 v1.5) ; Fri, 6 Jul 90 09:04:51 EDT
Received:  from mcnc by ge-dab.GE.COM (5.61/GE-DAB 1.12) with UUCP
	id AA16013 for everhart; Fri, 6 Jul 90 00:05:19 -0400
Received: from VM1.NoDak.EDU by mcnc.mcnc.org (5.59/MCNC/6-11-90)
	id AA13296; Thu, 5 Jul 90 23:25:52 EDT
Message-Id: <9007060325.AA13296@mcnc.mcnc.org>
Received: from NDSUVM1.BITNET by VM1.NoDak.EDU (IBM VM SMTP R1.2.1MX) with BSMTP id 1224; Thu, 05 Jul 90 22:25:38 CDT
Received: from NDSUVM1.BITNET by NDSUVM1.BITNET (Mailer R2.07) with BSMTP id
 1218; Thu, 05 Jul 90 22:25:37 CDT
Date:         Wed, 4 Jul 90 23:19:52 GMT
Reply-To: mcnc!VM1.NoDak.EDU!bill%WAIKATO.AC.NZ
Sender: ANU-NEWS Discussion <ANU-NEWS@VM1.NoDak.EDU>
From: mcnc!VM1.NoDak.EDU!bill%WAIKATO.AC.NZ
Subject:      Correction to Shutdown Code
To: Multiple recipients of list ANU-NEWS <ANU-NEWS@NDSUVM1>
 
Opps! The updated shutdown code has a slight error (the lock should remain
in Exclusive mode; a convert from EXMODE to EXMODE still writes the lock
value block to the resource's copy. The corrected shutdown module is :
 
---------------------------------------------------------------------------
/* SHUTDOWN.C.
   This program tries to obtain an exclusive mode lock which causes
   blocking ASTs to be delivered to the other programs that have called
   init_lock();
   The program needs to be run with SYSLCK privilege */
 
#define LOCKNAME "NEWS_LOCK"
#include descrip
#include lckdef
 
typedef volatile struct {
   int lksb_l_status;
   int lksb_l_lock_id;
   int lksb_l_value;
} LKSB_TYPE;
 
LKSB_TYPE lksb;
 
main()
{
        int status;
        $DESCRIPTOR( lock_desc, LOCKNAME );
 
        status = sys$enqw( 0, LCK$K_NLMODE, &lksb, LCK$M_SYSTEM,
            &lock_desc, 0, 0, 0, 0, 0, 0 );
        if (!(status & 1)) lib$stop(status);
        status = sys$enqw( 0, LCK$K_EXMODE, &lksb, LCK$M_CONVERT,
            0, 0, 0, 0, 0, 0, 0 );
        if (!(status & 1)) lib$stop(status);
 
        /* send across lock value 99 to indicate shutdown */
        lksb.lksb_l_value = 99;
        status = sys$enqw( 0, LCK$K_EXMODE, &lksb, LCK$M_CONVERT + LCK$M_VALBLK,
            0, 0, 0, 0, 0, 0, 0 );
        if (!(status & 1)) lib$stop(status);
        printf( "Completed\n" );
 
/*      keep EXMODE lock until utility re-started
        sys$hiber();
 */
}
