0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-19 03:13:47 +02:00

Checkpoint reorganization.

This commit is contained in:
Jason Volk 2017-11-30 11:44:23 -08:00
parent b2a6d4ebab
commit 1a1a50f5f3
15 changed files with 101 additions and 97 deletions

View file

@ -31,8 +31,8 @@ This is the first implementation of a Matrix homeserver written in C++. The road
for service is as follows:
- [✓] Phase One: Matrix clients using HTTP.
- [ ] Phase Two: Legacy IRC networks using TS6 protocol (Atheme Federation).
- [ ] Phase Three: Legacy IRC clients using RFC1459/RFC2812 legacy grammars.
- Phase Two: Legacy IRC networks using TS6 protocol (Atheme Federation).
- Phase Three: Legacy IRC clients using RFC1459/RFC2812 legacy grammars.
## Installation
@ -126,8 +126,7 @@ which may introduce the actual application features (or the "business logic")
of the server. These additional modules are found in the `modules/` directory;
This library can be embedded by developers creating their own server or those
who simply want to use the library of routines it provides. See the section for
`Using libircd`.
who simply want to use the library of routines it provides.
##### libircd can be embedded in your application with very minimal overhead.
@ -157,15 +156,15 @@ on multiple threads by the embedder's application, libircd will use a single
`io_service::strand`.
This methodology ensures there is an uninterrupted execution working through
a single event queue providing service which is not otherwise computationally
bound. Even if there are periods of execution which are computationally intense
like parsing, hashing, signature verification etc -- this is insignificant
compared to the amortized cost of thread synchronization and bus contention
for a network application.
a single event queue providing service. Even if there are periods of execution
which are computationally intense like parsing, hashing, cryptography etc -- this
is absorbed in lieu of thread synchronization and bus contention. Scaling this
system is done through running multiple instances which synchronize at the
application level.
✝ However, don't start assuming a truly threadless execution. If there is
ever a truly long-running background computation or a call to a 3rd
party library which will do IO and block the event loop, we may use an
✝ However, don't start assuming a truly threadless execution for the entire
address space. If there is ever a long-running background computation or a call
to a 3rd party library which will do IO and block the event loop, we may use an
additional `std::thread` to "offload" such an operation. Thus we do have
a threading model, but it is heterogeneous.

View file

@ -21,6 +21,7 @@
#include <ircd/ircd.h>
#include <ircd/asio.h>
#include <ircd/m/m.h>
#include "charybdis.h"
using namespace ircd;

@ -1 +1 @@
Subproject commit 090fadc2ca44cd8e2d057cb90cd648cf60587c2e
Subproject commit e58e94fb0696e9d99b8685348f02278a4bafced7

View file

@ -9,17 +9,24 @@ AM_CXXFLAGS = \
###
if GCC
AM_CXXFLAGS += -fpch-deps
AM_CXXFLAGS += \
-fpch-deps \
###
endif
if DEBUG
if GCC
AM_CXXFLAGS += -fmax-errors=2
AM_CXXFLAGS += \
-fmax-errors=2 \
###
endif
endif
if BUILD_PCH
BUILT_SOURCES = stdinc.h.gch stdinc.pic.h.gch
BUILT_SOURCES = \
stdinc.h.gch \
stdinc.pic.h.gch \
###
endif
stdinc.h.gch:

View file

@ -1,25 +1,23 @@
/*
* ircd-ratbox: A slightly useful ircd.
* ircd.h: A header for the ircd startup routines.
* Copyright (C) 2017 Matrix Construct Development Team
* Copyright (C) 2017 Jason Volk <jason@zemos.net>
*
* Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
* Copyright (C) 1996-2002 Hybrid Development Team
* Copyright (C) 2002-2004 ircd-ratbox development team
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*/
#pragma once
@ -38,18 +36,11 @@ namespace ircd
{
struct init;
enum class runlevel :uint;
using runlevel_handler = std::function<void (const enum runlevel &)>;
extern bool debugmode; ///< Toggled by command line to indicate debug behavior
extern const enum runlevel &runlevel; ///< Reflects current running mode of library
extern runlevel_handler runlevel_changed; ///< User hook to get called on runlevel change.
extern runlevel_handler runlevel_changed;
string_view reflect(const enum runlevel &);
void init(boost::asio::io_service &ios, const std::string &conf, runlevel_handler = {});
void init(boost::asio::io_service &ios, runlevel_handler = {});
bool quit() noexcept;
}
@ -71,12 +62,19 @@ namespace ircd
/// mode and may require some user action to continue.
///
enum class ircd::runlevel
:uint
:int
{
HALT = 0x00, ///< [inter] IRCd Powered off.
READY = 0x01, ///< [inter] Ready for user to run ios event loop.
START = 0x02, ///< [trans] Starting up subsystems for service.
RUN = 0x04, ///< [inter] IRCd in service.
QUIT = 0x10, ///< [trans] Clean shutdown in progress
FAULT = 0xFF, ///< [trans] QUIT with exception (dirty shutdown)
HALT = 0, ///< [inter] IRCd Powered off.
READY = 1, ///< [inter] Ready for user to run ios event loop.
START = 2, ///< [trans] Starting up subsystems for service.
RUN = 3, ///< [inter] IRCd in service.
QUIT = 4, ///< [trans] Clean shutdown in progress
FAULT = -1, ///< [trans] QUIT with exception (dirty shutdown)
};
template<class T>
std::string
ircd::demangle()
{
return demangle(typeid(T).name());
}

