You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-13 01:00:23 +02:00
Add ioFdReadNewOpen() and ioFdWriteNewOpen().
These functions construct and open in one call, which allows them to be used as function parameters.
This commit is contained in:
@ -38,12 +38,9 @@ cmdLocal(int fdRead, int fdWrite)
|
|||||||
MEM_CONTEXT_TEMP_BEGIN()
|
MEM_CONTEXT_TEMP_BEGIN()
|
||||||
{
|
{
|
||||||
String *name = strNewFmt(PROTOCOL_SERVICE_LOCAL "-%s", strZ(cfgOptionDisplay(cfgOptProcess)));
|
String *name = strNewFmt(PROTOCOL_SERVICE_LOCAL "-%s", strZ(cfgOptionDisplay(cfgOptProcess)));
|
||||||
IoRead *read = ioFdReadNew(name, fdRead, cfgOptionUInt64(cfgOptProtocolTimeout));
|
ProtocolServer *server = protocolServerNew(
|
||||||
ioReadOpen(read);
|
name, PROTOCOL_SERVICE_LOCAL_STR, ioFdReadNewOpen(name, fdRead, cfgOptionUInt64(cfgOptProtocolTimeout)),
|
||||||
IoWrite *write = ioFdWriteNew(name, fdWrite, cfgOptionUInt64(cfgOptProtocolTimeout));
|
ioFdWriteNewOpen(name, fdWrite, cfgOptionUInt64(cfgOptProtocolTimeout)));
|
||||||
ioWriteOpen(write);
|
|
||||||
|
|
||||||
ProtocolServer *server = protocolServerNew(name, PROTOCOL_SERVICE_LOCAL_STR, read, write);
|
|
||||||
protocolServerProcess(
|
protocolServerProcess(
|
||||||
server, cfgCommandJobRetry(), commandLocalHandlerList, PROTOCOL_SERVER_HANDLER_LIST_SIZE(commandLocalHandlerList));
|
server, cfgCommandJobRetry(), commandLocalHandlerList, PROTOCOL_SERVER_HANDLER_LIST_SIZE(commandLocalHandlerList));
|
||||||
}
|
}
|
||||||
|
@ -36,12 +36,9 @@ cmdRemote(int fdRead, int fdWrite)
|
|||||||
MEM_CONTEXT_TEMP_BEGIN()
|
MEM_CONTEXT_TEMP_BEGIN()
|
||||||
{
|
{
|
||||||
String *name = strNewFmt(PROTOCOL_SERVICE_REMOTE "-%s", strZ(cfgOptionDisplay(cfgOptProcess)));
|
String *name = strNewFmt(PROTOCOL_SERVICE_REMOTE "-%s", strZ(cfgOptionDisplay(cfgOptProcess)));
|
||||||
IoRead *read = ioFdReadNew(name, fdRead, cfgOptionUInt64(cfgOptProtocolTimeout));
|
ProtocolServer *server = protocolServerNew(
|
||||||
ioReadOpen(read);
|
name, PROTOCOL_SERVICE_REMOTE_STR, ioFdReadNewOpen(name, fdRead, cfgOptionUInt64(cfgOptProtocolTimeout)),
|
||||||
IoWrite *write = ioFdWriteNew(name, fdWrite, cfgOptionUInt64(cfgOptProtocolTimeout));
|
ioFdWriteNewOpen(name, fdWrite, cfgOptionUInt64(cfgOptProtocolTimeout)));
|
||||||
ioWriteOpen(write);
|
|
||||||
|
|
||||||
ProtocolServer *server = protocolServerNew(name, PROTOCOL_SERVICE_REMOTE_STR, read, write);
|
|
||||||
|
|
||||||
// Acquire a lock if this command needs one. We'll use the noop that is always sent from the client right after the
|
// Acquire a lock if this command needs one. We'll use the noop that is always sent from the client right after the
|
||||||
// handshake to return an error. We can't take a lock earlier than this because we want the error to go back through the
|
// handshake to return an error. We can't take a lock earlier than this because we want the error to go back through the
|
||||||
|
@ -183,9 +183,8 @@ execCheck(Exec *this)
|
|||||||
if (WIFEXITED(processStatus))
|
if (WIFEXITED(processStatus))
|
||||||
{
|
{
|
||||||
// Get data from stderr to help diagnose the problem
|
// Get data from stderr to help diagnose the problem
|
||||||
IoRead *ioReadError = ioFdReadNew(strNewFmt("%s error", strZ(this->name)), this->fdError, 0);
|
String *errorStr = strTrim(
|
||||||
ioReadOpen(ioReadError);
|
strNewBuf(ioReadBuf(ioFdReadNewOpen(strNewFmt("%s error", strZ(this->name)), this->fdError, 0))));
|
||||||
String *errorStr = strTrim(strNewBuf(ioReadBuf(ioReadError)));
|
|
||||||
|
|
||||||
// Throw the error with as much information as is available
|
// Throw the error with as much information as is available
|
||||||
THROWP_FMT(
|
THROWP_FMT(
|
||||||
@ -361,8 +360,7 @@ execOpen(Exec *this)
|
|||||||
|
|
||||||
// Assign file descriptors to io interfaces
|
// Assign file descriptors to io interfaces
|
||||||
this->ioReadFd = ioFdReadNew(strNewFmt("%s read", strZ(this->name)), this->fdRead, this->timeout);
|
this->ioReadFd = ioFdReadNew(strNewFmt("%s read", strZ(this->name)), this->fdRead, this->timeout);
|
||||||
this->ioWriteFd = ioFdWriteNew(strNewFmt("%s write", strZ(this->name)), this->fdWrite, this->timeout);
|
this->ioWriteFd = ioFdWriteNewOpen(strNewFmt("%s write", strZ(this->name)), this->fdWrite, this->timeout);
|
||||||
ioWriteOpen(this->ioWriteFd);
|
|
||||||
|
|
||||||
// Create wrapper interfaces that check process state
|
// Create wrapper interfaces that check process state
|
||||||
this->pub.ioReadExec = ioReadNewP(this, .block = true, .read = execRead, .eof = execEof, .fd = execFdRead);
|
this->pub.ioReadExec = ioReadNewP(this, .block = true, .read = execRead, .eof = execEof, .fd = execFdRead);
|
||||||
|
@ -14,4 +14,13 @@ Constructors
|
|||||||
***********************************************************************************************************************************/
|
***********************************************************************************************************************************/
|
||||||
IoRead *ioFdReadNew(const String *name, int fd, TimeMSec timeout);
|
IoRead *ioFdReadNew(const String *name, int fd, TimeMSec timeout);
|
||||||
|
|
||||||
|
// Construct and open read fd
|
||||||
|
__attribute__((always_inline)) static inline IoRead *
|
||||||
|
ioFdReadNewOpen(const String *const name, const int fd, const TimeMSec timeout)
|
||||||
|
{
|
||||||
|
IoRead *const result = ioFdReadNew(name, fd, timeout);
|
||||||
|
ioReadOpen(result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -14,6 +14,15 @@ Constructors
|
|||||||
***********************************************************************************************************************************/
|
***********************************************************************************************************************************/
|
||||||
IoWrite *ioFdWriteNew(const String *name, int fd, TimeMSec timeout);
|
IoWrite *ioFdWriteNew(const String *name, int fd, TimeMSec timeout);
|
||||||
|
|
||||||
|
// Construct and open write fd
|
||||||
|
__attribute__((always_inline)) static inline IoWrite *
|
||||||
|
ioFdWriteNewOpen(const String *const name, const int fd, const TimeMSec timeout)
|
||||||
|
{
|
||||||
|
IoWrite *const result = ioFdWriteNew(name, fd, timeout);
|
||||||
|
ioWriteOpen(result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
Helper functions
|
Helper functions
|
||||||
***********************************************************************************************************************************/
|
***********************************************************************************************************************************/
|
||||||
|
@ -193,16 +193,12 @@ sckSessionNew(IoSessionRole role, int fd, const String *host, unsigned int port,
|
|||||||
.host = strDup(host),
|
.host = strDup(host),
|
||||||
.port = port,
|
.port = port,
|
||||||
.timeout = timeout,
|
.timeout = timeout,
|
||||||
.read = ioFdReadNew(name, fd, timeout),
|
.read = ioFdReadNewOpen(name, fd, timeout),
|
||||||
.write = ioFdWriteNew(name, fd, timeout),
|
.write = ioFdWriteNewOpen(name, fd, timeout),
|
||||||
};
|
};
|
||||||
|
|
||||||
strFree(name);
|
strFree(name);
|
||||||
|
|
||||||
// Open read/write io
|
|
||||||
ioReadOpen(driver->read);
|
|
||||||
ioWriteOpen(driver->write);
|
|
||||||
|
|
||||||
// Ensure file descriptor is closed
|
// Ensure file descriptor is closed
|
||||||
memContextCallbackSet(driver->memContext, sckSessionFreeResource, driver);
|
memContextCallbackSet(driver->memContext, sckSessionFreeResource, driver);
|
||||||
|
|
||||||
|
@ -73,12 +73,9 @@ protocolLocalExec(
|
|||||||
|
|
||||||
// Run server with provided handlers
|
// Run server with provided handlers
|
||||||
String *name = strNewFmt(PROTOCOL_SERVICE_LOCAL "-shim-%u", processId);
|
String *name = strNewFmt(PROTOCOL_SERVICE_LOCAL "-shim-%u", processId);
|
||||||
IoRead *read = ioFdReadNew(name, pipeWrite[0], 5000);
|
ProtocolServer *server = protocolServerNew(
|
||||||
ioReadOpen(read);
|
name, PROTOCOL_SERVICE_LOCAL_STR, ioFdReadNewOpen(name, pipeWrite[0], 5000),
|
||||||
IoWrite *write = ioFdWriteNew(name, pipeRead[1], 5000);
|
ioFdWriteNewOpen(name, pipeRead[1], 5000));
|
||||||
ioWriteOpen(write);
|
|
||||||
|
|
||||||
ProtocolServer *server = protocolServerNew(name, PROTOCOL_SERVICE_LOCAL_STR, read, write);
|
|
||||||
protocolServerProcess(server, NULL, hrnProtocolStatic.localHandlerList, hrnProtocolStatic.localHandlerListSize);
|
protocolServerProcess(server, NULL, hrnProtocolStatic.localHandlerList, hrnProtocolStatic.localHandlerListSize);
|
||||||
|
|
||||||
// Exit when done
|
// Exit when done
|
||||||
@ -90,13 +87,10 @@ protocolLocalExec(
|
|||||||
close(pipeWrite[0]);
|
close(pipeWrite[0]);
|
||||||
|
|
||||||
// Create protocol object
|
// Create protocol object
|
||||||
IoRead *read = ioFdReadNew(strNewFmt(PROTOCOL_SERVICE_LOCAL "-%u shim protocol read", processId), pipeRead[0], 5000);
|
|
||||||
ioReadOpen(read);
|
|
||||||
IoWrite *write = ioFdWriteNew(strNewFmt(PROTOCOL_SERVICE_LOCAL "-%u shim protocol write", processId), pipeWrite[1], 5000);
|
|
||||||
ioWriteOpen(write);
|
|
||||||
|
|
||||||
helper->client = protocolClientNew(
|
helper->client = protocolClientNew(
|
||||||
strNewFmt(PROTOCOL_SERVICE_LOCAL "-%u shim protocol", processId), PROTOCOL_SERVICE_LOCAL_STR, read, write);
|
strNewFmt(PROTOCOL_SERVICE_LOCAL "-%u shim protocol", processId), PROTOCOL_SERVICE_LOCAL_STR,
|
||||||
|
ioFdReadNewOpen(strNewFmt(PROTOCOL_SERVICE_LOCAL "-%u shim protocol read", processId), pipeRead[0], 5000),
|
||||||
|
ioFdWriteNewOpen(strNewFmt(PROTOCOL_SERVICE_LOCAL "-%u shim protocol write", processId), pipeWrite[1], 5000));
|
||||||
|
|
||||||
FUNCTION_LOG_RETURN_VOID();
|
FUNCTION_LOG_RETURN_VOID();
|
||||||
}
|
}
|
||||||
@ -169,12 +163,9 @@ protocolRemoteExec(
|
|||||||
|
|
||||||
// Run server with provided handlers
|
// Run server with provided handlers
|
||||||
String *name = strNewFmt(PROTOCOL_SERVICE_REMOTE "-shim-%u", processId);
|
String *name = strNewFmt(PROTOCOL_SERVICE_REMOTE "-shim-%u", processId);
|
||||||
IoRead *read = ioFdReadNew(name, pipeWrite[0], 5000);
|
ProtocolServer *server = protocolServerNew(
|
||||||
ioReadOpen(read);
|
name, PROTOCOL_SERVICE_REMOTE_STR, ioFdReadNewOpen(name, pipeWrite[0], 5000),
|
||||||
IoWrite *write = ioFdWriteNew(name, pipeRead[1], 5000);
|
ioFdWriteNewOpen(name, pipeRead[1], 5000));
|
||||||
ioWriteOpen(write);
|
|
||||||
|
|
||||||
ProtocolServer *server = protocolServerNew(name, PROTOCOL_SERVICE_REMOTE_STR, read, write);
|
|
||||||
protocolServerProcess(server, NULL, hrnProtocolStatic.remoteHandlerList, hrnProtocolStatic.remoteHandlerListSize);
|
protocolServerProcess(server, NULL, hrnProtocolStatic.remoteHandlerList, hrnProtocolStatic.remoteHandlerListSize);
|
||||||
|
|
||||||
// Put an end message here to sync with the client to ensure that coverage data is written before exiting
|
// Put an end message here to sync with the client to ensure that coverage data is written before exiting
|
||||||
@ -189,13 +180,10 @@ protocolRemoteExec(
|
|||||||
close(pipeWrite[0]);
|
close(pipeWrite[0]);
|
||||||
|
|
||||||
// Create protocol object
|
// Create protocol object
|
||||||
IoRead *read = ioFdReadNew(strNewFmt(PROTOCOL_SERVICE_REMOTE "-%u shim protocol read", processId), pipeRead[0], 5000);
|
|
||||||
ioReadOpen(read);
|
|
||||||
IoWrite *write = ioFdWriteNew(strNewFmt(PROTOCOL_SERVICE_REMOTE "-%u shim protocol write", processId), pipeWrite[1], 5000);
|
|
||||||
ioWriteOpen(write);
|
|
||||||
|
|
||||||
helper->client = protocolClientNew(
|
helper->client = protocolClientNew(
|
||||||
strNewFmt(PROTOCOL_SERVICE_REMOTE "-%u shim protocol", processId), PROTOCOL_SERVICE_REMOTE_STR, read, write);
|
strNewFmt(PROTOCOL_SERVICE_REMOTE "-%u shim protocol", processId), PROTOCOL_SERVICE_REMOTE_STR,
|
||||||
|
ioFdReadNewOpen(strNewFmt(PROTOCOL_SERVICE_REMOTE "-%u shim protocol read", processId), pipeRead[0], 5000),
|
||||||
|
ioFdWriteNewOpen(strNewFmt(PROTOCOL_SERVICE_REMOTE "-%u shim protocol write", processId), pipeWrite[1], 5000));
|
||||||
|
|
||||||
FUNCTION_LOG_RETURN_VOID();
|
FUNCTION_LOG_RETURN_VOID();
|
||||||
}
|
}
|
||||||
|
@ -735,10 +735,8 @@ testRun(void)
|
|||||||
{
|
{
|
||||||
HARNESS_FORK_CHILD_BEGIN(0, true)
|
HARNESS_FORK_CHILD_BEGIN(0, true)
|
||||||
{
|
{
|
||||||
IoRead *read = ioFdReadNew(STRDEF("child read"), HARNESS_FORK_CHILD_READ(), 2000);
|
IoRead *read = ioFdReadNewOpen(STRDEF("child read"), HARNESS_FORK_CHILD_READ(), 2000);
|
||||||
ioReadOpen(read);
|
IoWrite *write = ioFdWriteNewOpen(STRDEF("child write"), HARNESS_FORK_CHILD_WRITE(), 2000);
|
||||||
IoWrite *write = ioFdWriteNew(STRDEF("child write"), HARNESS_FORK_CHILD_WRITE(), 2000);
|
|
||||||
ioWriteOpen(write);
|
|
||||||
|
|
||||||
TEST_RESULT_VOID(
|
TEST_RESULT_VOID(
|
||||||
lockAcquire(
|
lockAcquire(
|
||||||
@ -757,10 +755,8 @@ testRun(void)
|
|||||||
|
|
||||||
HARNESS_FORK_PARENT_BEGIN()
|
HARNESS_FORK_PARENT_BEGIN()
|
||||||
{
|
{
|
||||||
IoRead *read = ioFdReadNew(STRDEF("parent read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 2000);
|
IoRead *read = ioFdReadNewOpen(STRDEF("parent read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 2000);
|
||||||
ioReadOpen(read);
|
IoWrite *write = ioFdWriteNewOpen(STRDEF("parent write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 2000);
|
||||||
IoWrite *write = ioFdWriteNew(STRDEF("parent write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 2000);
|
|
||||||
ioWriteOpen(write);
|
|
||||||
|
|
||||||
// Wait for the child to acquire the lock
|
// Wait for the child to acquire the lock
|
||||||
ioReadLine(read);
|
ioReadLine(read);
|
||||||
|
@ -713,10 +713,8 @@ testRun(void)
|
|||||||
{
|
{
|
||||||
HARNESS_FORK_CHILD_BEGIN(0, true)
|
HARNESS_FORK_CHILD_BEGIN(0, true)
|
||||||
{
|
{
|
||||||
IoRead *read = ioFdReadNew(STRDEF("child read"), HARNESS_FORK_CHILD_READ(), 2000);
|
IoRead *read = ioFdReadNewOpen(STRDEF("child read"), HARNESS_FORK_CHILD_READ(), 2000);
|
||||||
ioReadOpen(read);
|
IoWrite *write = ioFdWriteNewOpen(STRDEF("child write"), HARNESS_FORK_CHILD_WRITE(), 2000);
|
||||||
IoWrite *write = ioFdWriteNew(STRDEF("child write"), HARNESS_FORK_CHILD_WRITE(), 2000);
|
|
||||||
ioWriteOpen(write);
|
|
||||||
|
|
||||||
lockAcquire(
|
lockAcquire(
|
||||||
cfgOptionStr(cfgOptLockPath), cfgOptionStr(cfgOptStanza), STRDEF("555-fefefefe"), cfgLockType(), 30000, true);
|
cfgOptionStr(cfgOptLockPath), cfgOptionStr(cfgOptStanza), STRDEF("555-fefefefe"), cfgLockType(), 30000, true);
|
||||||
@ -732,10 +730,8 @@ testRun(void)
|
|||||||
|
|
||||||
HARNESS_FORK_PARENT_BEGIN()
|
HARNESS_FORK_PARENT_BEGIN()
|
||||||
{
|
{
|
||||||
IoRead *read = ioFdReadNew(STRDEF("parent read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 2000);
|
IoRead *read = ioFdReadNewOpen(STRDEF("parent read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 2000);
|
||||||
ioReadOpen(read);
|
IoWrite *write = ioFdWriteNewOpen(STRDEF("parent write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 2000);
|
||||||
IoWrite *write = ioFdWriteNew(STRDEF("parent write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 2000);
|
|
||||||
ioWriteOpen(write);
|
|
||||||
|
|
||||||
// Wait for the child to acquire the lock
|
// Wait for the child to acquire the lock
|
||||||
ioReadLine(read);
|
ioReadLine(read);
|
||||||
|
@ -164,10 +164,8 @@ testRun(void)
|
|||||||
{
|
{
|
||||||
HARNESS_FORK_CHILD_BEGIN(0, true)
|
HARNESS_FORK_CHILD_BEGIN(0, true)
|
||||||
{
|
{
|
||||||
IoRead *read = ioFdReadNew(STRDEF("child read"), HARNESS_FORK_CHILD_READ(), 2000);
|
IoRead *read = ioFdReadNewOpen(STRDEF("child read"), HARNESS_FORK_CHILD_READ(), 2000);
|
||||||
ioReadOpen(read);
|
IoWrite *write = ioFdWriteNewOpen(STRDEF("child write"), HARNESS_FORK_CHILD_WRITE(), 2000);
|
||||||
IoWrite *write = ioFdWriteNew(STRDEF("child write"), HARNESS_FORK_CHILD_WRITE(), 2000);
|
|
||||||
ioWriteOpen(write);
|
|
||||||
|
|
||||||
int lockFd = open(HRN_PATH "/lock/empty" LOCK_FILE_EXT, O_RDONLY, 0);
|
int lockFd = open(HRN_PATH "/lock/empty" LOCK_FILE_EXT, O_RDONLY, 0);
|
||||||
TEST_RESULT_BOOL(lockFd != -1, true, "file descriptor acquired");
|
TEST_RESULT_BOOL(lockFd != -1, true, "file descriptor acquired");
|
||||||
@ -187,10 +185,8 @@ testRun(void)
|
|||||||
|
|
||||||
HARNESS_FORK_PARENT_BEGIN()
|
HARNESS_FORK_PARENT_BEGIN()
|
||||||
{
|
{
|
||||||
IoRead *read = ioFdReadNew(STRDEF("parent read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 2000);
|
IoRead *read = ioFdReadNewOpen(STRDEF("parent read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 2000);
|
||||||
ioReadOpen(read);
|
IoWrite *write = ioFdWriteNewOpen(STRDEF("parent write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 2000);
|
||||||
IoWrite *write = ioFdWriteNew(STRDEF("parent write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 2000);
|
|
||||||
ioWriteOpen(write);
|
|
||||||
|
|
||||||
// Wait for the child to acquire the lock
|
// Wait for the child to acquire the lock
|
||||||
ioReadLine(read);
|
ioReadLine(read);
|
||||||
@ -218,10 +214,8 @@ testRun(void)
|
|||||||
{
|
{
|
||||||
HARNESS_FORK_CHILD_BEGIN(0, true)
|
HARNESS_FORK_CHILD_BEGIN(0, true)
|
||||||
{
|
{
|
||||||
IoRead *read = ioFdReadNew(STRDEF("child read"), HARNESS_FORK_CHILD_READ(), 2000);
|
IoRead *read = ioFdReadNewOpen(STRDEF("child read"), HARNESS_FORK_CHILD_READ(), 2000);
|
||||||
ioReadOpen(read);
|
IoWrite *write = ioFdWriteNewOpen(STRDEF("child write"), HARNESS_FORK_CHILD_WRITE(), 2000);
|
||||||
IoWrite *write = ioFdWriteNew(STRDEF("child write"), HARNESS_FORK_CHILD_WRITE(), 2000);
|
|
||||||
ioWriteOpen(write);
|
|
||||||
|
|
||||||
int lockFd = open(HRN_PATH "/lock/empty" LOCK_FILE_EXT, O_RDONLY, 0);
|
int lockFd = open(HRN_PATH "/lock/empty" LOCK_FILE_EXT, O_RDONLY, 0);
|
||||||
TEST_RESULT_BOOL(lockFd != -1, true, "file descriptor acquired");
|
TEST_RESULT_BOOL(lockFd != -1, true, "file descriptor acquired");
|
||||||
@ -241,10 +235,8 @@ testRun(void)
|
|||||||
|
|
||||||
HARNESS_FORK_PARENT_BEGIN()
|
HARNESS_FORK_PARENT_BEGIN()
|
||||||
{
|
{
|
||||||
IoRead *read = ioFdReadNew(STRDEF("parent read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 2000);
|
IoRead *read = ioFdReadNewOpen(STRDEF("parent read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 2000);
|
||||||
ioReadOpen(read);
|
IoWrite *write = ioFdWriteNewOpen(STRDEF("parent write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 2000);
|
||||||
IoWrite *write = ioFdWriteNew(STRDEF("parent write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 2000);
|
|
||||||
ioWriteOpen(write);
|
|
||||||
|
|
||||||
// Wait for the child to acquire the lock
|
// Wait for the child to acquire the lock
|
||||||
ioReadLine(read);
|
ioReadLine(read);
|
||||||
@ -270,10 +262,8 @@ testRun(void)
|
|||||||
{
|
{
|
||||||
HARNESS_FORK_CHILD_BEGIN(0, true)
|
HARNESS_FORK_CHILD_BEGIN(0, true)
|
||||||
{
|
{
|
||||||
IoRead *read = ioFdReadNew(STRDEF("child read"), HARNESS_FORK_CHILD_READ(), 2000);
|
IoRead *read = ioFdReadNewOpen(STRDEF("child read"), HARNESS_FORK_CHILD_READ(), 2000);
|
||||||
ioReadOpen(read);
|
IoWrite *write = ioFdWriteNewOpen(STRDEF("child write"), HARNESS_FORK_CHILD_WRITE(), 2000);
|
||||||
IoWrite *write = ioFdWriteNew(STRDEF("child write"), HARNESS_FORK_CHILD_WRITE(), 2000);
|
|
||||||
ioWriteOpen(write);
|
|
||||||
|
|
||||||
TEST_RESULT_BOOL(
|
TEST_RESULT_BOOL(
|
||||||
lockAcquire(STRDEF(HRN_PATH "/lock"), cfgOptionStr(cfgOptStanza), cfgOptionStr(cfgOptExecId), 0, 30000, true),
|
lockAcquire(STRDEF(HRN_PATH "/lock"), cfgOptionStr(cfgOptStanza), cfgOptionStr(cfgOptExecId), 0, 30000, true),
|
||||||
@ -290,10 +280,7 @@ testRun(void)
|
|||||||
|
|
||||||
HARNESS_FORK_PARENT_BEGIN()
|
HARNESS_FORK_PARENT_BEGIN()
|
||||||
{
|
{
|
||||||
IoRead *read = ioFdReadNew(STRDEF("parent read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 2000);
|
IoRead *read = ioFdReadNewOpen(STRDEF("parent read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 2000);
|
||||||
ioReadOpen(read);
|
|
||||||
IoWrite *write = ioFdWriteNew(STRDEF("parent write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 2000);
|
|
||||||
ioWriteOpen(write);
|
|
||||||
|
|
||||||
// Wait for the child to acquire the lock
|
// Wait for the child to acquire the lock
|
||||||
ioReadLine(read);
|
ioReadLine(read);
|
||||||
@ -317,10 +304,8 @@ testRun(void)
|
|||||||
{
|
{
|
||||||
HARNESS_FORK_CHILD_BEGIN(0, true)
|
HARNESS_FORK_CHILD_BEGIN(0, true)
|
||||||
{
|
{
|
||||||
IoRead *read = ioFdReadNew(STRDEF("child read"), HARNESS_FORK_CHILD_READ(), 2000);
|
IoRead *read = ioFdReadNewOpen(STRDEF("child read"), HARNESS_FORK_CHILD_READ(), 2000);
|
||||||
ioReadOpen(read);
|
IoWrite *write = ioFdWriteNewOpen(STRDEF("child write"), HARNESS_FORK_CHILD_WRITE(), 2000);
|
||||||
IoWrite *write = ioFdWriteNew(STRDEF("child write"), HARNESS_FORK_CHILD_WRITE(), 2000);
|
|
||||||
ioWriteOpen(write);
|
|
||||||
|
|
||||||
int lockFd = open(HRN_PATH "/lock/badpid" LOCK_FILE_EXT, O_RDONLY, 0);
|
int lockFd = open(HRN_PATH "/lock/badpid" LOCK_FILE_EXT, O_RDONLY, 0);
|
||||||
TEST_RESULT_BOOL(lockFd != -1, true, "file descriptor acquired");
|
TEST_RESULT_BOOL(lockFd != -1, true, "file descriptor acquired");
|
||||||
@ -341,10 +326,8 @@ testRun(void)
|
|||||||
|
|
||||||
HARNESS_FORK_PARENT_BEGIN()
|
HARNESS_FORK_PARENT_BEGIN()
|
||||||
{
|
{
|
||||||
IoRead *read = ioFdReadNew(STRDEF("parent read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 2000);
|
IoRead *read = ioFdReadNewOpen(STRDEF("parent read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 2000);
|
||||||
ioReadOpen(read);
|
IoWrite *write = ioFdWriteNewOpen(STRDEF("parent write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 2000);
|
||||||
IoWrite *write = ioFdWriteNew(STRDEF("parent write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 2000);
|
|
||||||
ioWriteOpen(write);
|
|
||||||
|
|
||||||
// Wait for the child to acquire the lock
|
// Wait for the child to acquire the lock
|
||||||
ioReadLine(read);
|
ioReadLine(read);
|
||||||
|
@ -43,12 +43,10 @@ testRun(void)
|
|||||||
|
|
||||||
HARNESS_FORK_PARENT_BEGIN()
|
HARNESS_FORK_PARENT_BEGIN()
|
||||||
{
|
{
|
||||||
IoRead *read = ioFdReadNew(STRDEF("server read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 2000);
|
ProtocolClient *client = protocolClientNew(
|
||||||
ioReadOpen(read);
|
STRDEF("test"), PROTOCOL_SERVICE_LOCAL_STR,
|
||||||
IoWrite *write = ioFdWriteNew(STRDEF("server write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 2000);
|
ioFdReadNewOpen(STRDEF("server read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 2000),
|
||||||
ioWriteOpen(write);
|
ioFdWriteNewOpen(STRDEF("server write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 2000));
|
||||||
|
|
||||||
ProtocolClient *client = protocolClientNew(STRDEF("test"), PROTOCOL_SERVICE_LOCAL_STR, read, write);
|
|
||||||
protocolClientNoOp(client);
|
protocolClientNoOp(client);
|
||||||
protocolClientFree(client);
|
protocolClientFree(client);
|
||||||
}
|
}
|
||||||
|
@ -43,12 +43,10 @@ testRun(void)
|
|||||||
|
|
||||||
HARNESS_FORK_PARENT_BEGIN()
|
HARNESS_FORK_PARENT_BEGIN()
|
||||||
{
|
{
|
||||||
IoRead *read = ioFdReadNew(STRDEF("server read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 2000);
|
ProtocolClient *client = protocolClientNew(
|
||||||
ioReadOpen(read);
|
STRDEF("test"), PROTOCOL_SERVICE_REMOTE_STR,
|
||||||
IoWrite *write = ioFdWriteNew(STRDEF("server write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 2000);
|
ioFdReadNewOpen(STRDEF("server read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 2000),
|
||||||
ioWriteOpen(write);
|
ioFdWriteNewOpen(STRDEF("server write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 2000));
|
||||||
|
|
||||||
ProtocolClient *client = protocolClientNew(STRDEF("test"), PROTOCOL_SERVICE_REMOTE_STR, read, write);
|
|
||||||
protocolClientNoOp(client);
|
protocolClientNoOp(client);
|
||||||
protocolClientFree(client);
|
protocolClientFree(client);
|
||||||
}
|
}
|
||||||
@ -77,13 +75,13 @@ testRun(void)
|
|||||||
|
|
||||||
HARNESS_FORK_PARENT_BEGIN()
|
HARNESS_FORK_PARENT_BEGIN()
|
||||||
{
|
{
|
||||||
IoRead *read = ioFdReadNew(STRDEF("server read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 2000);
|
|
||||||
ioReadOpen(read);
|
|
||||||
IoWrite *write = ioFdWriteNew(STRDEF("server write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 2000);
|
|
||||||
ioWriteOpen(write);
|
|
||||||
|
|
||||||
ProtocolClient *client = NULL;
|
ProtocolClient *client = NULL;
|
||||||
TEST_ASSIGN(client, protocolClientNew(STRDEF("test"), PROTOCOL_SERVICE_REMOTE_STR, read, write), "create client");
|
TEST_ASSIGN(
|
||||||
|
client,
|
||||||
|
protocolClientNew(STRDEF("test"), PROTOCOL_SERVICE_REMOTE_STR,
|
||||||
|
ioFdReadNewOpen(STRDEF("server read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 2000),
|
||||||
|
ioFdWriteNewOpen(STRDEF("server write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 2000)),
|
||||||
|
"create client");
|
||||||
protocolClientNoOp(client);
|
protocolClientNoOp(client);
|
||||||
protocolClientFree(client);
|
protocolClientFree(client);
|
||||||
}
|
}
|
||||||
@ -111,14 +109,12 @@ testRun(void)
|
|||||||
|
|
||||||
HARNESS_FORK_PARENT_BEGIN()
|
HARNESS_FORK_PARENT_BEGIN()
|
||||||
{
|
{
|
||||||
IoRead *read = ioFdReadNew(STRDEF("server read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 2000);
|
|
||||||
ioReadOpen(read);
|
|
||||||
IoWrite *write = ioFdWriteNew(STRDEF("server write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 2000);
|
|
||||||
ioWriteOpen(write);
|
|
||||||
|
|
||||||
TEST_ERROR(
|
TEST_ERROR(
|
||||||
protocolClientNew(STRDEF("test"), PROTOCOL_SERVICE_REMOTE_STR, read, write), PathCreateError,
|
protocolClientNew(
|
||||||
"raised from test: unable to create path '/bogus': [13] Permission denied");
|
STRDEF("test"), PROTOCOL_SERVICE_REMOTE_STR,
|
||||||
|
ioFdReadNewOpen(STRDEF("server read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 2000),
|
||||||
|
ioFdWriteNewOpen(STRDEF("server write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 2000)),
|
||||||
|
PathCreateError, "raised from test: unable to create path '/bogus': [13] Permission denied");
|
||||||
}
|
}
|
||||||
HARNESS_FORK_PARENT_END();
|
HARNESS_FORK_PARENT_END();
|
||||||
}
|
}
|
||||||
@ -144,13 +140,14 @@ testRun(void)
|
|||||||
|
|
||||||
HARNESS_FORK_PARENT_BEGIN()
|
HARNESS_FORK_PARENT_BEGIN()
|
||||||
{
|
{
|
||||||
IoRead *read = ioFdReadNew(STRDEF("server read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 2000);
|
|
||||||
ioReadOpen(read);
|
|
||||||
IoWrite *write = ioFdWriteNew(STRDEF("server write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 2000);
|
|
||||||
ioWriteOpen(write);
|
|
||||||
|
|
||||||
ProtocolClient *client = NULL;
|
ProtocolClient *client = NULL;
|
||||||
TEST_ASSIGN(client, protocolClientNew(STRDEF("test"), PROTOCOL_SERVICE_REMOTE_STR, read, write), "create client");
|
TEST_ASSIGN(
|
||||||
|
client,
|
||||||
|
protocolClientNew(
|
||||||
|
STRDEF("test"), PROTOCOL_SERVICE_REMOTE_STR,
|
||||||
|
ioFdReadNewOpen(STRDEF("server read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 2000),
|
||||||
|
ioFdWriteNewOpen(STRDEF("server write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 2000)),
|
||||||
|
"create client");
|
||||||
protocolClientNoOp(client);
|
protocolClientNoOp(client);
|
||||||
|
|
||||||
TEST_RESULT_BOOL(
|
TEST_RESULT_BOOL(
|
||||||
@ -182,16 +179,14 @@ testRun(void)
|
|||||||
|
|
||||||
HARNESS_FORK_PARENT_BEGIN()
|
HARNESS_FORK_PARENT_BEGIN()
|
||||||
{
|
{
|
||||||
IoRead *read = ioFdReadNew(STRDEF("server read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 2000);
|
|
||||||
ioReadOpen(read);
|
|
||||||
IoWrite *write = ioFdWriteNew(STRDEF("server write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 2000);
|
|
||||||
ioWriteOpen(write);
|
|
||||||
|
|
||||||
storagePutP(storageNewWriteP(hrnStorage, STRDEF("lock/all" STOP_FILE_EXT)), NULL);
|
storagePutP(storageNewWriteP(hrnStorage, STRDEF("lock/all" STOP_FILE_EXT)), NULL);
|
||||||
|
|
||||||
TEST_ERROR(
|
TEST_ERROR(
|
||||||
protocolClientNew(STRDEF("test"), PROTOCOL_SERVICE_REMOTE_STR, read, write), StopError,
|
protocolClientNew(
|
||||||
"raised from test: stop file exists for all stanzas");
|
STRDEF("test"), PROTOCOL_SERVICE_REMOTE_STR,
|
||||||
|
ioFdReadNewOpen(STRDEF("server read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 2000),
|
||||||
|
ioFdWriteNewOpen(STRDEF("server write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 2000)),
|
||||||
|
StopError, "raised from test: stop file exists for all stanzas");
|
||||||
|
|
||||||
storageRemoveP(hrnStorage, STRDEF("lock/all" STOP_FILE_EXT));
|
storageRemoveP(hrnStorage, STRDEF("lock/all" STOP_FILE_EXT));
|
||||||
}
|
}
|
||||||
|
@ -543,8 +543,7 @@ testRun(void)
|
|||||||
{
|
{
|
||||||
IoWrite *write = NULL;
|
IoWrite *write = NULL;
|
||||||
|
|
||||||
TEST_ASSIGN(write, ioFdWriteNew(STRDEF("write test"), HARNESS_FORK_CHILD_WRITE(), 1000), "move write");
|
TEST_ASSIGN(write, ioFdWriteNewOpen(STRDEF("write test"), HARNESS_FORK_CHILD_WRITE(), 1000), "move write");
|
||||||
ioWriteOpen(write);
|
|
||||||
TEST_RESULT_BOOL(ioWriteReadyP(write), true, "write is ready");
|
TEST_RESULT_BOOL(ioWriteReadyP(write), true, "write is ready");
|
||||||
TEST_RESULT_INT(ioWriteFd(write), ((IoFdWrite *)write->driver)->fd, "check write fd");
|
TEST_RESULT_INT(ioWriteFd(write), ((IoFdWrite *)write->driver)->fd, "check write fd");
|
||||||
|
|
||||||
@ -568,9 +567,8 @@ testRun(void)
|
|||||||
|
|
||||||
HARNESS_FORK_PARENT_BEGIN()
|
HARNESS_FORK_PARENT_BEGIN()
|
||||||
{
|
{
|
||||||
IoRead *read = ioFdReadNew(STRDEF("read test"), HARNESS_FORK_PARENT_READ_PROCESS(0), 1000);
|
IoRead *read = ioFdReadNewOpen(STRDEF("read test"), HARNESS_FORK_PARENT_READ_PROCESS(0), 1000);
|
||||||
|
|
||||||
ioReadOpen(read);
|
|
||||||
TEST_RESULT_INT(ioReadFd(read), ((IoFdRead *)ioReadDriver(read))->fd, "check fd");
|
TEST_RESULT_INT(ioReadFd(read), ((IoFdRead *)ioReadDriver(read))->fd, "check fd");
|
||||||
TEST_RESULT_PTR(ioReadInterface(read), &read->pub.interface, "check interface");
|
TEST_RESULT_PTR(ioReadInterface(read), &read->pub.interface, "check interface");
|
||||||
TEST_RESULT_PTR(ioReadDriver(read), read->pub.driver, "check driver");
|
TEST_RESULT_PTR(ioReadDriver(read), read->pub.driver, "check driver");
|
||||||
|
@ -24,11 +24,6 @@ testRun(void)
|
|||||||
{
|
{
|
||||||
HARNESS_FORK_CHILD_BEGIN(0, true)
|
HARNESS_FORK_CHILD_BEGIN(0, true)
|
||||||
{
|
{
|
||||||
IoRead *read = ioFdReadNew(STRDEF("client read"), HARNESS_FORK_CHILD_READ(), 2000);
|
|
||||||
ioReadOpen(read);
|
|
||||||
IoWrite *write = ioFdWriteNew(STRDEF("client write"), HARNESS_FORK_CHILD_WRITE(), 2000);
|
|
||||||
ioWriteOpen(write);
|
|
||||||
|
|
||||||
StringList *argList = strLstNew();
|
StringList *argList = strLstNew();
|
||||||
strLstAddZ(argList, "--stanza=test1");
|
strLstAddZ(argList, "--stanza=test1");
|
||||||
hrnCfgArgRawZ(argList, cfgOptPgPath, "/path/to/pg");
|
hrnCfgArgRawZ(argList, cfgOptPgPath, "/path/to/pg");
|
||||||
@ -36,7 +31,9 @@ testRun(void)
|
|||||||
strLstAddZ(argList, "--repo1-host-user=repo-host-user");
|
strLstAddZ(argList, "--repo1-host-user=repo-host-user");
|
||||||
HRN_CFG_LOAD(cfgCmdArchiveGet, argList);
|
HRN_CFG_LOAD(cfgCmdArchiveGet, argList);
|
||||||
|
|
||||||
ProtocolServer *server = protocolServerNew(STRDEF("test"), STRDEF("config"), read, write);
|
ProtocolServer *server = protocolServerNew(
|
||||||
|
STRDEF("test"), STRDEF("config"), ioFdReadNewOpen(STRDEF("client read"), HARNESS_FORK_CHILD_READ(), 2000),
|
||||||
|
ioFdWriteNewOpen(STRDEF("client write"), HARNESS_FORK_CHILD_WRITE(), 2000));
|
||||||
|
|
||||||
static const ProtocolServerHandler commandHandler[] = {PROTOCOL_SERVER_HANDLER_OPTION_LIST};
|
static const ProtocolServerHandler commandHandler[] = {PROTOCOL_SERVER_HANDLER_OPTION_LIST};
|
||||||
protocolServerProcess(server, NULL, commandHandler, PROTOCOL_SERVER_HANDLER_LIST_SIZE(commandHandler));
|
protocolServerProcess(server, NULL, commandHandler, PROTOCOL_SERVER_HANDLER_LIST_SIZE(commandHandler));
|
||||||
@ -45,12 +42,10 @@ testRun(void)
|
|||||||
|
|
||||||
HARNESS_FORK_PARENT_BEGIN()
|
HARNESS_FORK_PARENT_BEGIN()
|
||||||
{
|
{
|
||||||
IoRead *read = ioFdReadNew(STRDEF("server read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 2000);
|
ProtocolClient *client = protocolClientNew(
|
||||||
ioReadOpen(read);
|
STRDEF("test"), STRDEF("config"),
|
||||||
IoWrite *write = ioFdWriteNew(STRDEF("server write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 2000);
|
ioFdReadNewOpen(STRDEF("server read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 2000),
|
||||||
ioWriteOpen(write);
|
ioFdWriteNewOpen(STRDEF("server write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 2000));
|
||||||
|
|
||||||
ProtocolClient *client = protocolClientNew(STRDEF("test"), STRDEF("config"), read, write);
|
|
||||||
|
|
||||||
VariantList *list = varLstNew();
|
VariantList *list = varLstNew();
|
||||||
varLstAdd(list, varNewStr(STRDEF("repo1-host")));
|
varLstAdd(list, varNewStr(STRDEF("repo1-host")));
|
||||||
|
@ -63,11 +63,6 @@ testRun(void)
|
|||||||
{
|
{
|
||||||
HARNESS_FORK_CHILD_BEGIN(0, true)
|
HARNESS_FORK_CHILD_BEGIN(0, true)
|
||||||
{
|
{
|
||||||
IoRead *read = ioFdReadNew(STRDEF("client read"), HARNESS_FORK_CHILD_READ(), 2000);
|
|
||||||
ioReadOpen(read);
|
|
||||||
IoWrite *write = ioFdWriteNew(STRDEF("client write"), HARNESS_FORK_CHILD_WRITE(), 2000);
|
|
||||||
ioWriteOpen(write);
|
|
||||||
|
|
||||||
// Set options
|
// Set options
|
||||||
StringList *argList = strLstNew();
|
StringList *argList = strLstNew();
|
||||||
strLstAddZ(argList, "--stanza=test1");
|
strLstAddZ(argList, "--stanza=test1");
|
||||||
@ -99,7 +94,13 @@ testRun(void)
|
|||||||
// Create server
|
// Create server
|
||||||
ProtocolServer *server = NULL;
|
ProtocolServer *server = NULL;
|
||||||
|
|
||||||
TEST_ASSIGN(server, protocolServerNew(STRDEF("db test server"), STRDEF("test"), read, write), "create server");
|
TEST_ASSIGN(
|
||||||
|
server,
|
||||||
|
protocolServerNew(
|
||||||
|
STRDEF("db test server"), STRDEF("test"),
|
||||||
|
ioFdReadNewOpen(STRDEF("client read"), HARNESS_FORK_CHILD_READ(), 2000),
|
||||||
|
ioFdWriteNewOpen(STRDEF("client write"), HARNESS_FORK_CHILD_WRITE(), 2000)),
|
||||||
|
"create server");
|
||||||
|
|
||||||
static const ProtocolServerHandler commandHandler[] = {PROTOCOL_SERVER_HANDLER_DB_LIST};
|
static const ProtocolServerHandler commandHandler[] = {PROTOCOL_SERVER_HANDLER_DB_LIST};
|
||||||
|
|
||||||
@ -112,16 +113,17 @@ testRun(void)
|
|||||||
|
|
||||||
HARNESS_FORK_PARENT_BEGIN()
|
HARNESS_FORK_PARENT_BEGIN()
|
||||||
{
|
{
|
||||||
IoRead *read = ioFdReadNew(STRDEF("server read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 2000);
|
|
||||||
ioReadOpen(read);
|
|
||||||
IoWrite *write = ioFdWriteNew(STRDEF("server write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 2000);
|
|
||||||
ioWriteOpen(write);
|
|
||||||
|
|
||||||
// Create client
|
// Create client
|
||||||
ProtocolClient *client = NULL;
|
ProtocolClient *client = NULL;
|
||||||
Db *db = NULL;
|
Db *db = NULL;
|
||||||
|
|
||||||
TEST_ASSIGN(client, protocolClientNew(STRDEF("db test client"), STRDEF("test"), read, write), "create client");
|
TEST_ASSIGN(
|
||||||
|
client,
|
||||||
|
protocolClientNew(
|
||||||
|
STRDEF("db test client"), STRDEF("test"),
|
||||||
|
ioFdReadNewOpen(STRDEF("server read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 2000),
|
||||||
|
ioFdWriteNewOpen(STRDEF("server write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 2000)),
|
||||||
|
"create client");
|
||||||
|
|
||||||
TRY_BEGIN()
|
TRY_BEGIN()
|
||||||
{
|
{
|
||||||
|
@ -172,12 +172,10 @@ testRun(void)
|
|||||||
strIdFromZ(stringIdBit6, "test"), STRDEF("/"), 0, 0, false, NULL, &driver, driver.interface);
|
strIdFromZ(stringIdBit6, "test"), STRDEF("/"), 0, 0, false, NULL, &driver, driver.interface);
|
||||||
|
|
||||||
// Setup handler for remote storage protocol
|
// Setup handler for remote storage protocol
|
||||||
IoRead *read = ioFdReadNew(STRDEF("storage server read"), HARNESS_FORK_CHILD_READ(), 60000);
|
ProtocolServer *server = protocolServerNew(
|
||||||
ioReadOpen(read);
|
STRDEF("storage test server"), STRDEF("test"),
|
||||||
IoWrite *write = ioFdWriteNew(STRDEF("storage server write"), HARNESS_FORK_CHILD_WRITE(), 1000);
|
ioFdReadNewOpen(STRDEF("storage server read"), HARNESS_FORK_CHILD_READ(), 60000),
|
||||||
ioWriteOpen(write);
|
ioFdWriteNewOpen(STRDEF("storage server write"), HARNESS_FORK_CHILD_WRITE(), 1000));
|
||||||
|
|
||||||
ProtocolServer *server = protocolServerNew(STRDEF("storage test server"), STRDEF("test"), read, write);
|
|
||||||
|
|
||||||
static const ProtocolServerHandler commandHandler[] = {PROTOCOL_SERVER_HANDLER_STORAGE_REMOTE_LIST};
|
static const ProtocolServerHandler commandHandler[] = {PROTOCOL_SERVER_HANDLER_STORAGE_REMOTE_LIST};
|
||||||
protocolServerProcess(server, NULL, commandHandler, PROTOCOL_SERVER_HANDLER_LIST_SIZE(commandHandler));
|
protocolServerProcess(server, NULL, commandHandler, PROTOCOL_SERVER_HANDLER_LIST_SIZE(commandHandler));
|
||||||
@ -188,12 +186,10 @@ testRun(void)
|
|||||||
HARNESS_FORK_PARENT_BEGIN()
|
HARNESS_FORK_PARENT_BEGIN()
|
||||||
{
|
{
|
||||||
// Create client
|
// Create client
|
||||||
IoRead *read = ioFdReadNew(STRDEF("storage client read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 60000);
|
ProtocolClient *client = protocolClientNew(
|
||||||
ioReadOpen(read);
|
STRDEF("storage test client"), STRDEF("test"),
|
||||||
IoWrite *write = ioFdWriteNew(STRDEF("storage client write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 1000);
|
ioFdReadNewOpen(STRDEF("storage client read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 60000),
|
||||||
ioWriteOpen(write);
|
ioFdWriteNewOpen(STRDEF("storage client write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 1000));
|
||||||
|
|
||||||
ProtocolClient *client = protocolClientNew(STRDEF("storage test client"), STRDEF("test"), read, write);
|
|
||||||
|
|
||||||
// Create remote storage
|
// Create remote storage
|
||||||
Storage *storageRemote = storageRemoteNew(
|
Storage *storageRemote = storageRemoteNew(
|
||||||
|
@ -437,10 +437,8 @@ testRun(void)
|
|||||||
{
|
{
|
||||||
HARNESS_FORK_CHILD_BEGIN(0, true)
|
HARNESS_FORK_CHILD_BEGIN(0, true)
|
||||||
{
|
{
|
||||||
IoRead *read = ioFdReadNew(STRDEF("server read"), HARNESS_FORK_CHILD_READ(), 2000);
|
IoRead *read = ioFdReadNewOpen(STRDEF("server read"), HARNESS_FORK_CHILD_READ(), 2000);
|
||||||
ioReadOpen(read);
|
IoWrite *write = ioFdWriteNewOpen(STRDEF("server write"), HARNESS_FORK_CHILD_WRITE(), 2000);
|
||||||
IoWrite *write = ioFdWriteNew(STRDEF("server write"), HARNESS_FORK_CHILD_WRITE(), 2000);
|
|
||||||
ioWriteOpen(write);
|
|
||||||
|
|
||||||
// Various bogus greetings
|
// Various bogus greetings
|
||||||
// -----------------------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------------------
|
||||||
@ -494,10 +492,8 @@ testRun(void)
|
|||||||
|
|
||||||
HARNESS_FORK_PARENT_BEGIN()
|
HARNESS_FORK_PARENT_BEGIN()
|
||||||
{
|
{
|
||||||
IoRead *read = ioFdReadNew(STRDEF("client read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 2000);
|
IoRead *read = ioFdReadNewOpen(STRDEF("client read"), HARNESS_FORK_PARENT_READ_PROCESS(0), 2000);
|
||||||
ioReadOpen(read);
|
IoWrite *write = ioFdWriteNewOpen(STRDEF("client write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 2000);
|
||||||
IoWrite *write = ioFdWriteNew(STRDEF("client write"), HARNESS_FORK_PARENT_WRITE_PROCESS(0), 2000);
|
|
||||||
ioWriteOpen(write);
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------------------
|
||||||
TEST_TITLE("bogus greetings");
|
TEST_TITLE("bogus greetings");
|
||||||
@ -665,13 +661,14 @@ testRun(void)
|
|||||||
// Local 1
|
// Local 1
|
||||||
HARNESS_FORK_CHILD_BEGIN(0, true)
|
HARNESS_FORK_CHILD_BEGIN(0, true)
|
||||||
{
|
{
|
||||||
IoRead *read = ioFdReadNew(STRDEF("local server 1 read"), HARNESS_FORK_CHILD_READ(), 10000);
|
|
||||||
ioReadOpen(read);
|
|
||||||
IoWrite *write = ioFdWriteNew(STRDEF("local server 1 write"), HARNESS_FORK_CHILD_WRITE(), 2000);
|
|
||||||
ioWriteOpen(write);
|
|
||||||
|
|
||||||
ProtocolServer *server = NULL;
|
ProtocolServer *server = NULL;
|
||||||
TEST_ASSIGN(server, protocolServerNew(STRDEF("local server 1"), STRDEF("test"), read, write), "local server 1");
|
TEST_ASSIGN(
|
||||||
|
server,
|
||||||
|
protocolServerNew(
|
||||||
|
STRDEF("local server 1"), STRDEF("test"),
|
||||||
|
ioFdReadNewOpen(STRDEF("local server 1 read"), HARNESS_FORK_CHILD_READ(), 10000),
|
||||||
|
ioFdWriteNewOpen(STRDEF("local server 1 write"), HARNESS_FORK_CHILD_WRITE(), 2000)),
|
||||||
|
"local server 1");
|
||||||
|
|
||||||
TEST_RESULT_UINT(protocolServerCommandGet(server).id, PROTOCOL_COMMAND_NOOP, "noop command get");
|
TEST_RESULT_UINT(protocolServerCommandGet(server).id, PROTOCOL_COMMAND_NOOP, "noop command get");
|
||||||
TEST_RESULT_VOID(protocolServerDataEndPut(server), "data end put");
|
TEST_RESULT_VOID(protocolServerDataEndPut(server), "data end put");
|
||||||
@ -692,13 +689,14 @@ testRun(void)
|
|||||||
// Local 2
|
// Local 2
|
||||||
HARNESS_FORK_CHILD_BEGIN(0, true)
|
HARNESS_FORK_CHILD_BEGIN(0, true)
|
||||||
{
|
{
|
||||||
IoRead *read = ioFdReadNew(STRDEF("local server 2 read"), HARNESS_FORK_CHILD_READ(), 10000);
|
|
||||||
ioReadOpen(read);
|
|
||||||
IoWrite *write = ioFdWriteNew(STRDEF("local server 2 write"), HARNESS_FORK_CHILD_WRITE(), 2000);
|
|
||||||
ioWriteOpen(write);
|
|
||||||
|
|
||||||
ProtocolServer *server = NULL;
|
ProtocolServer *server = NULL;
|
||||||
TEST_ASSIGN(server, protocolServerNew(STRDEF("local server 2"), STRDEF("test"), read, write), "local server 2");
|
TEST_ASSIGN(
|
||||||
|
server,
|
||||||
|
protocolServerNew(
|
||||||
|
STRDEF("local server 2"), STRDEF("test"),
|
||||||
|
ioFdReadNewOpen(STRDEF("local server 2 read"), HARNESS_FORK_CHILD_READ(), 10000),
|
||||||
|
ioFdWriteNewOpen(STRDEF("local server 2 write"), HARNESS_FORK_CHILD_WRITE(), 2000)),
|
||||||
|
"local server 2");
|
||||||
|
|
||||||
TEST_RESULT_UINT(protocolServerCommandGet(server).id, PROTOCOL_COMMAND_NOOP, "noop command get");
|
TEST_RESULT_UINT(protocolServerCommandGet(server).id, PROTOCOL_COMMAND_NOOP, "noop command get");
|
||||||
TEST_RESULT_VOID(protocolServerDataEndPut(server), "data end put");
|
TEST_RESULT_VOID(protocolServerDataEndPut(server), "data end put");
|
||||||
@ -733,16 +731,14 @@ testRun(void)
|
|||||||
|
|
||||||
for (unsigned int clientIdx = 0; clientIdx < clientTotal; clientIdx++)
|
for (unsigned int clientIdx = 0; clientIdx < clientTotal; clientIdx++)
|
||||||
{
|
{
|
||||||
IoRead *read = ioFdReadNew(
|
|
||||||
strNewFmt("local client %u read", clientIdx), HARNESS_FORK_PARENT_READ_PROCESS(clientIdx), 2000);
|
|
||||||
ioReadOpen(read);
|
|
||||||
IoWrite *write = ioFdWriteNew(
|
|
||||||
strNewFmt("local client %u write", clientIdx), HARNESS_FORK_PARENT_WRITE_PROCESS(clientIdx), 2000);
|
|
||||||
ioWriteOpen(write);
|
|
||||||
|
|
||||||
TEST_ASSIGN(
|
TEST_ASSIGN(
|
||||||
client[clientIdx],
|
client[clientIdx],
|
||||||
protocolClientNew(strNewFmt("local client %u", clientIdx), STRDEF("test"), read, write),
|
protocolClientNew(
|
||||||
|
strNewFmt("local client %u", clientIdx), STRDEF("test"),
|
||||||
|
ioFdReadNewOpen(
|
||||||
|
strNewFmt("local client %u read", clientIdx), HARNESS_FORK_PARENT_READ_PROCESS(clientIdx), 2000),
|
||||||
|
ioFdWriteNewOpen(
|
||||||
|
strNewFmt("local client %u write", clientIdx), HARNESS_FORK_PARENT_WRITE_PROCESS(clientIdx), 2000)),
|
||||||
strZ(strNewFmt("local client %u new", clientIdx)));
|
strZ(strNewFmt("local client %u new", clientIdx)));
|
||||||
TEST_RESULT_VOID(
|
TEST_RESULT_VOID(
|
||||||
protocolParallelClientAdd(parallel, client[clientIdx]), strZ(strNewFmt("local client %u add", clientIdx)));
|
protocolParallelClientAdd(parallel, client[clientIdx]), strZ(strNewFmt("local client %u add", clientIdx)));
|
||||||
|
Reference in New Issue
Block a user