![]() |
|
|||
0001 /** 0002 * @brief LMDB support function 0003 * 0004 * @file edbutil.c 0005 */ 0006 /* ----------------------------------------------------------------------------- 0007 * Enduro/X Middleware Platform for Distributed Transaction Processing 0008 * Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved. 0009 * Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved. 0010 * This software is released under one of the following licenses: 0011 * AGPL (with Java and Go exceptions) or Mavimax's license for commercial use. 0012 * See LICENSE file for full text. 0013 * ----------------------------------------------------------------------------- 0014 * AGPL license: 0015 * 0016 * This program is free software; you can redistribute it and/or modify it under 0017 * the terms of the GNU Affero General Public License, version 3 as published 0018 * by the Free Software Foundation; 0019 * 0020 * This program is distributed in the hope that it will be useful, but WITHOUT ANY 0021 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 0022 * PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3 0023 * for more details. 0024 * 0025 * You should have received a copy of the GNU Affero General Public License along 0026 * with this program; if not, write to the Free Software Foundation, Inc., 0027 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 0028 * 0029 * ----------------------------------------------------------------------------- 0030 * A commercial use license is available from Mavimax, Ltd 0031 * contact@mavimax.com 0032 * ----------------------------------------------------------------------------- 0033 */ 0034 0035 /*---------------------------Includes-----------------------------------*/ 0036 #include <stdlib.h> 0037 #include <stdio.h> 0038 #include <ndrstandard.h> 0039 #include <nstdutil.h> 0040 #include <nstd_tls.h> 0041 #include <string.h> 0042 #include <errno.h> 0043 #include <edbutil.h> 0044 #include "thlock.h" 0045 #include "userlog.h" 0046 #include "ndebug.h" 0047 /*---------------------------Externs------------------------------------*/ 0048 /*---------------------------Macros-------------------------------------*/ 0049 /*---------------------------Enums--------------------------------------*/ 0050 /*---------------------------Typedefs-----------------------------------*/ 0051 /*---------------------------Globals------------------------------------*/ 0052 /*---------------------------Statics------------------------------------*/ 0053 /*---------------------------Prototypes---------------------------------*/ 0054 0055 /** 0056 * Unlink MDB files (instead of drop - full kill) 0057 * @param resource LMDB directory 0058 * @param errdet where to print error detail 0059 * @param errdetbufsz error detail buffer size 0060 * @param log_facility log, if set to LOG_FACILITY_UBF, 0061 * @return EXSUCCEED/EXFAIL 0062 */ 0063 expublic int ndrx_mdb_unlink(char *resource, char *errdet, int errdetbufsz, 0064 int log_facility) 0065 { 0066 int ret = EXSUCCEED; 0067 char data_file[PATH_MAX+1]; 0068 char lock_file[PATH_MAX+1]; 0069 0070 snprintf(data_file, sizeof(data_file), "%s/data.edb", resource); 0071 snprintf(lock_file, sizeof(data_file), "%s/lock.edb", resource); 0072 0073 if (LOG_CODE_UBF==log_facility) 0074 { 0075 NDRX_LOG(log_info, "Removing data file: [%s], lock file: [%s]", 0076 data_file, lock_file); 0077 } 0078 else 0079 { 0080 UBF_LOG(log_info, "Removing data file: [%s], lock file: [%s]", 0081 data_file, lock_file); 0082 } 0083 0084 if (EXSUCCEED!=unlink(data_file)) 0085 { 0086 int err = errno; 0087 0088 if (LOG_CODE_UBF==log_facility) 0089 { 0090 UBF_LOG(log_info, "unlink [%s] failed: %s", data_file, strerror(err)); 0091 } 0092 else 0093 { 0094 NDRX_LOG(log_info, "unlink [%s] failed: %s", data_file, strerror(err)); 0095 } 0096 0097 if (ENOENT!=err) 0098 { 0099 snprintf(errdet, errdetbufsz, "Failed to unlink: [%s]", 0100 strerror(err)); 0101 ret=EXFAIL; 0102 } 0103 } 0104 0105 if (EXSUCCEED!=unlink(lock_file)) 0106 { 0107 int err = errno; 0108 0109 if (LOG_CODE_UBF==log_facility) 0110 { 0111 UBF_LOG(log_error, "unlink [%s] failed: %s", lock_file, strerror(err)); 0112 } 0113 else 0114 { 0115 NDRX_LOG(log_error, "unlink [%s] failed: %s", lock_file, strerror(err)); 0116 } 0117 if (ENOENT!=err) 0118 { 0119 snprintf(errdet, errdetbufsz, 0120 "Failed to unlink: [%s]", strerror(err)); 0121 ret=EXFAIL; 0122 } 0123 } 0124 0125 return ret; 0126 } 0127 0128 /* vim: set ts=4 sw=4 et smartindent: */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |