1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-12 10:04:14 +02:00

Move protocol module from common to command.

This module has dependencies on command/command so it does not make sense for it to be in the common module. Also move protocolFree() to main() since this is a very large dependency.

Adjust the tests so command/exit can be tested later. This is a bit messy but will get adjusted as we improve the test harness.
This commit is contained in:
David Steele 2022-06-17 11:17:52 -04:00
parent eb72a80b47
commit 55bcb933ee
10 changed files with 64 additions and 63 deletions

View File

@ -64,6 +64,7 @@ SRCS = \
command/check/check.c \ command/check/check.c \
command/check/common.c \ command/check/common.c \
command/expire/expire.c \ command/expire/expire.c \
command/exit.c \
command/help/help.c \ command/help/help.c \
command/info/info.c \ command/info/info.c \
command/command.c \ command/command.c \
@ -105,7 +106,6 @@ SRCS = \
common/crypto/common.c \ common/crypto/common.c \
common/crypto/hash.c \ common/crypto/hash.c \
common/exec.c \ common/exec.c \
common/exit.c \
common/fork.c \ common/fork.c \
common/ini.c \ common/ini.c \
common/io/client.c \ common/io/client.c \

View File

@ -7,9 +7,9 @@ Exit Routines
#include <string.h> #include <string.h>
#include "command/command.h" #include "command/command.h"
#include "command/exit.h"
#include "common/debug.h" #include "common/debug.h"
#include "common/error.h" #include "common/error.h"
#include "common/exit.h"
#include "common/lock.h" #include "common/lock.h"
#include "common/log.h" #include "common/log.h"
#include "config/config.h" #include "config/config.h"
@ -138,9 +138,6 @@ exitSafe(int result, bool error, SignalType signalType)
result = errorCode(); result = errorCode();
} }
// Free protocol objects
protocolFree();
// Log command end if a command is set // Log command end if a command is set
if (cfgCommand() != cfgCmdNone) if (cfgCommand() != cfgCmdNone)
{ {

View File

@ -1,9 +1,10 @@
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Exit Routines Exit Routines
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
#ifndef COMMON_EXIT_H #ifndef COMMAND_EXIT_H
#define COMMON_EXIT_H #define COMMAND_EXIT_H
#include <stdbool.h>
#include <signal.h> #include <signal.h>
/*********************************************************************************************************************************** /***********************************************************************************************************************************

View File

@ -5,10 +5,10 @@ Server Command
#include <sys/wait.h> #include <sys/wait.h>
#include "command/exit.h"
#include "command/remote/remote.h" #include "command/remote/remote.h"
#include "command/server/server.h" #include "command/server/server.h"
#include "common/debug.h" #include "common/debug.h"
#include "common/exit.h"
#include "common/fork.h" #include "common/fork.h"
#include "common/io/socket/server.h" #include "common/io/socket/server.h"
#include "common/io/tls/server.h" #include "common/io/tls/server.h"

View File

@ -14,6 +14,7 @@ Main
#include "command/command.h" #include "command/command.h"
#include "command/control/start.h" #include "command/control/start.h"
#include "command/control/stop.h" #include "command/control/stop.h"
#include "command/exit.h"
#include "command/expire/expire.h" #include "command/expire/expire.h"
#include "command/help/help.h" #include "command/help/help.h"
#include "command/info/info.h" #include "command/info/info.h"
@ -33,7 +34,6 @@ Main
#include "command/verify/verify.h" #include "command/verify/verify.h"
#include "common/debug.h" #include "common/debug.h"
#include "common/error.h" #include "common/error.h"
#include "common/exit.h"
#include "common/io/fdRead.h" #include "common/io/fdRead.h"
#include "common/io/fdWrite.h" #include "common/io/fdWrite.h"
#include "common/stat.h" #include "common/stat.h"
@ -306,5 +306,8 @@ main(int argListSize, const char *argList[])
} }
TRY_END(); TRY_END();
// Free protocol objects
protocolFree();
FUNCTION_LOG_RETURN(INT, error ? result : exitSafe(result, false, 0)); FUNCTION_LOG_RETURN(INT, error ? result : exitSafe(result, false, 0));
} }

View File

@ -184,6 +184,7 @@ src_pgbackrest = [
'command/backup/file.c', 'command/backup/file.c',
'command/check/check.c', 'command/check/check.c',
'command/check/common.c', 'command/check/common.c',
'command/exit.c',
'command/expire/expire.c', 'command/expire/expire.c',
'command/help/help.c', 'command/help/help.c',
'command/info/info.c', 'command/info/info.c',
@ -228,7 +229,6 @@ src_pgbackrest = [
'common/crypto/common.c', 'common/crypto/common.c',
'common/crypto/hash.c', 'common/crypto/hash.c',
'common/exec.c', 'common/exec.c',
'common/exit.c',
'common/fork.c', 'common/fork.c',
'common/ini.c', 'common/ini.c',
'common/io/client.c', 'common/io/client.c',

View File

@ -439,6 +439,14 @@ src/command/control/stop.h:
class: core class: core
type: c/h type: c/h
src/command/exit.c:
class: core
type: c
src/command/exit.h:
class: core
type: c/h
src/command/expire/expire.c: src/command/expire/expire.c:
class: core class: core
type: c type: c
@ -807,14 +815,6 @@ src/common/exec.h:
class: core class: core
type: c/h type: c/h
src/common/exit.c:
class: core
type: c
src/common/exit.h:
class: core
type: c/h
src/common/fork.c: src/common/fork.c:
class: core class: core
type: c type: c
@ -2179,6 +2179,10 @@ test/src/module/command/controlTest.c:
class: test/module class: test/module
type: c type: c
test/src/module/command/exitTest.c:
class: test/module
type: c
test/src/module/command/expireTest.c: test/src/module/command/expireTest.c:
class: test/module class: test/module
type: c type: c
@ -2255,10 +2259,6 @@ test/src/module/common/execTest.c:
class: test/module class: test/module
type: c type: c
test/src/module/common/exitTest.c:
class: test/module
type: c
test/src/module/common/forkTest.c: test/src/module/common/forkTest.c:
class: test/module class: test/module
type: c type: c

View File

@ -282,9 +282,38 @@ unit:
coverage: coverage:
- common/type/pack - common/type/pack
# ----------------------------------------------------------------------------------------------------------------------------
- name: compress
total: 5
coverage:
- common/compress/bz2/common
- common/compress/bz2/compress
- common/compress/bz2/decompress
- common/compress/gz/common
- common/compress/gz/compress
- common/compress/gz/decompress
- common/compress/lz4/common
- common/compress/lz4/compress
- common/compress/lz4/decompress
- common/compress/zst/common
- common/compress/zst/compress
- common/compress/zst/decompress
- common/compress/helper
depend:
- storage/posix/read
- storage/posix/storage
- storage/posix/write
- storage/read
- storage/storage
- storage/write
# ---------------------------------------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------------------------------------
- name: crypto - name: crypto
total: 3 total: 3
feature: STORAGE
harness: storage
coverage: coverage:
- common/crypto/cipherBlock - common/crypto/cipherBlock
@ -315,14 +344,6 @@ unit:
- common/io/fdRead - common/io/fdRead
- common/io/read - common/io/read
depend:
- storage/posix/read
- storage/posix/storage
- storage/posix/write
- storage/read
- storage/storage
- storage/write
# ---------------------------------------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------------------------------------
- name: io-http - name: io-http
total: 6 total: 6
@ -352,31 +373,12 @@ unit:
- common/ini - common/ini
# ---------------------------------------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------------------------------------
- name: compress - name: lock
total: 5
coverage:
- common/compress/bz2/common
- common/compress/bz2/compress
- common/compress/bz2/decompress
- common/compress/gz/common
- common/compress/gz/compress
- common/compress/gz/decompress
- common/compress/lz4/common
- common/compress/lz4/compress
- common/compress/lz4/decompress
- common/compress/zst/common
- common/compress/zst/compress
- common/compress/zst/decompress
- common/compress/helper
# ----------------------------------------------------------------------------------------------------------------------------
- name: exit
total: 3 total: 3
harness: config harness: config
coverage: coverage:
- common/exit - common/lock
depend: depend:
- command/backup/pageChecksum - command/backup/pageChecksum
@ -400,15 +402,6 @@ unit:
- storage/remote/storage - storage/remote/storage
- storage/remote/write - storage/remote/write
# ----------------------------------------------------------------------------------------------------------------------------
- name: lock
total: 3
feature: STORAGE
harness: storage
coverage:
- common/lock
# ******************************************************************************************************************************** # ********************************************************************************************************************************
- name: protocol - name: protocol
@ -846,6 +839,13 @@ unit:
coverage: coverage:
- command/local/local - command/local/local
# ----------------------------------------------------------------------------------------------------------------------------
- name: exit
total: 3
coverage:
- command/exit
# ---------------------------------------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------------------------------------
- name: server - name: server
total: 2 total: 2

View File

@ -94,7 +94,7 @@ testRun(void)
{ {
exitSafe(0, true, signalTypeNone); exitSafe(0, true, signalTypeNone);
TEST_RESULT_LOG( TEST_RESULT_LOG(
"P00 DEBUG: " TEST_PGB_PATH "/src/common/exit::exitSafe: (result: 0, error: true, signalType: 0)\n" "P00 DEBUG: " TEST_PGB_PATH "/src/command/exit::exitSafe: (result: 0, error: true, signalType: 0)\n"
"P00 ERROR: [122]: test debug error message\n" "P00 ERROR: [122]: test debug error message\n"
" --------------------------------------------------------------------\n" " --------------------------------------------------------------------\n"
" If SUBMITTING AN ISSUE please provide the following information:\n" " If SUBMITTING AN ISSUE please provide the following information:\n"
@ -109,7 +109,7 @@ testRun(void)
"P00 INFO: archive-push:async command end: aborted with exception [122]\n" "P00 INFO: archive-push:async command end: aborted with exception [122]\n"
"P00 DEBUG: " TEST_PGB_PATH "/src/common/lock::lockRelease: (failOnNoLock: false)\n" "P00 DEBUG: " TEST_PGB_PATH "/src/common/lock::lockRelease: (failOnNoLock: false)\n"
"P00 DEBUG: " TEST_PGB_PATH "/src/common/lock::lockRelease: => false\n" "P00 DEBUG: " TEST_PGB_PATH "/src/common/lock::lockRelease: => false\n"
"P00 DEBUG: " TEST_PGB_PATH "/src/common/exit::exitSafe: => 122"); "P00 DEBUG: " TEST_PGB_PATH "/src/command/exit::exitSafe: => 122");
} }
TRY_END(); TRY_END();

View File

@ -1,7 +1,7 @@
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Test Server Command Test Server Command
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
#include "common/exit.h" #include "command/exit.h"
#include "storage/posix/storage.h" #include "storage/posix/storage.h"
#include "storage/remote/storage.h" #include "storage/remote/storage.h"