From 9d33a89bc1bd36a7490f09eef35ec318fc5deda2 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Sun, 6 May 2018 08:17:32 -0400 Subject: [PATCH] make read buffer size templated --- contrib/backends/nntpchan-daemon/libnntpchan/epoll.hpp | 3 ++- contrib/backends/nntpchan-daemon/libnntpchan/event.cpp | 9 ++++++--- contrib/backends/nntpchan-daemon/libnntpchan/kqueue.hpp | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/contrib/backends/nntpchan-daemon/libnntpchan/epoll.hpp b/contrib/backends/nntpchan-daemon/libnntpchan/epoll.hpp index cacb57c..0e4dae0 100644 --- a/contrib/backends/nntpchan-daemon/libnntpchan/epoll.hpp +++ b/contrib/backends/nntpchan-daemon/libnntpchan/epoll.hpp @@ -14,11 +14,12 @@ namespace nntpchan { namespace ev { + template struct EpollLoop : public Loop { size_t conns; int epollfd; - char readbuf[128]; + char readbuf[bufsz]; EpollLoop() : conns(0), epollfd(epoll_create1(EPOLL_CLOEXEC)) { } diff --git a/contrib/backends/nntpchan-daemon/libnntpchan/event.cpp b/contrib/backends/nntpchan-daemon/libnntpchan/event.cpp index cebdc78..ed31f9d 100644 --- a/contrib/backends/nntpchan-daemon/libnntpchan/event.cpp +++ b/contrib/backends/nntpchan-daemon/libnntpchan/event.cpp @@ -1,14 +1,17 @@ #include + +constexpr size_t ev_buffsz = 512; + #ifdef __linux__ #include "epoll.hpp" -typedef nntpchan::ev::EpollLoop LoopImpl; +typedef nntpchan::ev::EpollLoop LoopImpl; #else #ifdef __freebsd__ #include "kqueue.hpp" -typedef nntpchan::ev::KqueueLoop LoopImpl; +typedef nntpchan::ev::KqueueLoop LoopImpl; #else #ifdef __netbsd__ -typedef nntpchan::ev::KqueueLoop LoopImpl; +typedef nntpchan::ev::KqueueLoop LoopImpl; #else #error "unsupported platform" #endif diff --git a/contrib/backends/nntpchan-daemon/libnntpchan/kqueue.hpp b/contrib/backends/nntpchan-daemon/libnntpchan/kqueue.hpp index 0ef54ae..ebc2419 100644 --- a/contrib/backends/nntpchan-daemon/libnntpchan/kqueue.hpp +++ b/contrib/backends/nntpchan-daemon/libnntpchan/kqueue.hpp @@ -6,11 +6,12 @@ namespace nntpchan { namespace ev { + template struct KqueueLoop : public Loop { int kfd; size_t conns; - char readbuf[1024]; + char readbuf[bufsz]; KqueueLoop() : kfd(kqueue()), conns(0)