pgbackrest.git / summary / log / commit / refs
commit 33e328abbf5992caccc15ff42ca2dca14502c983
Author: David Steele <david@pgmasters.net>
Date: Sun Dec 29 01:30:32 2019 +0000
Remove unused LibC code.
The code was made obsolete by the migration to C.
lib/pgBackRest/Common/Lock.pm | 97 ----------------------------
lib/pgBackRest/LibCAuto.pm | 21 ------
libc/LibC.xs | 5 --
libc/Makefile.PL | 1 -
libc/build/lib/pgBackRestLibC/Build.pm | 30 ---------
libc/xs/common/encode.xs | 48 --------------
libc/xs/common/encode.xsh | 7 --
libc/xs/common/lock.xs | 44 -------------
libc/xs/config/config.xs | 4 --
libc/xs/crypto/random.xs | 19 ------
test/lib/pgBackRestTest/Env/ConfigEnvTest.pm | 2 +-
11 files changed, 1 insertion(+), 277 deletions(-)
diff --git a/lib/pgBackRest/Common/Lock.pm b/lib/pgBackRest/Common/Lock.pm
deleted file mode 100644
index 7551960b1..000000000
--- a/lib/pgBackRest/Common/Lock.pm
+++ /dev/null
@@ -1,97 +0,0 @@
-####################################################################################################################################
-# COMMON LOCK MODULE
-####################################################################################################################################
-package pgBackRest::Common::Lock;
-
-use strict;
-use warnings FATAL => qw(all);
-use Carp qw(confess);
-
-use Exporter qw(import);
- our @EXPORT = qw();
-use Fcntl qw(:DEFAULT :flock);
-use File::Basename qw(dirname);
-
-use pgBackRest::Common::Exception;
-use pgBackRest::Common::Log;
-use pgBackRest::Common::String;
-use pgBackRest::Common::Wait;
-use pgBackRest::Config::Config;
-use pgBackRest::Storage::Helper;
-
-####################################################################################################################################
-# lockStopFileName
-#
-# Get the stop file name.
-####################################################################################################################################
-sub lockStopFileName
-{
- my $strStanza = shift;
-
- return cfgOption(CFGOPT_LOCK_PATH) . (defined($strStanza) ? "/${strStanza}" : '/all') . '.stop';
-}
-
-####################################################################################################################################
-# lockStopTest
-#
-# Test if a stop file exists for the current stanza or all stanzas.
-####################################################################################################################################
-sub lockStopTest
-{
- # Assign function parameters, defaults, and log debug info
- my
- (
- $strOperation,
- $bStanzaStopRequired,
- ) =
- logDebugParam
- (
- __PACKAGE__ . '::lockStopTest', \@_,
- {name => 'bStanzaStopRequired', optional => true, default => false}
- );
-
- my $bStopExists = false;
-
- # Check the stanza first if it is specified
- if (cfgOptionTest(CFGOPT_STANZA))
- {
- # Generate the stop file name
- my $strStopFile = lockStopFileName(cfgOption(CFGOPT_STANZA));
-
- if (-e $strStopFile)
- {
- # If the stop file exists and is required then set the flag to true
- if ($bStanzaStopRequired)
- {
- $bStopExists = true;
- }
- else
- {
- confess &log(ERROR, 'stop file exists for stanza ' . cfgOption(CFGOPT_STANZA), ERROR_STOP);
- }
- }
- }
-
- # If not looking for a specific stanza stop file, then check all stanzas
- if (!$bStanzaStopRequired)
- {
- # Now check all stanzas
- my $strStopFile = lockStopFileName();
-
- if (-e $strStopFile)
- {
- confess &log(ERROR, 'stop file exists for all stanzas', ERROR_STOP);
- }
- }
-
- # Return from function and log return values if any
- return logDebugReturn
- (
- $strOperation,
- {name => 'bStopExists', value => $bStopExists}
- );
-}
-
-push @EXPORT, qw(lockStopTest);
-
-1;
diff --git a/lib/pgBackRest/LibCAuto.pm b/lib/pgBackRest/LibCAuto.pm
index c159f07d5..73becd4a7 100644
--- a/lib/pgBackRest/LibCAuto.pm
+++ b/lib/pgBackRest/LibCAuto.pm
@@ -307,7 +307,6 @@ sub libcAutoExportTag
'CFGOPT_TARGET_TIMELINE',
'CFGOPT_TYPE',
'cfgCommandName',
- 'cfgOptionIndex',
'cfgOptionIndexTotal',
'cfgOptionName',
],
@@ -334,8 +333,6 @@ sub libcAutoExportTag
crypto =>
[
- 'CIPHER_MODE_ENCRYPT',
- 'CIPHER_MODE_DECRYPT',
'cryptoHashOne',
],
@@ -344,24 +341,6 @@ sub libcAutoExportTag
'libcUvSize',
],
- encode =>
- [
- 'ENCODE_TYPE_BASE64',
- 'decodeToBin',
- 'encodeToStr',
- ],
-
- lock =>
- [
- 'lockAcquire',
- 'lockRelease',
- ],
-
- random =>
- [
- 'cryptoRandomBytes',
- ],
-
storage =>
[
'storageRepoFree',
diff --git a/libc/LibC.xs b/libc/LibC.xs
index d8abd44bc..4f79efcdb 100644
--- a/libc/LibC.xs
+++ b/libc/LibC.xs
@@ -51,7 +51,6 @@ These includes are from the src directory. There is no Perl-specific code in th
#include "common/crypto/common.h"
#include "common/error.h"
#include "common/io/io.h"
-#include "common/lock.h"
#include "config/config.h"
#include "config/define.h"
#include "config/load.h"
@@ -70,7 +69,6 @@ XSH includes
These includes define data structures that are required for the C to Perl interface but are not part of the regular C source.
***********************************************************************************************************************************/
#include "xs/crypto/hash.xsh"
-#include "xs/common/encode.xsh"
#include "xs/config/configTest.xsh"
#include "xs/postgres/client.xsh"
#include "xs/storage/storage.xsh"
@@ -96,13 +94,10 @@ OUTPUT:
#
# These modules should map 1-1 with C modules in src directory.
# ----------------------------------------------------------------------------------------------------------------------------------
-INCLUDE: xs/common/encode.xs
-INCLUDE: xs/common/lock.xs
INCLUDE: xs/config/config.xs
INCLUDE: xs/config/configTest.xs
INCLUDE: xs/config/define.xs
INCLUDE: xs/crypto/hash.xs
-INCLUDE: xs/crypto/random.xs
INCLUDE: xs/postgres/client.xs
INCLUDE: xs/postgres/pageChecksum.xs
INCLUDE: xs/storage/storage.xs
diff --git a/libc/Makefile.PL b/libc/Makefile.PL
index 033f963ab..de6a5ad6e 100644
--- a/libc/Makefile.PL
+++ b/libc/Makefile.PL
@@ -71,7 +71,6 @@ my @stryCFile =
'common/io/read.c',
'common/io/tls/client.c',
'common/io/write.c',
- 'common/lock.c',
'common/log.c',
'common/memContext.c',
'common/regExp.c',
diff --git a/libc/build/lib/pgBackRestLibC/Build.pm b/libc/build/lib/pgBackRestLibC/Build.pm
index a6140bf23..82a011faa 100644
--- a/libc/build/lib/pgBackRestLibC/Build.pm
+++ b/libc/build/lib/pgBackRestLibC/Build.pm
@@ -82,7 +82,6 @@ my $rhExport =
{
&BLD_EXPORTTYPE_SUB => [qw(
cfgCommandName
- cfgOptionIndex
cfgOptionIndexTotal
cfgOptionName
)],
@@ -105,8 +104,6 @@ my $rhExport =
'crypto' =>
{
&BLD_EXPORTTYPE_SUB => [qw(
- CIPHER_MODE_ENCRYPT
- CIPHER_MODE_DECRYPT
cryptoHashOne
)],
},
@@ -118,33 +115,6 @@ my $rhExport =
)],
},
- 'encode' =>
- {
- &BLD_EXPORTTYPE_CONSTANT => [qw(
- ENCODE_TYPE_BASE64
- )],
-
- &BLD_EXPORTTYPE_SUB => [qw(
- decodeToBin
- encodeToStr
- )],
- },
-
- 'lock' =>
- {
- &BLD_EXPORTTYPE_SUB => [qw(
- lockAcquire
- lockRelease
- )],
- },
-
- 'random' =>
- {
- &BLD_EXPORTTYPE_SUB => [qw(
- cryptoRandomBytes
- )],
- },
-
'storage' =>
{
&BLD_EXPORTTYPE_SUB => [qw(
diff --git a/libc/xs/common/encode.xs b/libc/xs/common/encode.xs
deleted file mode 100644
index d41c69da6..000000000
--- a/libc/xs/common/encode.xs
+++ /dev/null
@@ -1,48 +0,0 @@
-# ----------------------------------------------------------------------------------------------------------------------------------
-# Binary to String Encode/Decode Perl Exports
-# ----------------------------------------------------------------------------------------------------------------------------------
-
-MODULE = pgBackRest::LibC PACKAGE = pgBackRest::LibC
-
-####################################################################################################################################
-SV *
-encodeToStr(encodeType, source)
- int encodeType
- SV *source
-CODE:
- RETVAL = NULL;
-
- STRLEN sourceSize;
- unsigned char *sourcePtr = (unsigned char *)SvPV(source, sourceSize);
-
- ERROR_XS_BEGIN()
- {
- RETVAL = newSV(encodeToStrSize(encodeType, sourceSize));
- SvPOK_only(RETVAL);
-
- encodeToStr(encodeType, sourcePtr, sourceSize, (char *)SvPV_nolen(RETVAL));
- SvCUR_set(RETVAL, encodeToStrSize(encodeType, sourceSize));
- }
- ERROR_XS_END();
-OUTPUT:
- RETVAL
-
-####################################################################################################################################
-SV *
-decodeToBin(encodeType, source)
- int encodeType
- const char *source
-CODE:
- RETVAL = NULL;
-
- ERROR_XS_BEGIN()
- {
- RETVAL = newSV(decodeToBinSize(encodeType, source));
- SvPOK_only(RETVAL);
-
- decodeToBin(encodeType, source, (unsigned char *)SvPV_nolen(RETVAL));
- SvCUR_set(RETVAL, decodeToBinSize(encodeType, source));
- }
- ERROR_XS_END();
-OUTPUT:
- RETVAL
diff --git a/libc/xs/common/encode.xsh b/libc/xs/common/encode.xsh
deleted file mode 100644
index 452c8133f..000000000
--- a/libc/xs/common/encode.xsh
+++ /dev/null
@@ -1,7 +0,0 @@
-/***********************************************************************************************************************************
-Binary to String Encode/Decode XS Header
-***********************************************************************************************************************************/
-#include "common/encode.h"
-
-// Encode types
-#define ENCODE_TYPE_BASE64 ((int)encodeBase64)
diff --git a/libc/xs/common/lock.xs b/libc/xs/common/lock.xs
deleted file mode 100644
index 6b90c04ba..000000000
--- a/libc/xs/common/lock.xs
+++ /dev/null
@@ -1,44 +0,0 @@
-# ----------------------------------------------------------------------------------------------------------------------------------
-# Lock Exports
-# ----------------------------------------------------------------------------------------------------------------------------------
-
-MODULE = pgBackRest::LibC PACKAGE = pgBackRest::LibC
-
-####################################################################################################################################
-bool
-lockAcquire(lockPath, command, stanza, lockTimeout, failOnNoLock)
- const char *lockPath
- const char *command
- const char *stanza
- double lockTimeout
- bool failOnNoLock
-CODE:
- RETVAL = false;
-
- MEM_CONTEXT_XS_TEMP_BEGIN()
- {
- // Set the command so we can get the correct lock type to use
- cfgCommandSet(cfgCommandId(command, true));
-
- // Attempt to acquire the lock
- if (cfgLockRequired())
- RETVAL = lockAcquire(strNew(lockPath), strNew(stanza), cfgLockType(), (TimeMSec)(lockTimeout * 1000), failOnNoLock);
- }
- MEM_CONTEXT_XS_TEMP_END();
-OUTPUT:
- RETVAL
-
-####################################################################################################################################
-bool
-lockRelease(failOnNoLock)
- bool failOnNoLock
-CODE:
- RETVAL = false;
-
- MEM_CONTEXT_XS_TEMP_BEGIN()
- {
- RETVAL = lockRelease(failOnNoLock);
- }
- MEM_CONTEXT_XS_TEMP_END();
-OUTPUT:
- RETVAL
diff --git a/libc/xs/config/config.xs b/libc/xs/config/config.xs
index af8e376ba..18bf17087 100644
--- a/libc/xs/config/config.xs
+++ b/libc/xs/config/config.xs
@@ -8,10 +8,6 @@ const char *
cfgCommandName(commandId)
U32 commandId
-I32
-cfgOptionIndex(optionId)
- U32 optionId
-
I32
cfgOptionIndexTotal(optionId)
U32 optionId
diff --git a/libc/xs/crypto/random.xs b/libc/xs/crypto/random.xs
deleted file mode 100644
index 8b0a46156..000000000
--- a/libc/xs/crypto/random.xs
+++ /dev/null
@@ -1,19 +0,0 @@
-# ----------------------------------------------------------------------------------------------------------------------------------
-# Random Perl Exports
-# ----------------------------------------------------------------------------------------------------------------------------------
-
-MODULE = pgBackRest::LibC PACKAGE = pgBackRest::LibC
-
-####################################################################################################################################
-SV *
-cryptoRandomBytes(size)
- I32 size
-CODE:
- RETVAL = newSV(size);
- SvPOK_only(RETVAL);
-
- cryptoRandomBytes((unsigned char *)SvPV_nolen(RETVAL), size);
-
- SvCUR_set(RETVAL, size);
-OUTPUT:
- RETVAL
diff --git a/test/lib/pgBackRestTest/Env/ConfigEnvTest.pm b/test/lib/pgBackRestTest/Env/ConfigEnvTest.pm
index cb8ed41b4..d4e14913b 100644
--- a/test/lib/pgBackRestTest/Env/ConfigEnvTest.pm
+++ b/test/lib/pgBackRestTest/Env/ConfigEnvTest.pm
@@ -17,7 +17,7 @@ use Getopt::Long qw(GetOptions);
use pgBackRest::Common::Exception;
use pgBackRest::Common::Log;
use pgBackRest::Config::Config;
-use pgBackRest::LibC qw(:test :lock);
+use pgBackRest::LibC qw(:test);
use pgBackRest::Version;
use pgBackRestTest::Common::RunTest;
[parent: e72a9dd0d2b6]