refactor: XArch Classes => Arch Exception Classes
This commit is contained in:
parent
8929f85bf7
commit
85d89f9846
27 changed files with 336 additions and 336 deletions
205
src/lib/arch/ArchException.h
Normal file
205
src/lib/arch/ArchException.h
Normal file
|
|
@ -0,0 +1,205 @@
|
||||||
|
/*
|
||||||
|
* Deskflow -- mouse and keyboard sharing utility
|
||||||
|
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||||
|
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
||||||
|
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/Common.h"
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
//! Generic thread exception
|
||||||
|
/*!
|
||||||
|
Exceptions derived from this class are used by the multithreading
|
||||||
|
library to perform stack unwinding when a thread terminates. These
|
||||||
|
exceptions must always be rethrown by clients when caught.
|
||||||
|
*/
|
||||||
|
class ThreadException : public std::exception
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Thread exception to cancel
|
||||||
|
/*!
|
||||||
|
Thrown to cancel a thread. Clients must not throw this type, but
|
||||||
|
must rethrow it if caught (by ThreadCancelException, ThreadException, or ...).
|
||||||
|
*/
|
||||||
|
class ThreadCancelException : public ThreadException
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\def RETHROW_THREADEXCEPTION
|
||||||
|
Convenience macro to rethrow an ThreadException exception but ignore other
|
||||||
|
exceptions. Put this in your catch (...) handler after necessary
|
||||||
|
cleanup but before leaving or returning from the handler.
|
||||||
|
*/
|
||||||
|
#define RETHROW_THREADEXCEPTION \
|
||||||
|
try { \
|
||||||
|
throw; \
|
||||||
|
} catch (ThreadException &) { \
|
||||||
|
throw; \
|
||||||
|
} catch (...) { \
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Generic network exception
|
||||||
|
/*!
|
||||||
|
Exceptions derived from this class are used by the networking
|
||||||
|
library to indicate various errors.
|
||||||
|
*/
|
||||||
|
class ArchNetworkException : public std::runtime_error
|
||||||
|
{
|
||||||
|
using std::runtime_error::runtime_error;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Operation was interrupted
|
||||||
|
class ArchNetworkInterruptedException : public ArchNetworkException
|
||||||
|
{
|
||||||
|
using ArchNetworkException::ArchNetworkException;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Network insufficient permission
|
||||||
|
class ArchNetworkAccessException : public ArchNetworkException
|
||||||
|
{
|
||||||
|
using ArchNetworkException::ArchNetworkException;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Network insufficient resources
|
||||||
|
class ArchNetworkResourceException : public ArchNetworkException
|
||||||
|
{
|
||||||
|
using ArchNetworkException::ArchNetworkException;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! No support for requested network resource/service
|
||||||
|
class ArchNetworkSupportException : public ArchNetworkException
|
||||||
|
{
|
||||||
|
using ArchNetworkException::ArchNetworkException;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Network I/O error
|
||||||
|
class ArchNetworkIOException : public ArchNetworkException
|
||||||
|
{
|
||||||
|
using ArchNetworkException::ArchNetworkException;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Network address is unavailable or not local
|
||||||
|
class ArchNetworkNoAddressException : public ArchNetworkException
|
||||||
|
{
|
||||||
|
using ArchNetworkException::ArchNetworkException;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Network address in use
|
||||||
|
class ArchNetworkAddressInUseException : public ArchNetworkException
|
||||||
|
{
|
||||||
|
using ArchNetworkException::ArchNetworkException;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! No route to address
|
||||||
|
class ArchNetworkNoRouteException : public ArchNetworkException
|
||||||
|
{
|
||||||
|
using ArchNetworkException::ArchNetworkException;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Socket not connected
|
||||||
|
class ArchNetworkNotConnectedException : public ArchNetworkException
|
||||||
|
{
|
||||||
|
using ArchNetworkException::ArchNetworkException;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Remote read end of socket has closed
|
||||||
|
class ArchNetworkShutdownException : public ArchNetworkException
|
||||||
|
{
|
||||||
|
using ArchNetworkException::ArchNetworkException;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Remote end of socket has disconnected
|
||||||
|
class ArchNetworkDisconnectedException : public ArchNetworkException
|
||||||
|
{
|
||||||
|
using ArchNetworkException::ArchNetworkException;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Remote end of socket refused connection
|
||||||
|
class ArchNetworkConnectionRefusedException : public ArchNetworkException
|
||||||
|
{
|
||||||
|
using ArchNetworkException::ArchNetworkException;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Remote end of socket is not responding
|
||||||
|
class ArchNetworkTimedOutException : public ArchNetworkException
|
||||||
|
{
|
||||||
|
using ArchNetworkException::ArchNetworkException;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Generic network name lookup erros
|
||||||
|
class ArchNetworkNameException : public ArchNetworkException
|
||||||
|
{
|
||||||
|
using ArchNetworkException::ArchNetworkException;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! The named host is unknown
|
||||||
|
class ArchNetworkNameUnknownException : public ArchNetworkNameException
|
||||||
|
{
|
||||||
|
using ArchNetworkNameException::ArchNetworkNameException;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! The named host is known but has no address
|
||||||
|
class ArchNetworkNameNoAddressException : public ArchNetworkNameException
|
||||||
|
{
|
||||||
|
using ArchNetworkNameException::ArchNetworkNameException;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Non-recoverable name server error
|
||||||
|
class ArchNetworkNameFailureException : public ArchNetworkNameException
|
||||||
|
{
|
||||||
|
using ArchNetworkNameException::ArchNetworkNameException;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Temporary name server error
|
||||||
|
class ArchNetworkNameUnavailableException : public ArchNetworkNameException
|
||||||
|
{
|
||||||
|
using ArchNetworkNameException::ArchNetworkNameException;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! The named host is known but no supported address
|
||||||
|
class ArchNetworkNameUnsupportedException : public ArchNetworkNameException
|
||||||
|
{
|
||||||
|
using ArchNetworkNameException::ArchNetworkNameException;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Generic daemon exception
|
||||||
|
/*!
|
||||||
|
Exceptions derived from this class are used by the daemon
|
||||||
|
library to indicate various errors.
|
||||||
|
*/
|
||||||
|
class ArchDaemonException : public std::runtime_error
|
||||||
|
{
|
||||||
|
using std::runtime_error::runtime_error;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Could not daemonize
|
||||||
|
class ArchDaemonFailedException : public ArchDaemonException
|
||||||
|
{
|
||||||
|
using ArchDaemonException::ArchDaemonException;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Could not install daemon
|
||||||
|
class ArchDaemonInstallException : public ArchDaemonException
|
||||||
|
{
|
||||||
|
using ArchDaemonException::ArchDaemonException;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Could not uninstall daemon
|
||||||
|
class ArchDaemonUninstallFailedException : public ArchDaemonException
|
||||||
|
{
|
||||||
|
using ArchDaemonException::ArchDaemonException;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Attempted to uninstall a daemon that was not installed
|
||||||
|
class ArchDaemonUninstallNotInstalledException : public ArchDaemonFailedException
|
||||||
|
{
|
||||||
|
using ArchDaemonFailedException::ArchDaemonFailedException;
|
||||||
|
};
|
||||||
|
|
@ -40,13 +40,13 @@ add_library(arch STATIC ${PLATFORM_CODE}
|
||||||
Arch.h
|
Arch.h
|
||||||
ArchDaemonNone.cpp
|
ArchDaemonNone.cpp
|
||||||
ArchDaemonNone.h
|
ArchDaemonNone.h
|
||||||
|
ArchException.h
|
||||||
IArchDaemon.h
|
IArchDaemon.h
|
||||||
IArchLog.h
|
IArchLog.h
|
||||||
IArchMultithread.h
|
IArchMultithread.h
|
||||||
IArchNetwork.h
|
IArchNetwork.h
|
||||||
ArchString.cpp
|
ArchString.cpp
|
||||||
ArchString.h
|
ArchString.h
|
||||||
XArch.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ public:
|
||||||
start when the current user logs in. If \p dependencies is not nullptr
|
start when the current user logs in. If \p dependencies is not nullptr
|
||||||
then it's a concatenation of NUL terminated other daemon names
|
then it's a concatenation of NUL terminated other daemon names
|
||||||
followed by a NUL; the daemon will be configured to startup after
|
followed by a NUL; the daemon will be configured to startup after
|
||||||
the listed daemons. Throws an \c XArchDaemon exception on failure.
|
the listed daemons. Throws an \c ArchDaemonException exception on failure.
|
||||||
*/
|
*/
|
||||||
virtual void installDaemon(
|
virtual void installDaemon(
|
||||||
const char *name, const char *description, const char *pathname, const char *commandLine, const char *dependencies
|
const char *name, const char *description, const char *pathname, const char *commandLine, const char *dependencies
|
||||||
|
|
@ -45,7 +45,7 @@ public:
|
||||||
|
|
||||||
//! Uninstall daemon
|
//! Uninstall daemon
|
||||||
/*!
|
/*!
|
||||||
Uninstall a daemon. Throws an \c XArchDaemon on failure.
|
Uninstall a daemon. Throws an \c ArchDaemonException on failure.
|
||||||
*/
|
*/
|
||||||
virtual void uninstallDaemon(const char *name) = 0;
|
virtual void uninstallDaemon(const char *name) = 0;
|
||||||
|
|
||||||
|
|
@ -63,7 +63,7 @@ public:
|
||||||
|
|
||||||
//! Daemonize the process
|
//! Daemonize the process
|
||||||
/*!
|
/*!
|
||||||
Daemonize. Throw XArchDaemonFailed on error. \c name is the name
|
Daemonize. Throw ArchDaemonFailedException on error. \c name is the name
|
||||||
of the daemon. Once daemonized, \c func is invoked and daemonize
|
of the daemon. Once daemonized, \c func is invoked and daemonize
|
||||||
returns when and what it does.
|
returns when and what it does.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -213,7 +213,7 @@ public:
|
||||||
//! Check error on socket
|
//! Check error on socket
|
||||||
/*!
|
/*!
|
||||||
If the socket \c s is in an error state then throws an appropriate
|
If the socket \c s is in an error state then throws an appropriate
|
||||||
XArchNetwork exception.
|
ArchNetworkException exception.
|
||||||
*/
|
*/
|
||||||
virtual void throwErrorOnSocket(ArchSocket s) = 0;
|
virtual void throwErrorOnSocket(ArchSocket s) = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,205 +0,0 @@
|
||||||
/*
|
|
||||||
* Deskflow -- mouse and keyboard sharing utility
|
|
||||||
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
|
||||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd.
|
|
||||||
* SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
|
|
||||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "common/Common.h"
|
|
||||||
|
|
||||||
#include <stdexcept>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
//! Generic thread exception
|
|
||||||
/*!
|
|
||||||
Exceptions derived from this class are used by the multithreading
|
|
||||||
library to perform stack unwinding when a thread terminates. These
|
|
||||||
exceptions must always be rethrown by clients when caught.
|
|
||||||
*/
|
|
||||||
class XThread : public std::exception
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Thread exception to cancel
|
|
||||||
/*!
|
|
||||||
Thrown to cancel a thread. Clients must not throw this type, but
|
|
||||||
must rethrow it if caught (by XThreadCancel, XThread, or ...).
|
|
||||||
*/
|
|
||||||
class XThreadCancel : public XThread
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\def RETHROW_XTHREAD
|
|
||||||
Convenience macro to rethrow an XThread exception but ignore other
|
|
||||||
exceptions. Put this in your catch (...) handler after necessary
|
|
||||||
cleanup but before leaving or returning from the handler.
|
|
||||||
*/
|
|
||||||
#define RETHROW_XTHREAD \
|
|
||||||
try { \
|
|
||||||
throw; \
|
|
||||||
} catch (XThread &) { \
|
|
||||||
throw; \
|
|
||||||
} catch (...) { \
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Generic network exception
|
|
||||||
/*!
|
|
||||||
Exceptions derived from this class are used by the networking
|
|
||||||
library to indicate various errors.
|
|
||||||
*/
|
|
||||||
class XArchNetwork : public std::runtime_error
|
|
||||||
{
|
|
||||||
using std::runtime_error::runtime_error;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Operation was interrupted
|
|
||||||
class XArchNetworkInterrupted : public XArchNetwork
|
|
||||||
{
|
|
||||||
using XArchNetwork::XArchNetwork;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Network insufficient permission
|
|
||||||
class XArchNetworkAccess : public XArchNetwork
|
|
||||||
{
|
|
||||||
using XArchNetwork::XArchNetwork;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Network insufficient resources
|
|
||||||
class XArchNetworkResource : public XArchNetwork
|
|
||||||
{
|
|
||||||
using XArchNetwork::XArchNetwork;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! No support for requested network resource/service
|
|
||||||
class XArchNetworkSupport : public XArchNetwork
|
|
||||||
{
|
|
||||||
using XArchNetwork::XArchNetwork;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Network I/O error
|
|
||||||
class XArchNetworkIO : public XArchNetwork
|
|
||||||
{
|
|
||||||
using XArchNetwork::XArchNetwork;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Network address is unavailable or not local
|
|
||||||
class XArchNetworkNoAddress : public XArchNetwork
|
|
||||||
{
|
|
||||||
using XArchNetwork::XArchNetwork;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Network address in use
|
|
||||||
class XArchNetworkAddressInUse : public XArchNetwork
|
|
||||||
{
|
|
||||||
using XArchNetwork::XArchNetwork;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! No route to address
|
|
||||||
class XArchNetworkNoRoute : public XArchNetwork
|
|
||||||
{
|
|
||||||
using XArchNetwork::XArchNetwork;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Socket not connected
|
|
||||||
class XArchNetworkNotConnected : public XArchNetwork
|
|
||||||
{
|
|
||||||
using XArchNetwork::XArchNetwork;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Remote read end of socket has closed
|
|
||||||
class XArchNetworkShutdown : public XArchNetwork
|
|
||||||
{
|
|
||||||
using XArchNetwork::XArchNetwork;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Remote end of socket has disconnected
|
|
||||||
class XArchNetworkDisconnected : public XArchNetwork
|
|
||||||
{
|
|
||||||
using XArchNetwork::XArchNetwork;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Remote end of socket refused connection
|
|
||||||
class XArchNetworkConnectionRefused : public XArchNetwork
|
|
||||||
{
|
|
||||||
using XArchNetwork::XArchNetwork;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Remote end of socket is not responding
|
|
||||||
class XArchNetworkTimedOut : public XArchNetwork
|
|
||||||
{
|
|
||||||
using XArchNetwork::XArchNetwork;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Generic network name lookup erros
|
|
||||||
class XArchNetworkName : public XArchNetwork
|
|
||||||
{
|
|
||||||
using XArchNetwork::XArchNetwork;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! The named host is unknown
|
|
||||||
class XArchNetworkNameUnknown : public XArchNetworkName
|
|
||||||
{
|
|
||||||
using XArchNetworkName::XArchNetworkName;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! The named host is known but has no address
|
|
||||||
class XArchNetworkNameNoAddress : public XArchNetworkName
|
|
||||||
{
|
|
||||||
using XArchNetworkName::XArchNetworkName;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Non-recoverable name server error
|
|
||||||
class XArchNetworkNameFailure : public XArchNetworkName
|
|
||||||
{
|
|
||||||
using XArchNetworkName::XArchNetworkName;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Temporary name server error
|
|
||||||
class XArchNetworkNameUnavailable : public XArchNetworkName
|
|
||||||
{
|
|
||||||
using XArchNetworkName::XArchNetworkName;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! The named host is known but no supported address
|
|
||||||
class XArchNetworkNameUnsupported : public XArchNetworkName
|
|
||||||
{
|
|
||||||
using XArchNetworkName::XArchNetworkName;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Generic daemon exception
|
|
||||||
/*!
|
|
||||||
Exceptions derived from this class are used by the daemon
|
|
||||||
library to indicate various errors.
|
|
||||||
*/
|
|
||||||
class XArchDaemon : public std::runtime_error
|
|
||||||
{
|
|
||||||
using std::runtime_error::runtime_error;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Could not daemonize
|
|
||||||
class XArchDaemonFailed : public XArchDaemon
|
|
||||||
{
|
|
||||||
using XArchDaemon::XArchDaemon;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Could not install daemon
|
|
||||||
class XArchDaemonInstallFailed : public XArchDaemon
|
|
||||||
{
|
|
||||||
using XArchDaemon::XArchDaemon;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Could not uninstall daemon
|
|
||||||
class XArchDaemonUninstallFailed : public XArchDaemon
|
|
||||||
{
|
|
||||||
using XArchDaemon::XArchDaemon;
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Attempted to uninstall a daemon that was not installed
|
|
||||||
class XArchDaemonUninstallNotInstalled : public XArchDaemonFailed
|
|
||||||
{
|
|
||||||
using XArchDaemonFailed::XArchDaemonFailed;
|
|
||||||
};
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
#include "arch/unix/ArchDaemonUnix.h"
|
#include "arch/unix/ArchDaemonUnix.h"
|
||||||
|
|
||||||
#include "arch/XArch.h"
|
#include "arch/ArchException.h"
|
||||||
#include "arch/unix/XArchUnix.h"
|
#include "arch/unix/XArchUnix.h"
|
||||||
#include "base/Log.h"
|
#include "base/Log.h"
|
||||||
|
|
||||||
|
|
@ -58,7 +58,7 @@ int ArchDaemonUnix::daemonize(const char *name, DaemonFunc const &func)
|
||||||
switch (fork()) {
|
switch (fork()) {
|
||||||
case -1:
|
case -1:
|
||||||
// failed
|
// failed
|
||||||
throw XArchDaemonFailed(errorToString(errno));
|
throw ArchDaemonFailedException(errorToString(errno));
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
// child
|
// child
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
#include "arch/unix/ArchMultithreadPosix.h"
|
#include "arch/unix/ArchMultithreadPosix.h"
|
||||||
|
|
||||||
#include "arch/Arch.h"
|
#include "arch/Arch.h"
|
||||||
#include "arch/XArch.h"
|
#include "arch/ArchException.h"
|
||||||
|
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
@ -584,7 +584,7 @@ void ArchMultithreadPosix::testCancelThreadImpl(ArchThreadImpl *thread)
|
||||||
|
|
||||||
// unwind thread's stack if cancelling
|
// unwind thread's stack if cancelling
|
||||||
if (cancel) {
|
if (cancel) {
|
||||||
throw XThreadCancel();
|
throw ThreadCancelException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -620,7 +620,7 @@ void ArchMultithreadPosix::doThreadFunc(ArchThread thread)
|
||||||
result = (*thread->m_func)(thread->m_userData);
|
result = (*thread->m_func)(thread->m_userData);
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (XThreadCancel &) {
|
catch (ThreadCancelException &) {
|
||||||
// client called cancel()
|
// client called cancel()
|
||||||
// set base value
|
// set base value
|
||||||
result = nullptr;
|
result = nullptr;
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
#include "arch/unix/ArchNetworkBSD.h"
|
#include "arch/unix/ArchNetworkBSD.h"
|
||||||
|
|
||||||
#include "arch/Arch.h"
|
#include "arch/Arch.h"
|
||||||
#include "arch/XArch.h"
|
#include "arch/ArchException.h"
|
||||||
#include "arch/unix/ArchMultithreadPosix.h"
|
#include "arch/unix/ArchMultithreadPosix.h"
|
||||||
#include "arch/unix/XArchUnix.h"
|
#include "arch/unix/XArchUnix.h"
|
||||||
|
|
||||||
|
|
@ -745,11 +745,11 @@ const int *ArchNetworkBSD::getUnblockPipeForThread(ArchThread thread)
|
||||||
switch (err) {
|
switch (err) {
|
||||||
case EINTR:
|
case EINTR:
|
||||||
ARCH->testCancelThread();
|
ARCH->testCancelThread();
|
||||||
throw XArchNetworkInterrupted(errorToString(err));
|
throw ArchNetworkInterruptedException(errorToString(err));
|
||||||
|
|
||||||
case EACCES:
|
case EACCES:
|
||||||
case EPERM:
|
case EPERM:
|
||||||
throw XArchNetworkAccess(errorToString(err));
|
throw ArchNetworkAccessException(errorToString(err));
|
||||||
|
|
||||||
case ENFILE:
|
case ENFILE:
|
||||||
case EMFILE:
|
case EMFILE:
|
||||||
|
|
@ -760,7 +760,7 @@ const int *ArchNetworkBSD::getUnblockPipeForThread(ArchThread thread)
|
||||||
#if defined(ENOSR)
|
#if defined(ENOSR)
|
||||||
case ENOSR:
|
case ENOSR:
|
||||||
#endif
|
#endif
|
||||||
throw XArchNetworkResource(errorToString(err));
|
throw ArchNetworkResourceException(errorToString(err));
|
||||||
|
|
||||||
case EPROTOTYPE:
|
case EPROTOTYPE:
|
||||||
case EPROTONOSUPPORT:
|
case EPROTONOSUPPORT:
|
||||||
|
|
@ -774,40 +774,40 @@ const int *ArchNetworkBSD::getUnblockPipeForThread(ArchThread thread)
|
||||||
#if defined(ENOPKG)
|
#if defined(ENOPKG)
|
||||||
case ENOPKG:
|
case ENOPKG:
|
||||||
#endif
|
#endif
|
||||||
throw XArchNetworkSupport(errorToString(err));
|
throw ArchNetworkSupportException(errorToString(err));
|
||||||
|
|
||||||
case EIO:
|
case EIO:
|
||||||
throw XArchNetworkIO(errorToString(err));
|
throw ArchNetworkIOException(errorToString(err));
|
||||||
|
|
||||||
case EADDRNOTAVAIL:
|
case EADDRNOTAVAIL:
|
||||||
throw XArchNetworkNoAddress(errorToString(err));
|
throw ArchNetworkNoAddressException(errorToString(err));
|
||||||
|
|
||||||
case EADDRINUSE:
|
case EADDRINUSE:
|
||||||
throw XArchNetworkAddressInUse(errorToString(err));
|
throw ArchNetworkAddressInUseException(errorToString(err));
|
||||||
|
|
||||||
case EHOSTUNREACH:
|
case EHOSTUNREACH:
|
||||||
case ENETUNREACH:
|
case ENETUNREACH:
|
||||||
throw XArchNetworkNoRoute(errorToString(err));
|
throw ArchNetworkNoRouteException(errorToString(err));
|
||||||
|
|
||||||
case ENOTCONN:
|
case ENOTCONN:
|
||||||
throw XArchNetworkNotConnected(errorToString(err));
|
throw ArchNetworkNotConnectedException(errorToString(err));
|
||||||
|
|
||||||
case EPIPE:
|
case EPIPE:
|
||||||
throw XArchNetworkShutdown(errorToString(err));
|
throw ArchNetworkShutdownException(errorToString(err));
|
||||||
|
|
||||||
case ECONNABORTED:
|
case ECONNABORTED:
|
||||||
case ECONNRESET:
|
case ECONNRESET:
|
||||||
throw XArchNetworkDisconnected(errorToString(err));
|
throw ArchNetworkDisconnectedException(errorToString(err));
|
||||||
|
|
||||||
case ECONNREFUSED:
|
case ECONNREFUSED:
|
||||||
throw XArchNetworkConnectionRefused(errorToString(err));
|
throw ArchNetworkConnectionRefusedException(errorToString(err));
|
||||||
|
|
||||||
case EHOSTDOWN:
|
case EHOSTDOWN:
|
||||||
case ETIMEDOUT:
|
case ETIMEDOUT:
|
||||||
throw XArchNetworkTimedOut(errorToString(err));
|
throw ArchNetworkTimedOutException(errorToString(err));
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw XArchNetwork(errorToString(err));
|
throw ArchNetworkException(errorToString(err));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -821,18 +821,18 @@ const int *ArchNetworkBSD::getUnblockPipeForThread(ArchThread thread)
|
||||||
|
|
||||||
switch (err) {
|
switch (err) {
|
||||||
case HOST_NOT_FOUND:
|
case HOST_NOT_FOUND:
|
||||||
throw XArchNetworkNameUnknown(s_msg[0]);
|
throw ArchNetworkNameUnknownException(s_msg[0]);
|
||||||
|
|
||||||
case NO_DATA:
|
case NO_DATA:
|
||||||
throw XArchNetworkNameNoAddress(s_msg[1]);
|
throw ArchNetworkNameNoAddressException(s_msg[1]);
|
||||||
|
|
||||||
case NO_RECOVERY:
|
case NO_RECOVERY:
|
||||||
throw XArchNetworkNameFailure(s_msg[2]);
|
throw ArchNetworkNameFailureException(s_msg[2]);
|
||||||
|
|
||||||
case TRY_AGAIN:
|
case TRY_AGAIN:
|
||||||
throw XArchNetworkNameUnavailable(s_msg[3]);
|
throw ArchNetworkNameUnavailableException(s_msg[3]);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw XArchNetworkName(s_msg[4]);
|
throw ArchNetworkNameException(s_msg[4]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
#include "arch/win32/ArchDaemonWindows.h"
|
#include "arch/win32/ArchDaemonWindows.h"
|
||||||
|
|
||||||
#include "arch/Arch.h"
|
#include "arch/Arch.h"
|
||||||
#include "arch/XArch.h"
|
#include "arch/ArchException.h"
|
||||||
#include "arch/win32/ArchMiscWindows.h"
|
#include "arch/win32/ArchMiscWindows.h"
|
||||||
#include "arch/win32/XArchWindows.h"
|
#include "arch/win32/XArchWindows.h"
|
||||||
#include "base/Log.h"
|
#include "base/Log.h"
|
||||||
|
|
@ -51,7 +51,7 @@ UINT ArchDaemonWindows::getDaemonQuitMessage()
|
||||||
void ArchDaemonWindows::daemonFailed(int result)
|
void ArchDaemonWindows::daemonFailed(int result)
|
||||||
{
|
{
|
||||||
assert(s_daemon != nullptr);
|
assert(s_daemon != nullptr);
|
||||||
throw XArchDaemonRunFailed(result);
|
throw ArchDaemonRunException(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArchDaemonWindows::installDaemon(
|
void ArchDaemonWindows::installDaemon(
|
||||||
|
|
@ -64,7 +64,7 @@ void ArchDaemonWindows::installDaemon(
|
||||||
SC_HANDLE mgr = OpenSCManager(nullptr, nullptr, GENERIC_WRITE);
|
SC_HANDLE mgr = OpenSCManager(nullptr, nullptr, GENERIC_WRITE);
|
||||||
if (mgr == nullptr) {
|
if (mgr == nullptr) {
|
||||||
// can't open service manager
|
// can't open service manager
|
||||||
throw XArchDaemonInstallFailed(windowsErrorToString(GetLastError()));
|
throw ArchDaemonInstallException(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the service
|
// create the service
|
||||||
|
|
@ -78,7 +78,7 @@ void ArchDaemonWindows::installDaemon(
|
||||||
DWORD err = GetLastError();
|
DWORD err = GetLastError();
|
||||||
if (err != ERROR_SERVICE_EXISTS) {
|
if (err != ERROR_SERVICE_EXISTS) {
|
||||||
CloseServiceHandle(mgr);
|
CloseServiceHandle(mgr);
|
||||||
throw XArchDaemonInstallFailed(windowsErrorToString(err));
|
throw ArchDaemonInstallException(windowsErrorToString(err));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// done with service (but only try to close if not null)
|
// done with service (but only try to close if not null)
|
||||||
|
|
@ -99,7 +99,7 @@ void ArchDaemonWindows::installDaemon(
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
throw XArchDaemonInstallFailed(windowsErrorToString(err));
|
throw ArchDaemonInstallException(windowsErrorToString(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the description
|
// set the description
|
||||||
|
|
@ -116,7 +116,7 @@ void ArchDaemonWindows::installDaemon(
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
throw XArchDaemonInstallFailed(windowsErrorToString(err));
|
throw ArchDaemonInstallException(windowsErrorToString(err));
|
||||||
}
|
}
|
||||||
ArchMiscWindows::setValue(key, _T("CommandLine"), commandLine);
|
ArchMiscWindows::setValue(key, _T("CommandLine"), commandLine);
|
||||||
|
|
||||||
|
|
@ -140,7 +140,7 @@ void ArchDaemonWindows::uninstallDaemon(const char *name)
|
||||||
SC_HANDLE mgr = OpenSCManager(nullptr, nullptr, GENERIC_WRITE);
|
SC_HANDLE mgr = OpenSCManager(nullptr, nullptr, GENERIC_WRITE);
|
||||||
if (mgr == nullptr) {
|
if (mgr == nullptr) {
|
||||||
// can't open service manager
|
// can't open service manager
|
||||||
throw XArchDaemonUninstallFailed(windowsErrorToString(GetLastError()));
|
throw ArchDaemonUninstallFailedException(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// open the service. oddly, you must open a service to delete it.
|
// open the service. oddly, you must open a service to delete it.
|
||||||
|
|
@ -149,9 +149,9 @@ void ArchDaemonWindows::uninstallDaemon(const char *name)
|
||||||
DWORD err = GetLastError();
|
DWORD err = GetLastError();
|
||||||
CloseServiceHandle(mgr);
|
CloseServiceHandle(mgr);
|
||||||
if (err != ERROR_SERVICE_DOES_NOT_EXIST) {
|
if (err != ERROR_SERVICE_DOES_NOT_EXIST) {
|
||||||
throw XArchDaemonUninstallFailed(windowsErrorToString(err));
|
throw ArchDaemonUninstallFailedException(windowsErrorToString(err));
|
||||||
}
|
}
|
||||||
throw XArchDaemonUninstallNotInstalled(windowsErrorToString(err));
|
throw ArchDaemonUninstallNotInstalledException(windowsErrorToString(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
// stop the service. we don't care if we fail.
|
// stop the service. we don't care if we fail.
|
||||||
|
|
@ -184,9 +184,9 @@ void ArchDaemonWindows::uninstallDaemon(const char *name)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (err != ERROR_SERVICE_MARKED_FOR_DELETE) {
|
if (err != ERROR_SERVICE_MARKED_FOR_DELETE) {
|
||||||
throw XArchDaemonUninstallFailed(windowsErrorToString(err));
|
throw ArchDaemonUninstallFailedException(windowsErrorToString(err));
|
||||||
}
|
}
|
||||||
throw XArchDaemonUninstallNotInstalled(windowsErrorToString(err));
|
throw ArchDaemonUninstallNotInstalledException(windowsErrorToString(err));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -211,7 +211,7 @@ int ArchDaemonWindows::daemonize(const char *name, DaemonFunc const &func)
|
||||||
if (StartServiceCtrlDispatcher(entry) == 0) {
|
if (StartServiceCtrlDispatcher(entry) == 0) {
|
||||||
// StartServiceCtrlDispatcher failed
|
// StartServiceCtrlDispatcher failed
|
||||||
s_daemon = nullptr;
|
s_daemon = nullptr;
|
||||||
throw XArchDaemonFailed(windowsErrorToString(GetLastError()));
|
throw ArchDaemonFailedException(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
s_daemon = nullptr;
|
s_daemon = nullptr;
|
||||||
|
|
@ -472,7 +472,7 @@ void ArchDaemonWindows::serviceMain(DWORD argc, LPTSTR *argvIn)
|
||||||
try {
|
try {
|
||||||
// invoke daemon function
|
// invoke daemon function
|
||||||
m_daemonResult = m_daemonFunc(static_cast<int>(argc), argv);
|
m_daemonResult = m_daemonFunc(static_cast<int>(argc), argv);
|
||||||
} catch (XArchDaemonRunFailed &e) {
|
} catch (ArchDaemonRunException &e) {
|
||||||
setStatusError(e.m_result);
|
setStatusError(e.m_result);
|
||||||
m_daemonResult = -1;
|
m_daemonResult = -1;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
|
@ -560,7 +560,7 @@ void ArchDaemonWindows::start(const char *name)
|
||||||
// open service manager
|
// open service manager
|
||||||
SC_HANDLE mgr = OpenSCManager(nullptr, nullptr, GENERIC_READ);
|
SC_HANDLE mgr = OpenSCManager(nullptr, nullptr, GENERIC_READ);
|
||||||
if (mgr == nullptr) {
|
if (mgr == nullptr) {
|
||||||
throw XArchDaemonFailed(windowsErrorToString(GetLastError()));
|
throw ArchDaemonFailedException(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// open the service
|
// open the service
|
||||||
|
|
@ -568,12 +568,12 @@ void ArchDaemonWindows::start(const char *name)
|
||||||
|
|
||||||
if (service == nullptr) {
|
if (service == nullptr) {
|
||||||
CloseServiceHandle(mgr);
|
CloseServiceHandle(mgr);
|
||||||
throw XArchDaemonFailed(windowsErrorToString(GetLastError()));
|
throw ArchDaemonFailedException(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// start the service
|
// start the service
|
||||||
if (!StartService(service, 0, nullptr)) {
|
if (!StartService(service, 0, nullptr)) {
|
||||||
throw XArchDaemonFailed(windowsErrorToString(GetLastError()));
|
throw ArchDaemonFailedException(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -582,7 +582,7 @@ void ArchDaemonWindows::stop(const char *name)
|
||||||
// open service manager
|
// open service manager
|
||||||
SC_HANDLE mgr = OpenSCManager(nullptr, nullptr, GENERIC_READ);
|
SC_HANDLE mgr = OpenSCManager(nullptr, nullptr, GENERIC_READ);
|
||||||
if (mgr == nullptr) {
|
if (mgr == nullptr) {
|
||||||
throw XArchDaemonFailed(windowsErrorToString(GetLastError()));
|
throw ArchDaemonFailedException(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// open the service
|
// open the service
|
||||||
|
|
@ -590,7 +590,7 @@ void ArchDaemonWindows::stop(const char *name)
|
||||||
|
|
||||||
if (service == nullptr) {
|
if (service == nullptr) {
|
||||||
CloseServiceHandle(mgr);
|
CloseServiceHandle(mgr);
|
||||||
throw XArchDaemonFailed(windowsErrorToString(GetLastError()));
|
throw ArchDaemonFailedException(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ask the service to stop, asynchronously
|
// ask the service to stop, asynchronously
|
||||||
|
|
@ -598,7 +598,7 @@ void ArchDaemonWindows::stop(const char *name)
|
||||||
if (!ControlService(service, SERVICE_CONTROL_STOP, &ss)) {
|
if (!ControlService(service, SERVICE_CONTROL_STOP, &ss)) {
|
||||||
DWORD dwErrCode = GetLastError();
|
DWORD dwErrCode = GetLastError();
|
||||||
if (dwErrCode != ERROR_SERVICE_NOT_ACTIVE) {
|
if (dwErrCode != ERROR_SERVICE_NOT_ACTIVE) {
|
||||||
throw XArchDaemonFailed(windowsErrorToString(GetLastError()));
|
throw ArchDaemonFailedException(windowsErrorToString(GetLastError()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -104,10 +104,10 @@ private:
|
||||||
void stop(const char *name);
|
void stop(const char *name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class XArchDaemonRunFailed
|
class ArchDaemonRunException
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
XArchDaemonRunFailed(int result) : m_result(result)
|
ArchDaemonRunException(int result) : m_result(result)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
#include "arch/win32/ArchMultithreadWindows.h"
|
#include "arch/win32/ArchMultithreadWindows.h"
|
||||||
#include "arch/Arch.h"
|
#include "arch/Arch.h"
|
||||||
#include "arch/XArch.h"
|
#include "arch/ArchException.h"
|
||||||
|
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
|
|
||||||
|
|
@ -577,7 +577,7 @@ void ArchMultithreadWindows::testCancelThreadImpl(ArchThreadImpl *thread)
|
||||||
|
|
||||||
// unwind thread's stack if cancelling
|
// unwind thread's stack if cancelling
|
||||||
if (cancel) {
|
if (cancel) {
|
||||||
throw XThreadCancel();
|
throw ThreadCancelException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -606,7 +606,7 @@ void ArchMultithreadWindows::doThreadFunc(ArchThread thread)
|
||||||
result = (*thread->m_func)(thread->m_userData);
|
result = (*thread->m_func)(thread->m_userData);
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (XThreadCancel &) {
|
catch (ThreadCancelException &) {
|
||||||
// client called cancel()
|
// client called cancel()
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
// note -- don't catch (...) to avoid masking bugs
|
// note -- don't catch (...) to avoid masking bugs
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@
|
||||||
|
|
||||||
#include "arch/win32/ArchNetworkWinsock.h"
|
#include "arch/win32/ArchNetworkWinsock.h"
|
||||||
#include "arch/Arch.h"
|
#include "arch/Arch.h"
|
||||||
|
#include "arch/ArchException.h"
|
||||||
#include "arch/IArchMultithread.h"
|
#include "arch/IArchMultithread.h"
|
||||||
#include "arch/XArch.h"
|
|
||||||
#include "arch/win32/ArchMultithreadWindows.h"
|
#include "arch/win32/ArchMultithreadWindows.h"
|
||||||
#include "arch/win32/XArchWindows.h"
|
#include "arch/win32/XArchWindows.h"
|
||||||
|
|
||||||
|
|
@ -65,7 +65,7 @@ static FARPROC netGetProcAddress(HMODULE module, LPCSTR name)
|
||||||
{
|
{
|
||||||
FARPROC func = ::GetProcAddress(module, name);
|
FARPROC func = ::GetProcAddress(module, name);
|
||||||
if (!func) {
|
if (!func) {
|
||||||
throw XArchNetworkSupport("");
|
throw ArchNetworkSupportException("");
|
||||||
}
|
}
|
||||||
return func;
|
return func;
|
||||||
}
|
}
|
||||||
|
|
@ -110,19 +110,19 @@ void ArchNetworkWinsock::init()
|
||||||
try {
|
try {
|
||||||
initModule((HMODULE)::LoadLibrary(s_library[i]));
|
initModule((HMODULE)::LoadLibrary(s_library[i]));
|
||||||
return;
|
return;
|
||||||
} catch (XArchNetwork &) {
|
} catch (ArchNetworkException &) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// can't initialize any library
|
// can't initialize any library
|
||||||
throw XArchNetworkSupport("Cannot load winsock library");
|
throw ArchNetworkSupportException("Cannot load winsock library");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArchNetworkWinsock::initModule(HMODULE module)
|
void ArchNetworkWinsock::initModule(HMODULE module)
|
||||||
{
|
{
|
||||||
if (module == nullptr) {
|
if (module == nullptr) {
|
||||||
throw XArchNetworkSupport("");
|
throw ArchNetworkSupportException("");
|
||||||
}
|
}
|
||||||
|
|
||||||
// get startup function address
|
// get startup function address
|
||||||
|
|
@ -134,7 +134,7 @@ void ArchNetworkWinsock::initModule(HMODULE module)
|
||||||
WSADATA data;
|
WSADATA data;
|
||||||
int err = startup(version, &data);
|
int err = startup(version, &data);
|
||||||
if (data.wVersion != version) {
|
if (data.wVersion != version) {
|
||||||
throw XArchNetworkSupport(winsockErrorToString(err));
|
throw ArchNetworkSupportException(winsockErrorToString(err));
|
||||||
}
|
}
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
// some other initialization error
|
// some other initialization error
|
||||||
|
|
@ -844,12 +844,12 @@ bool ArchNetworkWinsock::isEqualAddr(ArchNetAddress a, ArchNetAddress b)
|
||||||
{
|
{
|
||||||
switch (err) {
|
switch (err) {
|
||||||
case WSAEACCES:
|
case WSAEACCES:
|
||||||
throw XArchNetworkAccess(winsockErrorToString(err));
|
throw ArchNetworkAccessException(winsockErrorToString(err));
|
||||||
|
|
||||||
case WSAEMFILE:
|
case WSAEMFILE:
|
||||||
case WSAENOBUFS:
|
case WSAENOBUFS:
|
||||||
case WSAENETDOWN:
|
case WSAENETDOWN:
|
||||||
throw XArchNetworkResource(winsockErrorToString(err));
|
throw ArchNetworkResourceException(winsockErrorToString(err));
|
||||||
|
|
||||||
case WSAEPROTOTYPE:
|
case WSAEPROTOTYPE:
|
||||||
case WSAEPROTONOSUPPORT:
|
case WSAEPROTONOSUPPORT:
|
||||||
|
|
@ -863,50 +863,50 @@ bool ArchNetworkWinsock::isEqualAddr(ArchNetAddress a, ArchNetAddress b)
|
||||||
case WSANOTINITIALISED:
|
case WSANOTINITIALISED:
|
||||||
case WSAVERNOTSUPPORTED:
|
case WSAVERNOTSUPPORTED:
|
||||||
case WSASYSNOTREADY:
|
case WSASYSNOTREADY:
|
||||||
throw XArchNetworkSupport(winsockErrorToString(err));
|
throw ArchNetworkSupportException(winsockErrorToString(err));
|
||||||
|
|
||||||
case WSAEADDRNOTAVAIL:
|
case WSAEADDRNOTAVAIL:
|
||||||
throw XArchNetworkNoAddress(winsockErrorToString(err));
|
throw ArchNetworkNoAddressException(winsockErrorToString(err));
|
||||||
|
|
||||||
case WSAEADDRINUSE:
|
case WSAEADDRINUSE:
|
||||||
throw XArchNetworkAddressInUse(winsockErrorToString(err));
|
throw ArchNetworkAddressInUseException(winsockErrorToString(err));
|
||||||
|
|
||||||
case WSAEHOSTUNREACH:
|
case WSAEHOSTUNREACH:
|
||||||
case WSAENETUNREACH:
|
case WSAENETUNREACH:
|
||||||
throw XArchNetworkNoRoute(winsockErrorToString(err));
|
throw ArchNetworkNoRouteException(winsockErrorToString(err));
|
||||||
|
|
||||||
case WSAENOTCONN:
|
case WSAENOTCONN:
|
||||||
throw XArchNetworkNotConnected(winsockErrorToString(err));
|
throw ArchNetworkNotConnectedException(winsockErrorToString(err));
|
||||||
|
|
||||||
case WSAEDISCON:
|
case WSAEDISCON:
|
||||||
throw XArchNetworkShutdown(winsockErrorToString(err));
|
throw ArchNetworkShutdownException(winsockErrorToString(err));
|
||||||
|
|
||||||
case WSAENETRESET:
|
case WSAENETRESET:
|
||||||
case WSAECONNABORTED:
|
case WSAECONNABORTED:
|
||||||
case WSAECONNRESET:
|
case WSAECONNRESET:
|
||||||
throw XArchNetworkDisconnected(winsockErrorToString(err));
|
throw ArchNetworkDisconnectedException(winsockErrorToString(err));
|
||||||
|
|
||||||
case WSAECONNREFUSED:
|
case WSAECONNREFUSED:
|
||||||
throw XArchNetworkConnectionRefused(winsockErrorToString(err));
|
throw ArchNetworkConnectionRefusedException(winsockErrorToString(err));
|
||||||
|
|
||||||
case WSAEHOSTDOWN:
|
case WSAEHOSTDOWN:
|
||||||
case WSAETIMEDOUT:
|
case WSAETIMEDOUT:
|
||||||
throw XArchNetworkTimedOut(winsockErrorToString(err));
|
throw ArchNetworkTimedOutException(winsockErrorToString(err));
|
||||||
|
|
||||||
case WSAHOST_NOT_FOUND:
|
case WSAHOST_NOT_FOUND:
|
||||||
throw XArchNetworkNameUnknown(winsockErrorToString(err));
|
throw ArchNetworkNameUnknownException(winsockErrorToString(err));
|
||||||
|
|
||||||
case WSANO_DATA:
|
case WSANO_DATA:
|
||||||
throw XArchNetworkNameNoAddress(winsockErrorToString(err));
|
throw ArchNetworkNameNoAddressException(winsockErrorToString(err));
|
||||||
|
|
||||||
case WSANO_RECOVERY:
|
case WSANO_RECOVERY:
|
||||||
throw XArchNetworkNameFailure(winsockErrorToString(err));
|
throw ArchNetworkNameFailureException(winsockErrorToString(err));
|
||||||
|
|
||||||
case WSATRY_AGAIN:
|
case WSATRY_AGAIN:
|
||||||
throw XArchNetworkNameUnavailable(winsockErrorToString(err));
|
throw ArchNetworkNameUnavailableException(winsockErrorToString(err));
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw XArchNetwork(winsockErrorToString(err));
|
throw ArchNetworkException(winsockErrorToString(err));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -914,18 +914,18 @@ bool ArchNetworkWinsock::isEqualAddr(ArchNetAddress a, ArchNetAddress b)
|
||||||
{
|
{
|
||||||
switch (err) {
|
switch (err) {
|
||||||
case WSAHOST_NOT_FOUND:
|
case WSAHOST_NOT_FOUND:
|
||||||
throw XArchNetworkNameUnknown(winsockErrorToString(err));
|
throw ArchNetworkNameUnknownException(winsockErrorToString(err));
|
||||||
|
|
||||||
case WSANO_DATA:
|
case WSANO_DATA:
|
||||||
throw XArchNetworkNameNoAddress(winsockErrorToString(err));
|
throw ArchNetworkNameNoAddressException(winsockErrorToString(err));
|
||||||
|
|
||||||
case WSANO_RECOVERY:
|
case WSANO_RECOVERY:
|
||||||
throw XArchNetworkNameFailure(winsockErrorToString(err));
|
throw ArchNetworkNameFailureException(winsockErrorToString(err));
|
||||||
|
|
||||||
case WSATRY_AGAIN:
|
case WSATRY_AGAIN:
|
||||||
throw XArchNetworkNameUnavailable(winsockErrorToString(err));
|
throw ArchNetworkNameUnavailableException(winsockErrorToString(err));
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw XArchNetworkName(winsockErrorToString(err));
|
throw ArchNetworkNameException(winsockErrorToString(err));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#include "deskflow/win32/AppUtilWindows.h"
|
#include "deskflow/win32/AppUtilWindows.h"
|
||||||
|
|
||||||
#include "arch/XArch.h"
|
#include "arch/ArchException.h"
|
||||||
#include "arch/win32/ArchMiscWindows.h"
|
#include "arch/win32/ArchMiscWindows.h"
|
||||||
#include "arch/win32/XArchWindows.h"
|
#include "arch/win32/XArchWindows.h"
|
||||||
#include "base/Event.h"
|
#include "base/Event.h"
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ void *Thread::threadFunc(void *vjob)
|
||||||
LOG_DEBUG1("thread 0x%08x entry", id);
|
LOG_DEBUG1("thread 0x%08x entry", id);
|
||||||
job->run();
|
job->run();
|
||||||
LOG_DEBUG1("thread 0x%08x exit", id);
|
LOG_DEBUG1("thread 0x%08x exit", id);
|
||||||
} catch (XThreadCancel &) {
|
} catch (ThreadCancelException &) {
|
||||||
// client called cancel()
|
// client called cancel()
|
||||||
LOG_DEBUG1("caught cancel on thread 0x%08x", id);
|
LOG_DEBUG1("caught cancel on thread 0x%08x", id);
|
||||||
delete job;
|
delete job;
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ public:
|
||||||
\code
|
\code
|
||||||
catch(ThreadExit&) { throw; }
|
catch(ThreadExit&) { throw; }
|
||||||
\endcode
|
\endcode
|
||||||
or add the \c RETHROW_XTHREAD macro to the \c catch(...) block.
|
or add the \c RETHROW_THREADEXCEPTION macro to the \c catch(...) block.
|
||||||
*/
|
*/
|
||||||
[[noreturn]] static void exit(void *);
|
[[noreturn]] static void exit(void *);
|
||||||
|
|
||||||
|
|
@ -94,17 +94,17 @@ public:
|
||||||
Instead, it unwinds the stack and destroys automatic objects, as
|
Instead, it unwinds the stack and destroys automatic objects, as
|
||||||
if cancel() threw an exception (which is, in fact, what it does).
|
if cancel() threw an exception (which is, in fact, what it does).
|
||||||
Threads must take care to unlock and clean up any resources they
|
Threads must take care to unlock and clean up any resources they
|
||||||
may have, especially mutexes. They can \c catch(XThreadCancel) to
|
may have, especially mutexes. They can \c catch(ThreadCancelException) to
|
||||||
do that then rethrow the exception or they can let it happen
|
do that then rethrow the exception or they can let it happen
|
||||||
automatically by doing clean up in the d'tors of automatic
|
automatically by doing clean up in the d'tors of automatic
|
||||||
objects (like Lock). Clients are strongly encouraged to do the latter.
|
objects (like Lock). Clients are strongly encouraged to do the latter.
|
||||||
During cancellation, further cancel() calls are ignored (i.e.
|
During cancellation, further cancel() calls are ignored (i.e.
|
||||||
a thread cannot be interrupted by a cancel during cancellation).
|
a thread cannot be interrupted by a cancel during cancellation).
|
||||||
|
|
||||||
Clients that \c catch(XThreadCancel) must always rethrow the
|
Clients that \c catch(ThreadCancelException) must always rethrow the
|
||||||
exception. Clients that \c catch(...) must either rethrow the
|
exception. Clients that \c catch(...) must either rethrow the
|
||||||
exception or include a \c catch(XThreadCancel) handler that
|
exception or include a \c catch(ThreadCancelException) handler that
|
||||||
rethrows. The \c RETHROW_XTHREAD macro may be useful for that.
|
rethrows. The \c RETHROW_THREADEXCEPTION macro may be useful for that.
|
||||||
*/
|
*/
|
||||||
void cancel();
|
void cancel();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,15 +8,15 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "arch/XArch.h"
|
#include "arch/ArchException.h"
|
||||||
|
|
||||||
//! Thread exception to exit
|
//! Thread exception to exit
|
||||||
/*!
|
/*!
|
||||||
Thrown by Thread::exit() to exit a thread. Clients of Thread
|
Thrown by Thread::exit() to exit a thread. Clients of Thread
|
||||||
must not throw this type but must rethrow it if caught (by
|
must not throw this type but must rethrow it if caught (by
|
||||||
ThreadExitException, XThread, or ...).
|
ThreadExitException, ThreadException, or ...).
|
||||||
*/
|
*/
|
||||||
class ThreadExitException : public XThread
|
class ThreadExitException : public ThreadException
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! \c result is the result of the thread
|
//! \c result is the result of the thread
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
#include "net/NetworkAddress.h"
|
#include "net/NetworkAddress.h"
|
||||||
|
|
||||||
#include "arch/Arch.h"
|
#include "arch/Arch.h"
|
||||||
#include "arch/XArch.h"
|
#include "arch/ArchException.h"
|
||||||
#include "net/SocketException.h"
|
#include "net/SocketException.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
@ -155,13 +155,13 @@ size_t NetworkAddress::resolve(size_t index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (XArchNetworkNameUnknown &) {
|
} catch (ArchNetworkNameUnknownException &) {
|
||||||
throw SocketAddressException(SocketAddressException::SocketError::NotFound, m_hostname, m_port);
|
throw SocketAddressException(SocketAddressException::SocketError::NotFound, m_hostname, m_port);
|
||||||
} catch (XArchNetworkNameNoAddress &) {
|
} catch (ArchNetworkNameNoAddressException &) {
|
||||||
throw SocketAddressException(SocketAddressException::SocketError::NoAddress, m_hostname, m_port);
|
throw SocketAddressException(SocketAddressException::SocketError::NoAddress, m_hostname, m_port);
|
||||||
} catch (XArchNetworkNameUnsupported &) {
|
} catch (ArchNetworkNameUnsupportedException &) {
|
||||||
throw SocketAddressException(SocketAddressException::SocketError::Unsupported, m_hostname, m_port);
|
throw SocketAddressException(SocketAddressException::SocketError::Unsupported, m_hostname, m_port);
|
||||||
} catch (XArchNetworkName &) {
|
} catch (ArchNetworkNameException &) {
|
||||||
throw SocketAddressException(SocketAddressException::SocketError::Unknown, m_hostname, m_port);
|
throw SocketAddressException(SocketAddressException::SocketError::Unknown, m_hostname, m_port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
#include "SecureListenSocket.h"
|
#include "SecureListenSocket.h"
|
||||||
|
|
||||||
#include "SecureSocket.h"
|
#include "SecureSocket.h"
|
||||||
#include "arch/XArch.h"
|
#include "arch/ArchException.h"
|
||||||
#include "base/String.h"
|
#include "base/String.h"
|
||||||
#include "common/Settings.h"
|
#include "common/Settings.h"
|
||||||
#include "deskflow/ArgParser.h"
|
#include "deskflow/ArgParser.h"
|
||||||
|
|
@ -58,7 +58,7 @@ std::unique_ptr<IDataSocket> SecureListenSocket::accept()
|
||||||
secureSocket->secureAccept();
|
secureSocket->secureAccept();
|
||||||
|
|
||||||
return secureSocket;
|
return secureSocket;
|
||||||
} catch (XArchNetwork &) {
|
} catch (ArchNetworkException &) {
|
||||||
if (secureSocket) {
|
if (secureSocket) {
|
||||||
setListeningJob();
|
setListeningJob();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
#include "SecureSocket.h"
|
#include "SecureSocket.h"
|
||||||
#include "SecureUtils.h"
|
#include "SecureUtils.h"
|
||||||
|
|
||||||
#include "arch/XArch.h"
|
#include "arch/ArchException.h"
|
||||||
#include "base/Log.h"
|
#include "base/Log.h"
|
||||||
#include "base/Path.h"
|
#include "base/Path.h"
|
||||||
#include "base/String.h"
|
#include "base/String.h"
|
||||||
|
|
@ -589,7 +589,7 @@ void SecureSocket::checkResult(int status, int &retry)
|
||||||
// underlying socket I/O reproted an error
|
// underlying socket I/O reproted an error
|
||||||
try {
|
try {
|
||||||
ARCH->throwErrorOnSocket(getSocket());
|
ARCH->throwErrorOnSocket(getSocket());
|
||||||
} catch (XArchNetwork &e) {
|
} catch (ArchNetworkException &e) {
|
||||||
LOG_ERR("%s", e.what());
|
LOG_ERR("%s", e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
#include "net/SocketMultiplexer.h"
|
#include "net/SocketMultiplexer.h"
|
||||||
|
|
||||||
#include "arch/Arch.h"
|
#include "arch/Arch.h"
|
||||||
#include "arch/XArch.h"
|
#include "arch/ArchException.h"
|
||||||
#include "base/Log.h"
|
#include "base/Log.h"
|
||||||
#include "base/TMethodJob.h"
|
#include "base/TMethodJob.h"
|
||||||
#include "mt/CondVar.h"
|
#include "mt/CondVar.h"
|
||||||
|
|
@ -173,7 +173,7 @@ void SocketMultiplexer::removeSocket(ISocket *socket)
|
||||||
} else {
|
} else {
|
||||||
status = 0;
|
status = 0;
|
||||||
}
|
}
|
||||||
} catch (XArchNetwork &e) {
|
} catch (ArchNetworkException &e) {
|
||||||
LOG_WARN("error in socket multiplexer: %s", e.what());
|
LOG_WARN("error in socket multiplexer: %s", e.what());
|
||||||
status = 0;
|
status = 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
#include "net/TCPListenSocket.h"
|
#include "net/TCPListenSocket.h"
|
||||||
|
|
||||||
#include "arch/Arch.h"
|
#include "arch/Arch.h"
|
||||||
#include "arch/XArch.h"
|
#include "arch/ArchException.h"
|
||||||
#include "base/IEventQueue.h"
|
#include "base/IEventQueue.h"
|
||||||
#include "base/Log.h"
|
#include "base/Log.h"
|
||||||
#include "io/IOException.h"
|
#include "io/IOException.h"
|
||||||
|
|
@ -30,7 +30,7 @@ TCPListenSocket::TCPListenSocket(
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
m_socket = ARCH->newSocket(family, IArchNetwork::SocketType::Stream);
|
m_socket = ARCH->newSocket(family, IArchNetwork::SocketType::Stream);
|
||||||
} catch (XArchNetwork &e) {
|
} catch (ArchNetworkException &e) {
|
||||||
throw SocketCreateException(e.what());
|
throw SocketCreateException(e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -60,9 +60,9 @@ void TCPListenSocket::bind(const NetworkAddress &addr)
|
||||||
this, &TCPListenSocket::serviceListening, m_socket, true, false
|
this, &TCPListenSocket::serviceListening, m_socket, true, false
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} catch (XArchNetworkAddressInUse &e) {
|
} catch (ArchNetworkAddressInUseException &e) {
|
||||||
throw SocketAddressInUseException(e.what());
|
throw SocketAddressInUseException(e.what());
|
||||||
} catch (XArchNetwork &e) {
|
} catch (ArchNetworkException &e) {
|
||||||
throw SocketBindException(e.what());
|
throw SocketBindException(e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -77,7 +77,7 @@ void TCPListenSocket::close()
|
||||||
m_socketMultiplexer->removeSocket(this);
|
m_socketMultiplexer->removeSocket(this);
|
||||||
ARCH->closeSocket(m_socket);
|
ARCH->closeSocket(m_socket);
|
||||||
m_socket = nullptr;
|
m_socket = nullptr;
|
||||||
} catch (XArchNetwork &e) {
|
} catch (ArchNetworkException &e) {
|
||||||
throw SocketIOCloseException(e.what());
|
throw SocketIOCloseException(e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -94,7 +94,7 @@ std::unique_ptr<IDataSocket> TCPListenSocket::accept()
|
||||||
socket = std::make_unique<TCPSocket>(m_events, m_socketMultiplexer, ARCH->acceptSocket(m_socket, nullptr));
|
socket = std::make_unique<TCPSocket>(m_events, m_socketMultiplexer, ARCH->acceptSocket(m_socket, nullptr));
|
||||||
setListeningJob();
|
setListeningJob();
|
||||||
return socket;
|
return socket;
|
||||||
} catch (XArchNetwork &) {
|
} catch (ArchNetworkException &) {
|
||||||
if (socket) {
|
if (socket) {
|
||||||
setListeningJob();
|
setListeningJob();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
#include "net/TCPSocket.h"
|
#include "net/TCPSocket.h"
|
||||||
|
|
||||||
#include "arch/Arch.h"
|
#include "arch/Arch.h"
|
||||||
#include "arch/XArch.h"
|
#include "arch/ArchException.h"
|
||||||
#include "base/IEventQueue.h"
|
#include "base/IEventQueue.h"
|
||||||
#include "base/Log.h"
|
#include "base/Log.h"
|
||||||
#include "mt/Lock.h"
|
#include "mt/Lock.h"
|
||||||
|
|
@ -35,7 +35,7 @@ TCPSocket::TCPSocket(IEventQueue *events, SocketMultiplexer *socketMultiplexer,
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
m_socket = ARCH->newSocket(family, IArchNetwork::SocketType::Stream);
|
m_socket = ARCH->newSocket(family, IArchNetwork::SocketType::Stream);
|
||||||
} catch (const XArchNetwork &e) {
|
} catch (const ArchNetworkException &e) {
|
||||||
throw SocketCreateException(e.what());
|
throw SocketCreateException(e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,9 +75,9 @@ void TCPSocket::bind(const NetworkAddress &addr)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
ARCH->bindSocket(m_socket, addr.getAddress());
|
ARCH->bindSocket(m_socket, addr.getAddress());
|
||||||
} catch (const XArchNetworkAddressInUse &e) {
|
} catch (const ArchNetworkAddressInUseException &e) {
|
||||||
throw SocketAddressInUseException(e.what());
|
throw SocketAddressInUseException(e.what());
|
||||||
} catch (const XArchNetwork &e) {
|
} catch (const ArchNetworkException &e) {
|
||||||
throw SocketBindException(e.what());
|
throw SocketBindException(e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -103,7 +103,7 @@ void TCPSocket::close()
|
||||||
m_socket = nullptr;
|
m_socket = nullptr;
|
||||||
try {
|
try {
|
||||||
ARCH->closeSocket(socket);
|
ARCH->closeSocket(socket);
|
||||||
} catch (const XArchNetwork &e) {
|
} catch (const ArchNetworkException &e) {
|
||||||
// ignore, there's not much we can do
|
// ignore, there's not much we can do
|
||||||
LOG_WARN("error closing socket: %s", e.what());
|
LOG_WARN("error closing socket: %s", e.what());
|
||||||
}
|
}
|
||||||
|
|
@ -184,7 +184,7 @@ void TCPSocket::shutdownInput()
|
||||||
// shutdown socket for reading
|
// shutdown socket for reading
|
||||||
try {
|
try {
|
||||||
ARCH->closeSocketForRead(m_socket);
|
ARCH->closeSocketForRead(m_socket);
|
||||||
} catch (const XArchNetwork &e) {
|
} catch (const ArchNetworkException &e) {
|
||||||
// ignore, there's not much we can do
|
// ignore, there's not much we can do
|
||||||
LOG_WARN("error closing socket: %s", e.what());
|
LOG_WARN("error closing socket: %s", e.what());
|
||||||
}
|
}
|
||||||
|
|
@ -210,7 +210,7 @@ void TCPSocket::shutdownOutput()
|
||||||
// shutdown socket for writing
|
// shutdown socket for writing
|
||||||
try {
|
try {
|
||||||
ARCH->closeSocketForWrite(m_socket);
|
ARCH->closeSocketForWrite(m_socket);
|
||||||
} catch (const XArchNetwork &e) {
|
} catch (const ArchNetworkException &e) {
|
||||||
// ignore, there's not much we can do
|
// ignore, there's not much we can do
|
||||||
LOG_WARN("error closing socket: %s", e.what());
|
LOG_WARN("error closing socket: %s", e.what());
|
||||||
}
|
}
|
||||||
|
|
@ -265,7 +265,7 @@ void TCPSocket::connect(const NetworkAddress &addr)
|
||||||
// connection is in progress
|
// connection is in progress
|
||||||
m_writable = true;
|
m_writable = true;
|
||||||
}
|
}
|
||||||
} catch (const XArchNetwork &e) {
|
} catch (const ArchNetworkException &e) {
|
||||||
throw SocketConnectException(e.what());
|
throw SocketConnectException(e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -284,11 +284,11 @@ void TCPSocket::init()
|
||||||
// that should be sent without (much) delay. for example, the
|
// that should be sent without (much) delay. for example, the
|
||||||
// mouse motion messages are much less useful if they're delayed.
|
// mouse motion messages are much less useful if they're delayed.
|
||||||
ARCH->setNoDelayOnSocket(m_socket, true);
|
ARCH->setNoDelayOnSocket(m_socket, true);
|
||||||
} catch (const XArchNetwork &e) {
|
} catch (const ArchNetworkException &e) {
|
||||||
try {
|
try {
|
||||||
ARCH->closeSocket(m_socket);
|
ARCH->closeSocket(m_socket);
|
||||||
m_socket = nullptr;
|
m_socket = nullptr;
|
||||||
} catch (const XArchNetwork &e) {
|
} catch (const ArchNetworkException &e) {
|
||||||
// ignore, there's not much we can do
|
// ignore, there's not much we can do
|
||||||
LOG_WARN("error closing socket: %s", e.what());
|
LOG_WARN("error closing socket: %s", e.what());
|
||||||
}
|
}
|
||||||
|
|
@ -469,7 +469,7 @@ ISocketMultiplexerJob *TCPSocket::serviceConnecting(ISocketMultiplexerJob *job,
|
||||||
try {
|
try {
|
||||||
// connection may have failed or succeeded
|
// connection may have failed or succeeded
|
||||||
ARCH->throwErrorOnSocket(m_socket);
|
ARCH->throwErrorOnSocket(m_socket);
|
||||||
} catch (const XArchNetwork &e) {
|
} catch (const ArchNetworkException &e) {
|
||||||
sendConnectionFailedEvent(e.what());
|
sendConnectionFailedEvent(e.what());
|
||||||
onDisconnected();
|
onDisconnected();
|
||||||
return newJob();
|
return newJob();
|
||||||
|
|
@ -503,7 +503,7 @@ ISocketMultiplexerJob *TCPSocket::serviceConnected(ISocketMultiplexerJob *job, b
|
||||||
if (write) {
|
if (write) {
|
||||||
try {
|
try {
|
||||||
writeResult = doWrite();
|
writeResult = doWrite();
|
||||||
} catch (XArchNetworkShutdown &) {
|
} catch (ArchNetworkShutdownException &) {
|
||||||
// remote read end of stream hungup. our output side
|
// remote read end of stream hungup. our output side
|
||||||
// has therefore shutdown.
|
// has therefore shutdown.
|
||||||
onOutputShutdown();
|
onOutputShutdown();
|
||||||
|
|
@ -513,12 +513,12 @@ ISocketMultiplexerJob *TCPSocket::serviceConnected(ISocketMultiplexerJob *job, b
|
||||||
m_connected = false;
|
m_connected = false;
|
||||||
}
|
}
|
||||||
writeResult = New;
|
writeResult = New;
|
||||||
} catch (XArchNetworkDisconnected &) {
|
} catch (ArchNetworkDisconnectedException &) {
|
||||||
// stream hungup
|
// stream hungup
|
||||||
onDisconnected();
|
onDisconnected();
|
||||||
sendEvent(SocketDisconnected);
|
sendEvent(SocketDisconnected);
|
||||||
writeResult = New;
|
writeResult = New;
|
||||||
} catch (XArchNetwork &e) {
|
} catch (ArchNetworkException &e) {
|
||||||
// other write error
|
// other write error
|
||||||
LOG_WARN("error writing socket: %s", e.what());
|
LOG_WARN("error writing socket: %s", e.what());
|
||||||
onDisconnected();
|
onDisconnected();
|
||||||
|
|
@ -531,12 +531,12 @@ ISocketMultiplexerJob *TCPSocket::serviceConnected(ISocketMultiplexerJob *job, b
|
||||||
if (read && m_readable) {
|
if (read && m_readable) {
|
||||||
try {
|
try {
|
||||||
readResult = doRead();
|
readResult = doRead();
|
||||||
} catch (XArchNetworkDisconnected &) {
|
} catch (ArchNetworkDisconnectedException &) {
|
||||||
// stream hungup
|
// stream hungup
|
||||||
sendEvent(SocketDisconnected);
|
sendEvent(SocketDisconnected);
|
||||||
onDisconnected();
|
onDisconnected();
|
||||||
readResult = New;
|
readResult = New;
|
||||||
} catch (XArchNetwork &e) {
|
} catch (ArchNetworkException &e) {
|
||||||
// ignore other read error
|
// ignore other read error
|
||||||
LOG_WARN("error reading socket: %s", e.what());
|
LOG_WARN("error reading socket: %s", e.what());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
#include "platform/EiScreen.h"
|
#include "platform/EiScreen.h"
|
||||||
|
|
||||||
#include "arch/Arch.h"
|
#include "arch/Arch.h"
|
||||||
#include "arch/XArch.h"
|
#include "arch/ArchException.h"
|
||||||
#include "base/IEventQueue.h"
|
#include "base/IEventQueue.h"
|
||||||
#include "base/Log.h"
|
#include "base/Log.h"
|
||||||
#include "base/Stopwatch.h"
|
#include "base/Stopwatch.h"
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#include "platform/OSXClipboard.h"
|
#include "platform/OSXClipboard.h"
|
||||||
|
|
||||||
#include "arch/XArch.h"
|
#include "arch/ArchException.h"
|
||||||
#include "base/Log.h"
|
#include "base/Log.h"
|
||||||
#include "deskflow/Clipboard.h"
|
#include "deskflow/Clipboard.h"
|
||||||
#include "platform/OSXClipboardBMPConverter.h"
|
#include "platform/OSXClipboardBMPConverter.h"
|
||||||
|
|
@ -202,7 +202,7 @@ std::string OSXClipboard::get(Format format) const
|
||||||
LOG_DEBUG("exception thrown in OSXClipboard::get MacError (%d)", err);
|
LOG_DEBUG("exception thrown in OSXClipboard::get MacError (%d)", err);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
LOG_DEBUG("unknown exception in OSXClipboard::get");
|
LOG_DEBUG("unknown exception in OSXClipboard::get");
|
||||||
RETHROW_XTHREAD
|
RETHROW_THREADEXCEPTION
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buffer != nullptr)
|
if (buffer != nullptr)
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
#include "platform/OSXScreen.h"
|
#include "platform/OSXScreen.h"
|
||||||
|
|
||||||
#include "arch/XArch.h"
|
#include "arch/ArchException.h"
|
||||||
#include "base/EventQueue.h"
|
#include "base/EventQueue.h"
|
||||||
#include "base/IEventQueue.h"
|
#include "base/IEventQueue.h"
|
||||||
#include "base/Log.h"
|
#include "base/Log.h"
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
#include "platform/XWindowsScreen.h"
|
#include "platform/XWindowsScreen.h"
|
||||||
|
|
||||||
#include "arch/Arch.h"
|
#include "arch/Arch.h"
|
||||||
#include "arch/XArch.h"
|
#include "arch/ArchException.h"
|
||||||
#include "base/IEventQueue.h"
|
#include "base/IEventQueue.h"
|
||||||
#include "base/Log.h"
|
#include "base/Log.h"
|
||||||
#include "base/Stopwatch.h"
|
#include "base/Stopwatch.h"
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
#include "arch/IArchNetwork.h"
|
#include "arch/IArchNetwork.h"
|
||||||
#include "lib/arch/unix/ArchNetworkBSD.h"
|
#include "lib/arch/unix/ArchNetworkBSD.h"
|
||||||
|
|
||||||
#include "lib/arch/XArch.h"
|
#include "lib/arch/ArchException.h"
|
||||||
|
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
@ -69,7 +69,7 @@ TEST(ArchNetworkBSDTests, pollSocket_mockAccessError_throws)
|
||||||
|
|
||||||
const auto f = [&] { networkBSD.pollSocket(entries.data(), static_cast<int>(entries.size()), 1); };
|
const auto f = [&] { networkBSD.pollSocket(entries.data(), static_cast<int>(entries.size()), 1); };
|
||||||
|
|
||||||
EXPECT_THROW({ f(); }, XArchNetworkAccess);
|
EXPECT_THROW({ f(); }, ArchNetworkAccessException);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(ArchNetworkBSDTests, pollSocket_pfdHasRevents_copiedToEntries)
|
TEST(ArchNetworkBSDTests, pollSocket_pfdHasRevents_copiedToEntries)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue