Ocelot 0.8

This commit is contained in:
Git
2014-03-27 16:30:00 +00:00
parent 0d5eed2a9e
commit 61d445e247
22 changed files with 247 additions and 329 deletions

View File

@@ -1,3 +1,8 @@
-- 0.8 (2014-03-27)
Add setting for maximum request size
Get client IP from the x-forwarded-for header if it is provided
Read/write full requests even if they are split into several recv/send calls
-- 0.7 (2013-12-05)
Add bintohex function to use when printing binary data to stdout
Check if compiler supports -std=c++11

View File

@@ -12,4 +12,4 @@ ocelot_LDADD = $(BOOST_IOSTREAMS_LIB) $(BOOST_SYSTEM_LIB) -lev -lmysqlpp
EXTRA_DIST = CHANGES LICENSE config.cpp.template
dist-hook:
touch ${distdir}/configure
patch -p2 -d ${distdir} < ../dist.patch
patch -p2 -d ${distdir} --no-backup-if-mismatch < ../dist.patch

View File

@@ -1,4 +1,4 @@
# Makefile.in generated by automake 1.14 from Makefile.am.
# Makefile.in generated by automake 1.14.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
@@ -106,8 +106,9 @@ am_ocelot_OBJECTS = db.$(OBJEXT) events.$(OBJEXT) \
nodist_ocelot_OBJECTS = config.$(OBJEXT)
ocelot_OBJECTS = $(am_ocelot_OBJECTS) $(nodist_ocelot_OBJECTS)
am__DEPENDENCIES_1 =
ocelot_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
$(am__DEPENDENCIES_1)
ocelot_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
ocelot_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(ocelot_LDFLAGS) \
$(LDFLAGS) -o $@
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
@@ -307,7 +308,8 @@ ocelot_SOURCES = config.h db.cpp db.h events.cpp events.h misc_functions.cpp mis
nodist_ocelot_SOURCES = config.cpp
AM_CPPFLAGS = -std=c++11 -march=native -O2 -fvisibility=hidden -fvisibility-inlines-hidden -fomit-frame-pointer -fno-ident -pthread -Wall -Wfatal-errors -Wl,O1 -Wl,--as-needed $(BOOST_CPPFLAGS) -I$(MYSQLPP_INC_DIR) -I$(EV_INC_DIR) -I$(MYSQL_C_INC_DIR)
ocelot_LDADD = $(BOOST_LDFLAGS) $(BOOST_IOSTREAMS_LIB) $(BOOST_SYSTEM_LIB) -L$(EV_LIB_DIR) -L$(MYSQLPP_LIB_DIR) -lev -lmysqlpp
ocelot_LDFLAGS = $(BOOST_IOSTREAMS_LIB) $(BOOST_SYSTEM_LIB) -L$(MYSQLPP_LIB_DIR) -pthread
ocelot_LDADD = $(BOOST_IOSTREAMS_LIB) $(BOOST_SYSTEM_LIB) -lev -lmysqlpp
EXTRA_DIST = CHANGES LICENSE config.cpp.template
all: all-am
@@ -392,7 +394,7 @@ clean-binPROGRAMS:
ocelot$(EXEEXT): $(ocelot_OBJECTS) $(ocelot_DEPENDENCIES) $(EXTRA_ocelot_DEPENDENCIES)
@rm -f ocelot$(EXEEXT)
$(AM_V_CXXLD)$(CXXLINK) $(ocelot_OBJECTS) $(ocelot_LDADD) $(LIBS)
$(AM_V_CXXLD)$(ocelot_LINK) $(ocelot_OBJECTS) $(ocelot_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -595,9 +597,10 @@ distcheck: dist
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& am__cwd=`pwd` \
&& $(am__cd) $(distdir)/_build \
&& ../configure --srcdir=.. --prefix="$$dc_install_base" \
&& ../configure \
$(AM_DISTCHECK_CONFIGURE_FLAGS) \
$(DISTCHECK_CONFIGURE_FLAGS) \
--srcdir=.. --prefix="$$dc_install_base" \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
@@ -780,7 +783,7 @@ uninstall-am: uninstall-binPROGRAMS
dist-hook:
touch ${distdir}/configure
patch -p2 -d ${distdir} < ../dist.patch
patch -p2 -d ${distdir} --no-backup-if-mismatch < ../dist.patch
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.

6
aclocal.m4 vendored
View File

@@ -1,4 +1,4 @@
# generated automatically by aclocal 1.14 -*- Autoconf -*-
# generated automatically by aclocal 1.14.1 -*- Autoconf -*-
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
@@ -35,7 +35,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION],
[am__api_version='1.14'
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
dnl require some minimum version. Point them to the right macro.
m4_if([$1], [1.14], [],
m4_if([$1], [1.14.1], [],
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
])
@@ -51,7 +51,7 @@ m4_define([_AM_AUTOCONF_VERSION], [])
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.14])dnl
[AM_AUTOMAKE_VERSION([1.14.1])dnl
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])

View File

@@ -5,6 +5,7 @@ config::config() {
port = 34000;
max_connections = 512;
max_read_buffer = 4096;
max_request_size = 4096;
timeout_interval = 20;
schedule_interval = 3;
max_middlemen = 5000;

243
config.guess vendored
View File

@@ -1,10 +1,8 @@
#! /bin/sh
# Attempt to guess a canonical system name.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012, 2013 Free Software Foundation, Inc.
# Copyright 1992-2014 Free Software Foundation, Inc.
timestamp='2012-12-30'
timestamp='2014-02-12'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@@ -52,9 +50,7 @@ version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
2012, 2013 Free Software Foundation, Inc.
Copyright 1992-2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -137,25 +133,23 @@ UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
case "${UNAME_SYSTEM}" in
Linux|GNU/*)
Linux|GNU|GNU/*)
# If the system lacks a compiler, then just pick glibc.
# We could probably try harder.
LIBC=gnu
eval $set_cc_for_build
cat <<-EOF > $dummy.c
#include <features.h>
#ifdef __UCLIBC__
# ifdef __UCLIBC_CONFIG_VERSION__
LIBC=uclibc __UCLIBC_CONFIG_VERSION__
# else
#if defined(__UCLIBC__)
LIBC=uclibc
# endif
#else
# ifdef __dietlibc__
#elif defined(__dietlibc__)
LIBC=dietlibc
# else
#else
LIBC=gnu
# endif
#endif
EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
;;
esac
@@ -910,6 +904,9 @@ EOF
if test "$?" = 0 ; then LIBC="gnulibc1" ; fi
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
arc:Linux:*:* | arceb:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
arm*:Linux:*:*)
eval $set_cc_for_build
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
@@ -972,6 +969,9 @@ EOF
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
;;
or1k:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
or32:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
exit ;;
@@ -995,8 +995,14 @@ EOF
ppc:Linux:*:*)
echo powerpc-unknown-linux-${LIBC}
exit ;;
ppc64le:Linux:*:*)
echo powerpc64le-unknown-linux-${LIBC}
exit ;;
ppcle:Linux:*:*)
echo powerpcle-unknown-linux-${LIBC}
exit ;;
s390:Linux:*:* | s390x:Linux:*:*)
echo ${UNAME_MACHINE}-ibm-linux
echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
exit ;;
sh64*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
@@ -1014,7 +1020,18 @@ EOF
echo ${UNAME_MACHINE}-dec-linux-${LIBC}
exit ;;
x86_64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
eval $set_cc_for_build
X86_64_ABI=
# If there is a compiler, see if it is configured for 32-bit objects.
if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \
(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_X32 >/dev/null
then
X86_64_ABI=x32
fi
fi
echo x86_64-unknown-linux-gnu${X86_64_ABI}
exit ;;
xtensa*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
@@ -1250,19 +1267,31 @@ EOF
exit ;;
*:Darwin:*:*)
UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
case $UNAME_PROCESSOR in
i386)
eval $set_cc_for_build
if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
then
UNAME_PROCESSOR="x86_64"
fi
fi ;;
unknown) UNAME_PROCESSOR=powerpc ;;
esac
eval $set_cc_for_build
if test "$UNAME_PROCESSOR" = unknown ; then
UNAME_PROCESSOR=powerpc
fi
if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then
if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
then
case $UNAME_PROCESSOR in
i386) UNAME_PROCESSOR=x86_64 ;;
powerpc) UNAME_PROCESSOR=powerpc64 ;;
esac
fi
fi
elif test "$UNAME_PROCESSOR" = i386 ; then
# Avoid executing cc on OS X 10.9, as it ships with a stub
# that puts up a graphical alert prompting to install
# developer tools. Any system running Mac OS X 10.7 or
# later (Darwin 11 and later) is required to have a 64-bit
# processor. This is not true of the ARM version of Darwin
# that Apple uses in portable devices.
UNAME_PROCESSOR=x86_64
fi
echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
exit ;;
*:procnto*:*:* | *:QNX:[0123456789]*:*)
@@ -1353,154 +1382,6 @@ EOF
exit ;;
esac
eval $set_cc_for_build
cat >$dummy.c <<EOF
#ifdef _SEQUENT_
# include <sys/types.h>
# include <sys/utsname.h>
#endif
main ()
{
#if defined (sony)
#if defined (MIPSEB)
/* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
I don't know.... */
printf ("mips-sony-bsd\n"); exit (0);
#else
#include <sys/param.h>
printf ("m68k-sony-newsos%s\n",
#ifdef NEWSOS4
"4"
#else
""
#endif
); exit (0);
#endif
#endif
#if defined (__arm) && defined (__acorn) && defined (__unix)
printf ("arm-acorn-riscix\n"); exit (0);
#endif
#if defined (hp300) && !defined (hpux)
printf ("m68k-hp-bsd\n"); exit (0);
#endif
#if defined (NeXT)
#if !defined (__ARCHITECTURE__)
#define __ARCHITECTURE__ "m68k"
#endif
int version;
version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
if (version < 4)
printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
else
printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
exit (0);
#endif
#if defined (MULTIMAX) || defined (n16)
#if defined (UMAXV)
printf ("ns32k-encore-sysv\n"); exit (0);
#else
#if defined (CMU)
printf ("ns32k-encore-mach\n"); exit (0);
#else
printf ("ns32k-encore-bsd\n"); exit (0);
#endif
#endif
#endif
#if defined (__386BSD__)
printf ("i386-pc-bsd\n"); exit (0);
#endif
#if defined (sequent)
#if defined (i386)
printf ("i386-sequent-dynix\n"); exit (0);
#endif
#if defined (ns32000)
printf ("ns32k-sequent-dynix\n"); exit (0);
#endif
#endif
#if defined (_SEQUENT_)
struct utsname un;
uname(&un);
if (strncmp(un.version, "V2", 2) == 0) {
printf ("i386-sequent-ptx2\n"); exit (0);
}
if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
printf ("i386-sequent-ptx1\n"); exit (0);
}
printf ("i386-sequent-ptx\n"); exit (0);
#endif
#if defined (vax)
# if !defined (ultrix)
# include <sys/param.h>
# if defined (BSD)
# if BSD == 43
printf ("vax-dec-bsd4.3\n"); exit (0);
# else
# if BSD == 199006
printf ("vax-dec-bsd4.3reno\n"); exit (0);
# else
printf ("vax-dec-bsd\n"); exit (0);
# endif
# endif
# else
printf ("vax-dec-bsd\n"); exit (0);
# endif
# else
printf ("vax-dec-ultrix\n"); exit (0);
# endif
#endif
#if defined (alliant) && defined (i860)
printf ("i860-alliant-bsd\n"); exit (0);
#endif
exit (1);
}
EOF
$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
{ echo "$SYSTEM_NAME"; exit; }
# Apollos put the system type in the environment.
test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
# Convex versions that predate uname can use getsysinfo(1)
if [ -x /usr/convex/getsysinfo ]
then
case `getsysinfo -f cpu_type` in
c1*)
echo c1-convex-bsd
exit ;;
c2*)
if getsysinfo -f scalar_acc
then echo c32-convex-bsd
else echo c2-convex-bsd
fi
exit ;;
c34*)
echo c34-convex-bsd
exit ;;
c38*)
echo c38-convex-bsd
exit ;;
c4*)
echo c4-convex-bsd
exit ;;
esac
fi
cat >&2 <<EOF
$0: unable to guess system type

