|
|
| version 1.1, 2025/01/19 02:04:04 | version 1.7, 2025/04/13 15:12:21 |
|---|---|
| Line 1 | Line 1 |
| /* | /* |
| * * | * $Id$ |
| * * * | * TP global checkpointing code |
| * * * | |
| * *************** | |
| * * * * * | |
| * * MUMPS * | |
| * * * * * | |
| * *************** | |
| * * * | |
| * * * | |
| * * | |
| * | |
| * tp_check.c | |
| * TP database checkpointing code | |
| * | * |
| * | * |
| * Author: Serena Willis <jpw@coherent-logic.com> | * Author: Serena Willis <snw@coherent-logic.com> |
| * Copyright (C) 1998 MUG Deutschland | * Copyright (C) 1998 MUG Deutschland |
| * Copyright (C) 2022 Coherent Logic Development LLC | * Copyright (C) 2022, 2025 Coherent Logic Development LLC |
| * | * |
| * | * |
| * This file is part of FreeM. | * This file is part of FreeM. |
| Line 35 | Line 23 |
| * You should have received a copy of the GNU Affero Public License | * You should have received a copy of the GNU Affero Public License |
| * along with FreeM. If not, see <https://www.gnu.org/licenses/>. | * along with FreeM. If not, see <https://www.gnu.org/licenses/>. |
| * | * |
| * $Log$ | |
| * Revision 1.7 2025/04/13 15:12:21 snw | |
| * Fix transaction checkpoints on OS/2 [CLOSES #34] | |
| * | |
| * Revision 1.6 2025/04/13 04:22:43 snw | |
| * Fix snprintf calls | |
| * | |
| * Revision 1.5 2025/04/09 19:52:02 snw | |
| * Eliminate as many warnings as possible while building with -Wall | |
| * | |
| * Revision 1.4 2025/03/22 18:43:54 snw | |
| * Make STRLEN 255 chars and add BIGSTR macro for larger buffers | |
| * | |
| * Revision 1.3 2025/03/09 19:50:47 snw | |
| * Second phase of REUSE compliance and header reformat | |
| * | |
| * | |
| * SPDX-FileCopyrightText: (C) 2025 Coherent Logic Development LLC | |
| * SPDX-License-Identifier: AGPL-3.0-or-later | |
| **/ | **/ |
| #include <stdlib.h> | #include <stdlib.h> |
| Line 46 | Line 53 |
| #include "journal.h" | #include "journal.h" |
| #include "fs.h" | #include "fs.h" |
| #if defined(__OS2__) | |
| # include <os2.h> | |
| #endif | |
| short frm_global_exists(char *, char *, char *); | short frm_global_exists(char *, char *, char *); |
| cptab *cptab_head[TP_MAX_NEST]; | cptab *cptab_head[TP_MAX_NEST]; |
| Line 53 cptab *cptab_head[TP_MAX_NEST]; | Line 64 cptab *cptab_head[TP_MAX_NEST]; |
| cptab *cptab_insert(int tlevel, char *global) | cptab *cptab_insert(int tlevel, char *global) |
| { | { |
| cptab *t; | cptab *t; |
| char mode; | |
| short g_exists; | short g_exists; |
| char *gc_ns; | char *gc_ns; |
| char *gc_pth; | char *gc_pth; |
| gc_ns = (char *) malloc (STRLEN * sizeof (char)); | gc_ns = (char *) malloc (STRLEN * sizeof (char)); |
| NULLPTRCHK(gc_ns,"cptab_insert"); | NULLPTRCHK(gc_ns,"cptab_insert"); |
| gc_pth = (char *) malloc (STRLEN * sizeof (char)); | gc_pth = (char *) malloc (PATHLEN * sizeof (char)); |
| NULLPTRCHK(gc_pth,"cptab_insert"); | NULLPTRCHK(gc_pth,"cptab_insert"); |
| for (t = cptab_head[tlevel]; t != NULL; t = t->next) { | for (t = cptab_head[tlevel]; t != NULL; t = t->next) { |
| Line 89 cptab *cptab_insert(int tlevel, char *gl | Line 97 cptab *cptab_insert(int tlevel, char *gl |
| t->file = (char *) malloc (sizeof (char) * (strlen (gc_pth))); | t->file = (char *) malloc (sizeof (char) * (strlen (gc_pth))); |
| NULLPTRCHK(t->file,"cptab_insert"); | NULLPTRCHK(t->file,"cptab_insert"); |
| t->cp_file = (char *) malloc (sizeof (char) * STRLEN); | t->cp_file = (char *) malloc (sizeof (char) * PATHLEN); |
| NULLPTRCHK(t->cp_file,"cptab_insert"); | NULLPTRCHK(t->cp_file,"cptab_insert"); |
| strcpy (t->file, gc_pth); | strcpy (t->file, gc_pth); |
| stcnv_m2c (t->file); | stcnv_m2c (t->file); |
| snprintf (t->cp_file, STRLEN - 1, "%s.%d.%d.chk", t->file, pid, tp_level); | snprintf (t->cp_file, PATHLEN - 1, "%s.%d.%d.chk", t->file, pid, tp_level); |
| free (gc_ns); | free (gc_ns); |
| free (gc_pth); | free (gc_pth); |
| Line 175 void cptab_postcommit(int tlevel) | Line 183 void cptab_postcommit(int tlevel) |
| { | { |
| cptab *t; | cptab *t; |
| /*char *cmd;*/ | /*char *cmd;*/ |
| int rc; | |
| /* | /* |
| cmd = (char *) malloc (STRLEN * sizeof (char)); | cmd = (char *) malloc (STRLEN * sizeof (char)); |
| Line 200 void cptab_postcommit(int tlevel) | Line 207 void cptab_postcommit(int tlevel) |
| short cptab_rollback(int tlevel) | short cptab_rollback(int tlevel) |
| { | { |
| cptab *t; | cptab *t; |
| /*char *cmd;*/ | |
| int rc; | int rc; |
| /* | |
| cmd = (char *) malloc (STRLEN * sizeof (char)); | |
| NULLPTRCHK(cmd,"cptab_rollback"); | |
| */ | |
| for (t = cptab_head[tlevel]; t != NULL; t = t->next) { | for (t = cptab_head[tlevel]; t != NULL; t = t->next) { |
| switch (t->mode) { | switch (t->mode) { |
| case CP_REMOVE: | case CP_REMOVE: |
| unlink (t->file); | unlink (t->file); |
| /* | |
| snprintf (cmd, STRLEN - 1, "/bin/rm -f '%s'", t->file); | |
| rc = system (cmd); | |
| */ | |
| break; | break; |
| case CP_RESTORE: | case CP_RESTORE: |
| /* | #if !defined(__OS2__) |
| snprintf (cmd, STRLEN - 1, "/bin/cp '%s' '%s'", t->cp_file, t->file); | |
| rc = system (cmd); | |
| */ | |
| rc = cp (t->file, t->cp_file); | rc = cp (t->file, t->cp_file); |
| #else | |
| rc = DosCopy (t->cp_file, t->file, 1); | |
| #endif | |
| if (rc != 0) { | if (rc != 0) { |
| cptab_head[tlevel] = NULL; | cptab_head[tlevel] = NULL; |
| /*free (cmd);*/ | /*free (cmd);*/ |
| return FALSE; | return FALSE; |
| } | } |
| /* | |
| snprintf (cmd, STRLEN - 1, "/bin/rm -f %s", t->cp_file); | |
| rc = system (cmd); | |
| */ | |
| unlink (t->cp_file); | unlink (t->cp_file); |
| if (rc != 0) { | if (rc != 0) { |
| cptab_head[tlevel] = NULL; | cptab_head[tlevel] = NULL; |