1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2026-05-22 10:15:16 +02:00

Remove unused LibC code.

The code was made obsolete by the migration to C.
This commit is contained in:
David Steele
2019-12-28 18:30:32 -07:00
parent e72a9dd0d2
commit 33e328abbf
11 changed files with 1 additions and 277 deletions
-97
View File
@@ -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;
-21
View File
@@ -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',
-5
View File
@@ -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
-1
View File
@@ -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',
-30
View File
@@ -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(
-48
View File
@@ -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
-7
View File
@@ -1,7 +0,0 @@
/***********************************************************************************************************************************
Binary to String Encode/Decode XS Header
***********************************************************************************************************************************/
#include "common/encode.h"
// Encode types
#define ENCODE_TYPE_BASE64 ((int)encodeBase64)
-44
View File
@@ -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
-4
View File
@@ -8,10 +8,6 @@ const char *
cfgCommandName(commandId)
U32 commandId
I32
cfgOptionIndex(optionId)
U32 optionId
I32
cfgOptionIndexTotal(optionId)
U32 optionId
-19
View File
@@ -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
+1 -1
View File
@@ -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;