View File

@@ -9,16 +9,17 @@ class config {
unsigned int port;
unsigned int max_connections;
unsigned int max_read_buffer;
unsigned int max_request_size;
unsigned int timeout_interval;
unsigned int schedule_interval;
unsigned int max_middlemen;
unsigned int announce_interval;
unsigned int peers_timeout;
unsigned int reap_peers_interval;
unsigned int del_reason_lifetime;
// MySQL
std::string mysql_db;
std::string mysql_host;

38
config.sub vendored
View File

@@ -1,10 +1,8 @@
#! /bin/sh
# Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012, 2013 Free Software Foundation, Inc.
# Copyright 1992-2014 Free Software Foundation, Inc.
timestamp='2013-01-11'
timestamp='2014-01-01'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@@ -70,9 +68,7 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\
GNU config.sub ($timestamp)
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
2012, 2013 Free Software Foundation, Inc.
Copyright 1992-2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -256,12 +252,12 @@ case $basic_machine in
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| am33_2.0 \
| arc \
| arc | arceb \
| arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
| avr | avr32 \
| be32 | be64 \
| bfin \
| c4x | clipper \
| c4x | c8051 | clipper \
| d10v | d30v | dlx | dsp16xx | dvp \
| epiphany \
| fido | fr30 | frv \
@@ -269,6 +265,7 @@ case $basic_machine in
| hexagon \
| i370 | i860 | i960 | ia64 \
| ip2k | iq2000 \
| k1om \
| le32 | le64 \
| lm32 \
| m32c | m32r | m32rle | m68000 | m68k | m88k \
@@ -297,10 +294,10 @@ case $basic_machine in
| mt \
| msp430 \
| nds32 | nds32le | nds32be \
| nios | nios2 \
| nios | nios2 | nios2eb | nios2el \
| ns16k | ns32k \
| open8 \
| or32 \
| or1k | or32 \
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle \
| pyramid \
@@ -328,7 +325,7 @@ case $basic_machine in
c6x)
basic_machine=tic6x-unknown
;;
m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)
m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip)
basic_machine=$basic_machine-unknown
os=-none
;;
@@ -370,13 +367,13 @@ case $basic_machine in
| aarch64-* | aarch64_be-* \
| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
| avr-* | avr32-* \
| be32-* | be64-* \
| bfin-* | bs2000-* \
| c[123]* | c30-* | [cjt]90-* | c4x-* \
| clipper-* | craynv-* | cydra-* \
| c8051-* | clipper-* | craynv-* | cydra-* \
| d10v-* | d30v-* | dlx-* \
| elxsi-* \
| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
@@ -385,6 +382,7 @@ case $basic_machine in
| hexagon-* \
| i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* | iq2000-* \
| k1om-* \
| le32-* | le64-* \
| lm32-* \
| m32c-* | m32r-* | m32rle-* \
@@ -414,7 +412,7 @@ case $basic_machine in
| mt-* \
| msp430-* \
| nds32-* | nds32le-* | nds32be-* \
| nios-* | nios2-* \
| nios-* | nios2-* | nios2eb-* | nios2el-* \
| none-* | np1-* | ns16k-* | ns32k-* \
| open8-* \
| orion-* \
@@ -798,7 +796,7 @@ case $basic_machine in
os=-mingw64
;;
mingw32)
basic_machine=i386-pc
basic_machine=i686-pc
os=-mingw32
;;
mingw32ce)
@@ -852,7 +850,7 @@ case $basic_machine in
basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
;;
msys)
basic_machine=i386-pc
basic_machine=i686-pc
os=-msys
;;
mvs)
@@ -1568,6 +1566,9 @@ case $basic_machine in
c4x-* | tic4x-*)
os=-coff
;;
c8051-*)
os=-elf
;;
hexagon-*)
os=-elf
;;
@@ -1611,6 +1612,9 @@ case $basic_machine in
mips*-*)
os=-elf
;;
or1k-*)
os=-elf
;;
or32-*)
os=-coff
;;

20
configure vendored
View File

@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for ocelot 0.7.
# Generated by GNU Autoconf 2.69 for ocelot 0.8.
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -577,8 +577,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='ocelot'
PACKAGE_TARNAME='ocelot'
PACKAGE_VERSION='0.7'
PACKAGE_STRING='ocelot 0.7'
PACKAGE_VERSION='0.8'
PACKAGE_STRING='ocelot 0.8'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
@@ -1300,7 +1300,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures ocelot 0.7 to adapt to many kinds of systems.
\`configure' configures ocelot 0.8 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1369,7 +1369,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of ocelot 0.7:";;
short | recursive ) echo "Configuration of ocelot 0.8:";;
esac
cat <<\_ACEOF
@@ -1498,7 +1498,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
ocelot configure 0.7
ocelot configure 0.8
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1834,7 +1834,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by ocelot $as_me 0.7, which was
It was created by ocelot $as_me 0.8, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -2697,7 +2697,7 @@ fi
# Define the identity of the package.
PACKAGE='ocelot'
VERSION='0.7'
VERSION='0.8'
# Some tools Automake needs.
@@ -6524,7 +6524,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by ocelot $as_me 0.7, which was
This file was extended by ocelot $as_me 0.8, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -6581,7 +6581,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
ocelot config.status 0.7
ocelot config.status 0.8
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"

View File

@@ -1,4 +1,4 @@
AC_INIT(ocelot, 0.7)
AC_INIT(ocelot, 0.8)
AM_INIT_AUTOMAKE([1.11 no-define foreign])
AC_PROG_CXX
AC_CONFIG_FILES([Makefile])

27
db.cpp
View File

@@ -9,32 +9,31 @@
#include <time.h>
#include <mutex>
#include <thread>
#include <boost/lexical_cast.hpp>
#define DB_LOCK_TIMEOUT 50
mysql::mysql(std::string mysql_db, std::string mysql_host, std::string username, std::string password) {
if (!conn.connect(mysql_db.c_str(), mysql_host.c_str(), username.c_str(), password.c_str(), 0)) {
std::cout << "Could not connect to MySQL" << std::endl;
mysql::mysql(std::string mysql_db, std::string mysql_host, std::string username, std::string password) :
db(mysql_db), server(mysql_host), db_user(username), pw(password),
u_active(false), t_active(false), p_active(false), s_active(false), tok_active(false)
{
try {
conn.connect(mysql_db.c_str(), mysql_host.c_str(), username.c_str(), password.c_str(), 0);
} catch (const mysqlpp::Exception &er) {
std::cout << "Failed to connect to MySQL (" << er.what() << ')' << std::endl;
return;
}
db = mysql_db, server = mysql_host, db_user = username, pw = password;
u_active = false; t_active = false; p_active = false; s_active = false; tok_active = false;
std::cout << "Connected to MySQL" << std::endl;
update_user_buffer = "";
update_torrent_buffer = "";
update_heavy_peer_buffer = "";
update_light_peer_buffer = "";
update_snatch_buffer = "";
std::cout << "Clearing xbt_files_users and resetting peer counts...";
std::cout.flush();
clear_peer_data();
std::cout << "done" << std::endl;
}
bool mysql::connected() {
return conn.connected();
}
void mysql::clear_peer_data() {
try {
mysqlpp::Query query = conn.query("TRUNCATE xbt_files_users;");
@@ -454,7 +453,7 @@ void mysql::do_flush_snatches() {
std::unique_lock<std::mutex> sq_lock(snatch_queue_lock);
snatch_queue.pop();
}
}
}
catch (const mysqlpp::BadQuery &er) {
std::cerr << "Query error: " << er.what() << " in flush snatches with a qlength: " << snatch_queue.front().size() << " queue size: " << snatch_queue.size() << std::endl;
sleep(3);

7
db.h
View File

@@ -16,7 +16,7 @@ class mysql {
std::string update_light_peer_buffer;
std::string update_snatch_buffer;
std::string update_token_buffer;
std::queue<std::string> user_queue;
std::queue<std::string> torrent_queue;
std::queue<std::string> peer_queue;
@@ -52,11 +52,12 @@ class mysql {
bool verbose_flush;
mysql(std::string mysql_db, std::string mysql_host, std::string username, std::string password);
bool connected();
void load_torrents(torrent_list &torrents);
void load_users(user_list &users);
void load_tokens(torrent_list &torrents);
void load_whitelist(std::vector<std::string> &whitelist);
void record_user(std::string &record); // (id,uploaded_change,downloaded_change)
void record_torrent(std::string &record); // (id,seeders,leechers,snatched_change,balance)
void record_snatch(std::string &record, std::string &ip); // (uid,fid,tstamp)
@@ -67,7 +68,7 @@ class mysql {
void flush();
bool all_clear();
std::mutex torrent_list_mutex;
};

View File

@@ -1,7 +1,7 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2012-10-18.11; # UTC
scriptversion=2013-05-30.07; # UTC
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
@@ -552,6 +552,7 @@ $ {
G
p
}' >> "$depfile"
echo >> "$depfile" # make sure the fragment doesn't end with a backslash
rm -f "$tmpdepfile"
;;

View File

@@ -4,6 +4,7 @@
#include "worker.h"
#include "events.h"
#include "schedule.h"
#include "response.h"
#include <cerrno>
#include <mutex>
@@ -16,37 +17,37 @@
connection_mother::connection_mother(worker * worker_obj, config * config_obj, mysql * db_obj, site_comm * sc_obj) : work(worker_obj), conf(config_obj), db(db_obj), sc(sc_obj) {
memset(&address, 0, sizeof(address));
addr_len = sizeof(address);
listen_socket = socket(AF_INET, SOCK_STREAM, 0);
// Stop old sockets from hogging the port
int yes = 1;
if (setsockopt(listen_socket, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1) {
std::cout << "Could not reuse socket" << std::endl;
}
// Create libev event loop
ev::io event_loop_watcher;
event_loop_watcher.set<connection_mother, &connection_mother::handle_connect>(this);
event_loop_watcher.start(listen_socket, ev::READ);
// Get ready to bind
address.sin_family = AF_INET;
//address.sin_addr.s_addr = inet_addr(conf->host.c_str()); // htonl(INADDR_ANY)
address.sin_addr.s_addr = htonl(INADDR_ANY);
address.sin_port = htons(conf->port);
// Bind
if (bind(listen_socket, (sockaddr *) &address, sizeof(address)) == -1) {
std::cout << "Bind failed " << errno << std::endl;
}
// Listen
if (listen(listen_socket, conf->max_connections) == -1) {
std::cout << "Listen failed" << std::endl;
}
// Set non-blocking
int flags = fcntl(listen_socket, F_GETFL);
if (flags == -1) {
@@ -55,14 +56,14 @@ connection_mother::connection_mother(worker * worker_obj, config * config_obj, m
if (fcntl(listen_socket, F_SETFL, flags | O_NONBLOCK) == -1) {
std::cout << "Could not set non-blocking" << std::endl;
}
// Create libev timer
schedule timer(this, worker_obj, conf, db, sc);
schedule_event.set<schedule, &schedule::handle>(&timer);
schedule_event.set(conf->schedule_interval, conf->schedule_interval); // After interval, every interval
schedule_event.start();
std::cout << "Sockets up, starting event loop!" << std::endl;
ev_loop(ev_default_loop(0), 0);
}
@@ -91,9 +92,9 @@ connection_mother::~connection_mother()
//---------- Connection middlemen - these little guys live until their connection is closed
connection_middleman::connection_middleman(int &listen_socket, sockaddr_in &address, socklen_t &addr_len, worker * new_work, connection_mother * mother_arg, config * config_obj) :
connection_middleman::connection_middleman(int &listen_socket, sockaddr_in &address, socklen_t &addr_len, worker * new_work, connection_mother * mother_arg, config * config_obj) :
conf(config_obj), mother (mother_arg), work(new_work) {
connect_sock = accept(listen_socket, (sockaddr *) &address, &addr_len);
if (connect_sock == -1) {
std::cout << "Accept failed, errno " << errno << ": " << strerror(errno) << std::endl;
@@ -102,7 +103,7 @@ connection_middleman::connection_middleman(int &listen_socket, sockaddr_in &addr
stats.open_connections++; // destructor decrements open connections
return;
}
// Set non-blocking
int flags = fcntl(connect_sock, F_GETFL);
if (flags == -1) {
@@ -111,21 +112,22 @@ connection_middleman::connection_middleman(int &listen_socket, sockaddr_in &addr
if (fcntl(connect_sock, F_SETFL, flags | O_NONBLOCK) == -1) {
std::cout << "Could not set non-blocking" << std::endl;
}
// Get their info
if (getpeername(connect_sock, (sockaddr *) &client_addr, &addr_len) == -1) {
//std::cout << "Could not get client info" << std::endl;
}
request.reserve(conf->max_read_buffer);
written = 0;
read_event.set<connection_middleman, &connection_middleman::handle_read>(this);
read_event.start(connect_sock, ev::READ);
// Let the socket timeout in timeout_interval seconds
timeout_event.set<connection_middleman, &connection_middleman::handle_timeout>(this);
timeout_event.set(conf->timeout_interval, 0);
timeout_event.start();
std::unique_lock<std::mutex> lock(stats.mutex);
stats.open_connections++;
}
@@ -138,43 +140,53 @@ connection_middleman::~connection_middleman() {
// Handler to read data from the socket, called by event loop when socket is readable
void connection_middleman::handle_read(ev::io &watcher, int events_flags) {
read_event.stop();
char buffer[conf->max_read_buffer + 1];
memset(buffer, 0, conf->max_read_buffer + 1);
int ret = recv(connect_sock, &buffer, conf->max_read_buffer, 0);
if (ret == -1) {
if (ret <= 0) {
delete this;
return;
}
std::unique_lock<std::mutex> lock(stats.mutex);
stats.bytes_read += ret;
lock.unlock();
std::string stringbuf = buffer;
char ip[INET_ADDRSTRLEN];
inet_ntop(AF_INET, &(client_addr.sin_addr), ip, INET_ADDRSTRLEN);
std::string ip_str = ip;
//--- CALL WORKER
response = work->work(stringbuf, ip_str);
// Find out when the socket is writeable.
// The loop in connection_mother will call handle_write when it is.
write_event.set<connection_middleman, &connection_middleman::handle_write>(this);
write_event.start(connect_sock, ev::WRITE);
request.append(buffer, ret);
size_t request_size = request.size();
if (request_size > conf->max_request_size || (request_size >= 4 && request.compare(request_size - 4, std::string::npos, "\r\n\r\n") == 0)) {
read_event.stop();
if (request_size > conf->max_request_size) {
shutdown(connect_sock, SHUT_RD);
response = error("GET string too long");
} else {
char ip[INET_ADDRSTRLEN];
inet_ntop(AF_INET, &(client_addr.sin_addr), ip, INET_ADDRSTRLEN);
std::string ip_str = ip;
//--- CALL WORKER
response = work->work(request, ip_str);
}
// Find out when the socket is writeable.
// The loop in connection_mother will call handle_write when it is.
write_event.set<connection_middleman, &connection_middleman::handle_write>(this);
write_event.start(connect_sock, ev::WRITE);
}
}
// Handler to write data to the socket, called by event loop when socket is writeable
void connection_middleman::handle_write(ev::io &watcher, int events_flags) {
write_event.stop();
timeout_event.stop();
send(connect_sock, response.c_str(), response.size(), MSG_NOSIGNAL);
int ret = send(connect_sock, response.c_str()+written, response.size()-written, MSG_NOSIGNAL);
written += ret;
std::unique_lock<std::mutex> lock(stats.mutex);
stats.bytes_written += response.size();
stats.bytes_written += ret;
lock.unlock();
delete this;
if (written == response.size()) {
write_event.stop();
timeout_event.stop();
delete this;
}
}
// After a middleman has been alive for timout_interval seconds, this is called

View File

@@ -9,12 +9,12 @@
#include <sys/socket.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <unistd.h>
/*
TODO find out what these do
#include <unistd.h>
#include <netinet/in.h>
#include <netdb.h>
#include <sys/types.h>
@@ -27,7 +27,7 @@ TODO find out what these do
/*
We have three classes - the mother, the middlemen, and the worker
THE MOTHER
The mother is called when a client opens a connection to the server.
The mother is called when a client opens a connection to the server.
It creates a middleman for every new connection, which will be called
when its socket is ready for reading.
THE MIDDLEMEN
@@ -35,9 +35,9 @@ THE MIDDLEMEN
reads the data and sends it to the worker. When it gets the response, it
gets called to write its data back to the client.
THE WORKER
The worker gets data from the middleman, and returns the response. It
doesn't concern itself with silly things like sockets.
The worker gets data from the middleman, and returns the response. It
doesn't concern itself with silly things like sockets.
see worker.h for the worker.
*/
@@ -55,8 +55,8 @@ class connection_mother {
mysql * db;
site_comm * sc;
ev::timer schedule_event;
public:
public:
connection_mother(worker * worker_obj, config * config_obj, mysql * db_obj, site_comm * sc_obj);
void handle_connect(ev::io &watcher, int events_flags);
~connection_mother();
@@ -68,20 +68,22 @@ class connection_mother {
class connection_middleman {
private:
int connect_sock;
unsigned int written;
ev::io read_event;
ev::io write_event;
ev::timer timeout_event;
std::string request;
std::string response;
config * conf;
connection_mother * mother;
worker * work;
sockaddr_in client_addr;
public:
connection_middleman(int &listen_socket, sockaddr_in &address, socklen_t &addr_len, worker* work, connection_mother * mother_arg, config * config_obj);
~connection_middleman();
void handle_read(ev::io &watcher, int events_flags);
void handle_write(ev::io &watcher, int events_flags);
void handle_timeout(ev::timer &watcher, int events_flags);

View File

@@ -40,7 +40,7 @@ std::string hex_decode(const std::string &in) {
} else if (in[i] >= '0' && in[i] <= '9') {
x = static_cast<unsigned char>((in[i]-48) << 4);
}
i++;
if (in[i] >= 'a' && in[i] <= 'f') {
x += static_cast<unsigned char>(in[i]-87);

View File

@@ -1,7 +1,7 @@
#! /bin/sh
# Common wrapper for a few potentially missing GNU programs.
scriptversion=2012-06-26.16; # UTC
scriptversion=2013-10-28.13; # UTC
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
@@ -160,7 +160,7 @@ give_advice ()
;;
autom4te*)
echo "You might have modified some maintainer files that require"
echo "the 'automa4te' program to be rebuilt."
echo "the 'autom4te' program to be rebuilt."
program_details 'autom4te'
;;
bison*|yacc*)

View File

@@ -33,7 +33,12 @@ int main(int argc, char **argv) {
verbose = true;
}
}
mysql db(conf.mysql_db, conf.mysql_host, conf.mysql_username, conf.mysql_password);
if (!db.connected()) {
std::cout << "Exiting" << std::endl;
return 0;
}
db.verbose_flush = verbose;
site_comm sc(conf);

View File

@@ -47,11 +47,11 @@ typedef struct {
enum {
DUPE, // 0
TRUMP, // 1
BAD_FILE_NAMES, // 2
BAD_FILE_NAMES, // 2
BAD_FOLDER_NAMES, // 3
BAD_TAGS, // 4
BAD_FORMAT, // 5
DISCS_MISSING, // 6
DISCS_MISSING, // 6
DISCOGRAPHY,// 7
EDITED_LOG,// 8
INACCURATE_BITRATE, // 9

View File

@@ -9,7 +9,7 @@
schedule::schedule(connection_mother * mother_obj, worker* worker_obj, config* conf_obj, mysql * db_obj, site_comm * sc_obj) : mother(mother_obj), work(worker_obj), conf(conf_obj), db(db_obj), sc(sc_obj) {
counter = 0;
last_opened_connections = 0;
next_reap_peers = time(NULL) + conf->reap_peers_interval + 40;
}
//---------- Schedule - gets called every schedule_interval seconds
@@ -27,7 +27,7 @@ void schedule::handle(ev::timer &watcher, int events_flags) {
}
last_opened_connections = stats.opened_connections;
db->flush();
sc->flush_tokens();

View File

@@ -11,7 +11,7 @@ class schedule {
site_comm * sc;
uint64_t last_opened_connections;
int counter;
time_t next_flush;
time_t next_reap_peers;
public:

View File

@@ -25,8 +25,6 @@
#include "report.h"
#include "user.h"
#include <boost/bind.hpp>
//---------- Worker - does stuff with input
worker::worker(torrent_list &torrents, user_list &users, std::vector<std::string> &_whitelist, config * conf_obj, mysql * db_obj, site_comm * sc) : torrents_list(torrents), users_list(users), whitelist(_whitelist), conf(conf_obj), db(db_obj), s_comm(sc)
{
@@ -297,6 +295,10 @@ std::string worker::announce(torrent &tor, user_ptr &u, params_type &params, par
} else {
completed_torrent = false;
}
} else if (tor.seeders.find(peer_id) != tor.seeders.end()) {
// If the peer exists in both peer lists, just decrement the seed count.
// Should be cheaper than searching the seed list in the left > 0 case
dec_s = true;
}
} else {
peer_it = tor.seeders.find(peer_id);
@@ -310,9 +312,6 @@ std::string worker::announce(torrent &tor, user_ptr &u, params_type &params, par
std::pair<peer_list::iterator, bool> insert
= tor.seeders.insert(std::pair<std::string, peer>(peer_id, *p));
tor.leechers.erase(peer_it);
/*if (downloaded > 0) {
std::cout << "Found unreported snatch from user " << userid << " on torrent " << tor.id << std::endl;
}*/
peer_it = insert.first;
peer_changed = true;
dec_l = true;
@@ -402,10 +401,17 @@ std::string worker::announce(torrent &tor, user_ptr &u, params_type &params, par
params_type::const_iterator param_ip = params.find("ip");
if (param_ip != params.end()) {
ip = param_ip->second;
} else if ((param_ip = params.find("ipv4")) != params.end()) {
ip = param_ip->second;
} else {
param_ip = params.find("ipv4");
if (param_ip != params.end()) {
ip = param_ip->second;
auto head_itr = headers.find("x-forwarded-for");
if (head_itr != headers.end()) {
size_t ip_end_pos = head_itr->second.find(',');
if (ip_end_pos != std::string::npos) {
ip = head_itr->second.substr(0, ip_end_pos);
} else {
ip = head_itr->second;
}
}
}
@@ -538,8 +544,8 @@ std::string worker::announce(torrent &tor, user_ptr &u, params_type &params, par
} else {
end = i;
if (--end == tor.seeders.begin()) {
end++;
i++;
++end;
++i;
}
}
@@ -550,18 +556,18 @@ std::string worker::announce(torrent &tor, user_ptr &u, params_type &params, par
}
// Don't show users themselves
if (i->second.user->get_id() == userid || !i->second.visible) {
i++;
++i;
continue;
}
peers.append(i->second.ip_port);
found_peers++;
tor.last_selected_seeder = i->first;
i++;
++i;
}
}
if (found_peers < numwant && tor.leechers.size() > 1) {
for (peer_list::const_iterator i = tor.leechers.begin(); i != tor.leechers.end() && found_peers < numwant; i++) {
for (peer_list::const_iterator i = tor.leechers.begin(); i != tor.leechers.end() && found_peers < numwant; ++i) {
// Don't show users themselves or leech disabled users
if (i->second.ip_port == p->ip_port || i->second.user->get_id() == userid || !i->second.visible) {
continue;
@@ -572,7 +578,7 @@ std::string worker::announce(torrent &tor, user_ptr &u, params_type &params, par
}
} else if (tor.leechers.size() > 0) { // User is a seeder, and we have leechers!
for (peer_list::const_iterator i = tor.leechers.begin(); i != tor.leechers.end() && found_peers < numwant; i++) {
for (peer_list::const_iterator i = tor.leechers.begin(); i != tor.leechers.end() && found_peers < numwant; ++i) {
// Don't show users themselves or leech disabled users
if (i->second.user->get_id() == userid || !i->second.visible) {
continue;
@@ -582,7 +588,7 @@ std::string worker::announce(torrent &tor, user_ptr &u, params_type &params, par
}
}
}
// Update the stats
std::unique_lock<std::mutex> lock(stats.mutex);
stats.succ_announcements++;
@@ -634,7 +640,7 @@ std::string worker::announce(torrent &tor, user_ptr &u, params_type &params, par
// Putting this after the peer deletion gives us accurate swarm sizes
if (update_torrent || tor.last_flushed + 3600 < cur_time) {
tor.last_flushed = cur_time;
std::stringstream record;
record << '(' << tor.id << ',' << tor.seeders.size() << ',' << tor.leechers.size() << ',' << snatched << ',' << tor.balance << ')';
std::string record_str = record.str();
@@ -682,7 +688,7 @@ std::string worker::announce(torrent &tor, user_ptr &u, params_type &params, par
std::string worker::scrape(const std::list<std::string> &infohashes, params_type &headers) {
bool gzip = false;
std::string output = "d5:filesd";
for (std::list<std::string>::const_iterator i = infohashes.begin(); i != infohashes.end(); i++) {
for (std::list<std::string>::const_iterator i = infohashes.begin(); i != infohashes.end(); ++i) {
std::string infohash = *i;
infohash = hex_decode(infohash);
@@ -819,10 +825,10 @@ std::string worker::update(params_type &params) {
stats.seeders -= torrent_it->second.seeders.size();
stats_lock.unlock();
std::unique_lock<std::mutex> us_lock(ustats_lock);
for (auto p = torrent_it->second.leechers.begin(); p != torrent_it->second.leechers.end(); p++) {
for (auto p = torrent_it->second.leechers.begin(); p != torrent_it->second.leechers.end(); ++p) {
p->second.user->decr_leeching();
}
for (auto p = torrent_it->second.seeders.begin(); p != torrent_it->second.seeders.end(); p++) {
for (auto p = torrent_it->second.seeders.begin(); p != torrent_it->second.seeders.end(); ++p) {
p->second.user->decr_seeding();
}
us_lock.unlock();
@@ -948,14 +954,13 @@ void worker::reap_peers() {
cur_time = time(NULL);
unsigned int reaped_l = 0, reaped_s = 0;
unsigned int cleared_torrents = 0;
for (auto t = torrents_list.begin(); t != torrents_list.end(); t++) {
for (auto t = torrents_list.begin(); t != torrents_list.end(); ++t) {
bool reaped_this = false; // True if at least one peer was deleted from the current torrent
auto p = t->second.leechers.begin();
peer_list::iterator del_p;
while (p != t->second.leechers.end()) {
if (p->second.last_announced + conf->peers_timeout < cur_time) {
del_p = p;
p++;
del_p = p++;
std::unique_lock<std::mutex> us_lock(ustats_lock);
del_p->second.user->decr_leeching();
us_lock.unlock();
@@ -964,14 +969,13 @@ void worker::reap_peers() {
reaped_this = true;
reaped_l++;
} else {
p++;
++p;
}
}
p = t->second.seeders.begin();
while (p != t->second.seeders.end()) {
if (p->second.last_announced + conf->peers_timeout < cur_time) {
del_p = p;
p++;
del_p = p++;
std::unique_lock<std::mutex> us_lock(ustats_lock);
del_p->second.user->decr_seeding();
us_lock.unlock();
@@ -980,7 +984,7 @@ void worker::reap_peers() {
reaped_this = true;
reaped_s++;
} else {
p++;
++p;
}
}
if (reaped_this && t->second.seeders.empty() && t->second.leechers.empty()) {
@@ -1007,14 +1011,13 @@ void worker::reap_del_reasons()
unsigned int reaped = 0;
for (; it != del_reasons.end(); ) {
if (it->second.time <= max_time) {
auto del_it = it;
it++;
auto del_it = it++;
std::unique_lock<std::mutex> dr_lock(del_reasons_lock);
del_reasons.erase(del_it);
reaped++;
continue;
}
it++;
++it;
}
std::cout << "Reaped " << reaped << " del reasons" << std::endl;
}