2016-04-08 11:36:08 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
|
|
|
/*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
2017-12-20 07:06:26 -06:00
|
|
|
#include <config.h>
|
2017-03-08 10:38:22 -06:00
|
|
|
|
2016-04-08 11:36:08 -05:00
|
|
|
#include <cassert>
|
2019-11-06 03:07:32 -06:00
|
|
|
#include <sysexits.h>
|
loolwsd: include cleanup and organization
A source file (.cpp) must include its own header first.
This insures that the header is self-contained and
doesn't depend on arbitrary (and accidental) includes
before it to compile.
Furthermore, system headers should go next, followed by
C then C++ headers, then libraries (Poco, etc) and, finally,
project headers come last.
This makes sure that headers and included in the same dependency
order to avoid side-effects. For example, Poco should never rely on
anything from our project in the same way that a C header should
never rely on anything in C++, Poco, or project headers.
Also, includes ought to be sorted where possible, to improve
readability and avoid accidental duplicates (of which there
were a few).
Change-Id: I62cc1343e4a091d69195e37ed659dba20cfcb1ef
Reviewed-on: https://gerrit.libreoffice.org/25262
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
2016-05-21 09:23:07 -05:00
|
|
|
|
2017-12-20 07:06:26 -06:00
|
|
|
#include <Log.hpp>
|
|
|
|
#include <Util.hpp>
|
|
|
|
#include <Unit.hpp>
|
2016-04-08 11:36:08 -05:00
|
|
|
|
2016-04-09 11:30:48 -05:00
|
|
|
class UnitTimeout : public UnitWSD
|
2016-04-08 11:36:08 -05:00
|
|
|
{
|
|
|
|
std::atomic<bool> _timedOut;
|
|
|
|
public:
|
|
|
|
UnitTimeout()
|
|
|
|
: _timedOut(false)
|
|
|
|
{
|
|
|
|
setTimeout(10);
|
|
|
|
}
|
|
|
|
virtual void timeout() override
|
|
|
|
{
|
|
|
|
_timedOut = true;
|
2016-04-09 11:30:48 -05:00
|
|
|
UnitBase::timeout();
|
2016-04-08 11:36:08 -05:00
|
|
|
}
|
2017-02-16 21:04:45 -06:00
|
|
|
virtual void returnValue(int & retValue) override
|
2016-04-08 11:36:08 -05:00
|
|
|
{
|
|
|
|
if (!_timedOut)
|
|
|
|
{
|
2018-01-14 19:39:06 -06:00
|
|
|
LOG_INF("Failed to timeout");
|
2019-11-06 03:07:32 -06:00
|
|
|
retValue = EX_SOFTWARE;
|
2016-04-08 11:36:08 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
assert(_setRetValue);
|
2019-11-06 03:07:32 -06:00
|
|
|
assert(_retValue == EX_SOFTWARE);
|
2016-04-08 11:36:08 -05:00
|
|
|
// we wanted a timeout.
|
2019-11-06 03:07:32 -06:00
|
|
|
retValue = EX_OK;
|
2016-04-08 11:36:08 -05:00
|
|
|
}
|
|
|
|
}
|
2016-04-09 11:30:48 -05:00
|
|
|
|
|
|
|
// sanity check the non-unit-test paths
|
|
|
|
static void testDefaultKits()
|
|
|
|
{
|
2016-12-22 03:27:30 -06:00
|
|
|
bool madeWSD = init(UnitType::Wsd, std::string());
|
2016-04-09 11:30:48 -05:00
|
|
|
assert(madeWSD);
|
2016-06-07 02:18:49 -05:00
|
|
|
delete UnitBase::Global;
|
2016-12-22 08:04:07 -06:00
|
|
|
UnitBase::Global = nullptr;
|
2016-12-22 03:27:30 -06:00
|
|
|
bool madeKit = init(UnitType::Kit, std::string());
|
2016-04-09 11:30:48 -05:00
|
|
|
assert(madeKit);
|
2016-06-07 02:18:49 -05:00
|
|
|
delete UnitBase::Global;
|
2016-12-22 08:04:07 -06:00
|
|
|
UnitBase::Global = nullptr;
|
2016-04-09 11:30:48 -05:00
|
|
|
}
|
2016-04-08 11:36:08 -05:00
|
|
|
};
|
|
|
|
|
2016-04-09 11:30:48 -05:00
|
|
|
UnitBase *unit_create_wsd(void)
|
2016-04-08 11:36:08 -05:00
|
|
|
{
|
2016-04-09 11:30:48 -05:00
|
|
|
UnitTimeout::testDefaultKits();
|
2016-04-08 11:36:08 -05:00
|
|
|
return new UnitTimeout();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|