1 /****^  ***********************************************************
  2         *                                                         *
  3         * Copyright, (C) Honeywell Bull Inc., 1987                *
  4         *                                                         *
  5         * Copyright, (C) Honeywell Information Systems Inc., 1982 *
  6         *                                                         *
  7         * Copyright (c) 1972 by Massachusetts Institute of        *
  8         * Technology and Honeywell Information Systems, Inc.      *
  9         *                                                         *
 10         *********************************************************** */
 11 
 12 
 13 /* format: style4,delnl,insnl,indattr,ifthen,dclind10 */
 14 commit:
 15      proc (p_journal_control_block_ptr, p_code);
 16 
 17 /* Complete whatever changes are in progress.
 18 
 19    Written  by  Lindsey Spratt 08/06/79
 20    Modified 11/21/79 by C. D. Tavares to commit in forward order instead of reverse.
 21    Modified 02/15/85 by Chris Jones for privileges and clean up.
 22 */
 23 /* Parameter */
 24 
 25 dcl       p_journal_control_block_ptr
 26                                  ptr;
 27 dcl       p_code                 fixed bin (35);
 28 
 29 /* Automatic */
 30 
 31 dcl       privileges_string      bit (36) aligned;
 32 dcl       scratch_area_ptr       ptr;
 33 
 34 /* Based */
 35 
 36 dcl       scratch_area           area (4096) based (scratch_area_ptr);
 37 
 38 /* Controlled */
 39 /* Builtin */
 40 
 41 dcl       null                   builtin;
 42 
 43 dcl       cleanup                condition;
 44 
 45 /* Entry */
 46 
 47 dcl       iox_$control           entry (ptr, char (*), ptr, fixed bin (35));
 48 dcl       iox_$delete_record     entry (ptr, fixed bin (35));
 49 dcl       get_system_free_area_  entry returns (ptr);
 50 dcl       rcprm_registry_util_$turn_off_privs
 51                                  entry (bit (36) aligned);
 52 dcl       rcprm_registry_util_$turn_on_privs
 53                                  entry (bit (36) aligned);
 54 
 55 /* External */
 56 
 57 dcl       error_table_$locked_by_this_process
 58                                  fixed bin (35) ext;
 59 ^L
 60           journal_control_block_ptr = p_journal_control_block_ptr;
 61           scratch_area_ptr = get_system_free_area_ ();
 62 
 63           if journal_control_block.latest_entry_ptr = null then do;
 64                p_code = 0;
 65                return;
 66           end;
 67 
 68           do journal_entry_ptr = journal_control_block.latest_entry_ptr repeat (journal_entry.prev_ptr)
 69                while (journal_entry.prev_ptr ^= null);
 70           end;                                              /* Find the first journal entry */
 71 
 72           rs_info_ptr = null ();
 73           privileges_string = ""b;
 74           on cleanup call clean_up;
 75 
 76           call rcprm_registry_util_$turn_on_privs (privileges_string);
 77 
 78           do while (journal_entry_ptr ^= null);
 79 
 80                goto ENTRY_TYPE (journal_entry.type);
 81 
 82 ENTRY_TYPE (1):                                             /* RS_LOCK */
 83 ENTRY_TYPE (7):                                             /* RS_LOCK_COUNT */
 84 ENTRY_TYPE (8):                                             /* RS_LOCK_CREATE */
 85                alloc rs_info in (scratch_area);
 86                rs_info.version = rs_info_version_2;
 87                rs_info.unlock_sw = "1"b;
 88                rs_info.lock_sw = "0"b;
 89                rs_info.locate_sw = "1"b;
 90                rs_info.descriptor = journal_entry.descriptor;
 91                call iox_$control (journal_control_block.vfile_iocb_ptr, "record_status", rs_info_ptr, p_code);
 92                if p_code ^= 0 & p_code ^= error_table_$locked_by_this_process then do;
 93                     call clean_up;
 94                     return;
 95                end;
 96                free rs_info;
 97 
 98                goto NEXT;
 99 
100 ENTRY_TYPE (2):                                             /* write_record */
101                goto NEXT;
102 
103 ENTRY_TYPE (3):                                             /* delete_record */
104                alloc rs_info in (scratch_area);
105                rs_info.version = rs_info_version_2;
106                rs_info.locate_sw = "1"b;
107                rs_info.descriptor = journal_entry.descriptor;
108 
109                call iox_$control (journal_control_block.vfile_iocb_ptr, "record_status", rs_info_ptr, p_code);
110                if p_code ^= 0 & p_code ^= error_table_$locked_by_this_process then do;
111                     call clean_up;
112                     return;
113                end;
114 
115                free rs_info;
116 
117                call iox_$delete_record (journal_control_block.vfile_iocb_ptr, p_code);
118                if p_code ^= 0 & p_code ^= error_table_$locked_by_this_process then do;
119                     call clean_up;
120                     return;
121                end;
122 
123                goto NEXT;
124 
125 
126 ENTRY_TYPE (4):                                             /* add_key */
127                goto NEXT;
128 
129 
130 ENTRY_TYPE (5):                                             /* delete_key */
131                goto NEXT;
132 
133 
134 ENTRY_TYPE (6):                                             /* RS_COUNT */
135                goto NEXT;
136 
137 NEXT:
138                journal_entry_ptr = journal_entry.next_ptr;
139                if journal_entry_ptr ^= null then
140                     journal_entry.prev_ptr = null;
141           end;
142           call clean_up;
143           return;
144 
145 clean_up:
146      proc;
147 
148           if rs_info_ptr ^= null () then
149                free rs_info;
150           call rcprm_registry_util_$turn_off_privs (privileges_string);
151 
152      end clean_up;
153 ^L
154 %include journal_entry;
155 %include journal_control_block;
156 %include rs_info;
157      end;                                                   /* end commit */