rollback revisions introducing new stuff

(which should not happen) and thus breaking building those are the
revisions:

2008-01-23T19:48:33Z!paniemin@cc.hut.fi
2008-01-23T20:03:29Z!benoit.timbert@free.fr (partly)
2008-01-23T20:06:14Z!benoit.timbert@free.fr
2008-01-24T17:07:32Z!koraq@xs4all.nl
2008-01-26T08:34:13Z!paniemin@cc.hut.fi
2008-01-26T10:30:28Z!paniemin@cc.hut.fi
This commit is contained in:
Nils Kneuper 2008-01-27 21:51:48 +00:00
parent 40614c53c1
commit 4a990a75c6
5 changed files with 4 additions and 167 deletions

View file

@ -244,12 +244,6 @@ AC_ARG_WITH([server-gid],
[servergid=""])
AC_SUBST([servergid])
AC_ARG_ENABLE([server-monitor],
AS_HELP_STRING([--enable-server-monitor], [enable server monitor thread; libgtop2 is required]),
[servermonitor=$enableval],
[servermonitor=no])
AC_ARG_ENABLE([campaign_server],
AS_HELP_STRING([--enable-campaign-server], [enable compilation of campaign server]),
[campaignserver=$enableval],
@ -320,7 +314,6 @@ AM_CONDITIONAL([STATIC], [test x$static = xyes])
AM_CONDITIONAL([PYTHON_INSTALL], [test x$python_install = xyes])
AM_CONDITIONAL([GAME], [test x$game = xyes])
AM_CONDITIONAL([SERVER], [test x$server = xyes])
AM_CONDITIONAL([SERVER_MONITOR], [test x$servermonitor = xyes])
AM_CONDITIONAL([CAMPAIGNSERVER], [test x$campaignserver = xyes])
AM_CONDITIONAL([TESTS], [test x$tests = xyes])
AM_CONDITIONAL([EDITOR], [test x$editor = xyes])
@ -907,17 +900,6 @@ if test "x$lite" = "xno"; then
fi
fi
#######################################################################
# Check for libgtop2 if server monitor enabled #
#######################################################################
GTOP_LIBS=""
GTOP_CFLAGS=""
if test "x$servermonitor" = "xyes"; then
PKG_CHECK_MODULES([GTOP], [libgtop-2.0 >= 2.10])
fi
#######################################################################
# Check for boost iostreams #
#######################################################################
@ -986,7 +968,6 @@ m4_pattern_allow([^BOOST_AUTO_TEST$])
AM_CONDITIONAL([BOOST_TEST_DYN_LINK], [test x"$boost_test_dyn_link" = xyes])
AM_CONDITIONAL([BOOST_AUTO_TEST], [test x"$boost_auto_test" = xyes])
#######################################################################
# Tune gettext stuff for our needs #
#######################################################################

View file

@ -151,12 +151,11 @@ wesnothd_SOURCES = \
server/player.cpp \
server/proxy.cpp \
server/server.cpp \
server/monitor.cpp \
network.cpp \
network_worker.cpp \
loadscreen_empty.cpp
wesnothd_LDADD = -L. -lwesnoth-core $(GTOP_LIBS) $(BOOST_IOSTREAMS_LIBS) @SDL_NET_LIBS@ @SDL_LIBS@ $(LIBINTL)
wesnothd_LDADD = -L. -lwesnoth-core $(BOOST_IOSTREAMS_LIBS) @SDL_NET_LIBS@ @SDL_LIBS@ $(LIBINTL)
wesnothd_DEPENDENCIES=libwesnoth-core.a
#############################################################################
@ -450,11 +449,10 @@ FORCE:
endif
AM_CXXFLAGS = -I $(srcdir)/sdl_ttf -I../intl -I$(top_srcdir)/intl @SDL_CFLAGS@ -DWESNOTH_PATH=\"$(pkgdatadir)\" \
-DLOCALEDIR=\"$(LOCALEDIR)\" -DHAS_RELATIVE_LOCALEDIR=$(HAS_RELATIVE_LOCALEDIR) -DFIFODIR=\"$(fifodir)\"\
$(GTOP_CFLAGS)
-DLOCALEDIR=\"$(LOCALEDIR)\" -DHAS_RELATIVE_LOCALEDIR=$(HAS_RELATIVE_LOCALEDIR) -DFIFODIR=\"$(fifodir)\"
AM_CFLAGS = -I $(srcdir)/sdl_ttf -I../intl -I$(top_srcdir)/intl @SDL_CFLAGS@ -DWESNOTH_PATH=\"$(pkgdatadir)\" \
-DLOCALEDIR=\"$(LOCALEDIR)\" -DHAS_RELATIVE_LOCALEDIR=$(HAS_RELATIVE_LOCALEDIR) $(GTOP_CFGLAGS)
-DLOCALEDIR=\"$(LOCALEDIR)\" -DHAS_RELATIVE_LOCALEDIR=$(HAS_RELATIVE_LOCALEDIR)
if PYTHON
AM_CXXFLAGS += @PYTHON_CFLAGS@
@ -491,9 +489,7 @@ endif
CXXLD = $(LDPREFIX) $(CXX)
CXXFLAGS += $(BOOST_CPPFLAGS)
if SERVER_MONITOR
CXXFLAGS += -DSERVER_MONITOR
endif
if STATIC
LDFLAGS += -all-static

View file

@ -1,96 +0,0 @@
/* $Id$ */
/*
Copyright (C) 2008 by Pauli Nieminen <paniemin@cc.hut.fi>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
or at your option any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
//! Here is the implementation for server monitoring thread
//! Initial target is to have it useful in posix systems
//! and later add support for windows if possible.
//! If a system doesn't support monitoring it is not compiled.
#include "monitor.hpp"
#include "../util.hpp"
#ifdef SERVER_MONITOR
#include <iostream>
#include <glibtop.h>
#include <glibtop/proctime.h>
#endif
namespace nserver {
#ifdef SERVER_MONITOR
int monitor_thread_start(void *data)
{
server_monitor &monitor = *(static_cast<server_monitor*>(data));
size_t start_time = SDL_GetTicks();
size_t delta;
while(true)
{
monitor.check();
if (monitor.is_ending())
{
break;
}
delta = minimum<size_t>(monitor.get_delay(), SDL_GetTicks() - start_time);
SDL_Delay(monitor.get_delay()-delta);
start_time = SDL_GetTicks();
}
return 0;
}
void server_monitor::check()
{
size_t pid = getpid();
glibtop_proc_time cpu;
glibtop_get_proc_time(&cpu,pid);
std::cout << "cpu time: real: " << cpu.rtime
<< " user: " << cpu.utime
<< " kernel: " << cpu.stime
<< " frequency: " << cpu.frequency
<< "\n";
}
#endif
server_monitor::server_monitor(size_t delay)
#ifdef SERVER_MONITOR
: ending_(false),
delay_(delay),
mutex_(new threading::mutex()),
thread_(new threading::thread(&monitor_thread_start, static_cast<void*>(this)))
#endif
{
#ifdef SERVER_MONITOR
glibtop_init();
#endif
}
server_monitor::~server_monitor()
{
#ifdef SERVER_MONITOR
// atomic operation doesn't need locking :)
ending_ = true;
// Wait for thread to quit
delete thread_;
delete mutex_;
glibtop_close();
#endif
}
}

View file

@ -1,42 +0,0 @@
/* $Id$ */
/*
Copyright (C) 2008 by Pauli Nieminen <paniemin@cc.hut.fi>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
or at your option any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#ifndef SERVER_MONITOR_HPP_INCLUDED
#define SERVER_MONITOR_HPP_INCLUDED
#include "../thread.hpp"
namespace nserver {
class server_monitor {
public:
server_monitor(size_t delay = 1000);
~server_monitor();
#ifdef SERVER_MONITOR
void check();
threading::mutex& get_mutex() const {return *mutex_;};
bool is_ending() const {return ending_;};
size_t get_delay() const {return delay_;};
private:
bool ending_;
int delay_;
threading::mutex* mutex_;
threading::thread* thread_;
#endif
private:
server_monitor(const server_monitor&);
const server_monitor& operator=(const server_monitor&);
};
}
#endif // SERVER_MONITOR_HPP_INCLUDED

View file

@ -31,7 +31,6 @@
#include "metrics.hpp"
#include "player.hpp"
#include "proxy.hpp"
#include "monitor.hpp"
#include <algorithm>
#include <cassert>
@ -148,7 +147,6 @@ private:
void process_data_lobby(const network::connection sock, const config& data);
void process_data_game(const network::connection sock, const config& data);
void delete_game(std::vector<game>::iterator game_it);
nserver::server_monitor monitor;
};
server::server(int port, input_stream& input, const std::string& config_file, size_t min_threads,size_t max_threads)