View file

@ -1,23 +1,22 @@
/*
* ircd-ratbox: A slightly useful ircd.
* stdinc.h: Pull in all of the necessary system headers
* Copyright (C) 2017 Matrix Construct Development Team
* Copyright (C) 2017 Jason Volk <jason@zemos.net>
*
* Copyright (C) 2002 Aaron Sethman <androsyn@ratbox.org>
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice is present in all copies.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
@ -144,9 +143,10 @@ namespace std
///////////////////////////////////////////////////////////////////////////////
//
// Some items imported into our namespace.
// libircd API
//
// Some items imported into our namespace.
namespace ircd
{
using std::nullptr_t;
@ -166,21 +166,17 @@ namespace ircd
using uint128_t = unsigned __int128;
}
///////////////////////////////////////////////////////////////////////////////
//
// libircd API
//
// Unsorted section
namespace ircd
{
struct client;
struct server;
enum class runlevel :uint;
enum class runlevel :int;
using runlevel_handler = std::function<void (const enum runlevel &)>;
constexpr size_t BUFSIZE { 512 };
extern const std::string &conf;
extern const enum runlevel &runlevel;
extern const std::string &conf;
extern bool debugmode; ///< Toggle; available only ifdef RB_DEBUG
std::string demangle(const std::string &symbol);
template<class T> std::string demangle();
@ -224,14 +220,7 @@ namespace ircd
#include "js.h"
#include "mods.h"
#include "net/net.h"
#include "m/m.h"
#include "resource.h"
#include "server.h"
#include "client.h"
template<class T>
std::string
ircd::demangle()
{
return demangle(typeid(T).name());
}
#include "m/m.h"
#include "resource.h"

View file

@ -75,10 +75,10 @@ libircd_la_SOURCES = \
lexical.cc \
locale.cc \
logger.cc \
m_id.cc \
m_io.cc \
m_vm.cc \
m.cc \
m/id.cc \
m/io.cc \
m/vm.cc \
m/m.cc \
mods.cc \
net.cc \
openssl.cc \

View file

@ -26,6 +26,8 @@
*/
#include <ircd/asio.h>
#include <ircd/m/m.h>
#include <ircd/resource.h>
namespace ircd {
@ -33,14 +35,14 @@ namespace ircd {
// (or idle mode) after which it is disconnected.
const auto async_timeout
{
300s
40s
};
// Time limit for how long a connected client can be in "request mode." This
// should never be hit unless there's an error in the handling code.
const auto request_timeout
{
60s
20s
};
// The pool of request contexts. When a client makes a request it does so by acquiring
@ -48,7 +50,7 @@ const auto request_timeout
// in a synchronous manner as if each connection had its own thread.
ctx::pool request
{
"request", 256_KiB
"request", 4_MiB
};
// Container for all active clients (connections) for iteration purposes.
@ -67,7 +69,7 @@ template<class... args> std::shared_ptr<client> make_client(args&&...);
ircd::client::init::init()
{
request.add(2);
request.add(32);
}
void
@ -247,8 +249,9 @@ bool
ircd::client::main()
noexcept try
{
const auto header_max{8192};
const auto content_max{65536};
const auto header_max{8_KiB};
//const auto content_max{64_KiB};
const auto content_max{8_MiB};
const unique_buffer<mutable_buffer> buffer
{
header_max + content_max

View file

@ -24,6 +24,7 @@
*/
#include <ircd/asio.h>
#include <ircd/m/m.h>
namespace ircd
{

View file

@ -19,6 +19,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <ircd/m/m.h>
namespace ircd::m::io
{
bool acquire_local(event::fetch &);

View file

@ -19,6 +19,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <ircd/m/m.h>
///////////////////////////////////////////////////////////////////////////////
//
// m.h

View file

@ -19,6 +19,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <ircd/m/m.h>
///////////////////////////////////////////////////////////////////////////////
//
// m/vm.h

View file

@ -19,6 +19,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <ircd/m/m.h>
#include <ircd/resource.h>
namespace ircd {
IRCD_INIT_PRIORITY(STD_CONTAINER)

View file

@ -11,9 +11,6 @@ AM_CPPFLAGS = \
@JS_CPPFLAGS@ \
@BOOST_CPPFLAGS@ \
-include $(top_srcdir)/include/ircd/ircd.h \
-include $(top_srcdir)/include/ircd/server.h \
-include $(top_srcdir)/include/ircd/m/m.h \
-include $(top_srcdir)/include/ircd/resource.h \
-include $(top_srcdir)/include/ircd/mapi.h \
###