*** empty log message ***

svn path=/trunk/boinc/; revision=3228
This commit is contained in:
David Anderson 2004-04-07 06:51:42 +00:00
parent 292d1c142f
commit 9767991240
26 changed files with 203 additions and 137 deletions

2
aclocal.m4 vendored
View File

@ -1104,7 +1104,7 @@ AC_DEFUN([SAH_HEADER_STDCXX],[
#
# Revision Log:
# $Log$
# Revision 1.79 2004/04/04 01:59:43 davea
# Revision 1.80 2004/04/07 06:51:37 davea
# *** empty log message ***
#
# Revision 1.1 2003/12/11 18:38:24 korpela

View File

@ -11386,3 +11386,33 @@ David April 4 2004
client/
app.C
David April 6 2004
- move update_average() from sched_util.C to util.C
(and give it a half-life arg)
- move Messages class declaration out of util.h into its own file
- move file_lock() from util.C to filesys.C
- client: rename get_percent_done() to get_fraction_done
(uh... percents are 0..100; fracs are 0..1)
client/
client_state.h
cs_apps.C
cs_benchmark.C
cs_cmdline.C
cs_prefs.C
cs_scheduler.C
gui_rpc_server.C
message.h
lib/
filesys.C,h
messages.C
messages.h (new)
util.C,h
sched/
Makefile.am
sched_send.C
sched_util.C,h
update_stats.C
validate.C
validate_test.C

View File

@ -179,7 +179,7 @@ public:
int cleanup_and_exit();
int set_nslots();
double estimate_cpu_time(WORKUNIT&);
double get_percent_done(RESULT* result);
double get_fraction_done(RESULT* result);
bool input_files_available(RESULT*);
private:
int nslots;

View File

@ -316,7 +316,7 @@ inline double force_fraction(double f) {
return f;
}
double CLIENT_STATE::get_percent_done(RESULT* result) {
double CLIENT_STATE::get_fraction_done(RESULT* result) {
ACTIVE_TASK* atp = active_tasks.lookup_result(result);
return atp ? force_fraction(atp->fraction_done) : 0.0;
}

View File

@ -49,6 +49,7 @@
#include "error_numbers.h"
#include "file_names.h"
#include "filesys.h"
#include "util.h"
#include "cpu_benchmark.h"
#include "client_state.h"

View File

@ -27,6 +27,7 @@
#include <stdio.h>
#endif
#include "util.h"
#include "client_state.h"
static void print_options(char* prog) {

View File

@ -25,6 +25,7 @@
#include "stdafx.h"
#endif
#include "util.h"
#include "filesys.h"
#include "file_names.h"
#include "cpu_benchmark.h"

View File

@ -83,7 +83,7 @@ void CLIENT_STATE::current_work_buf_days(double& work_buf, int& nactive_results)
// TODO: subtract time already finished for WUs in progress
seconds_remaining += estimate_cpu_time(*rp->wup) * (1.0-get_percent_done(rp));
seconds_remaining += estimate_cpu_time(*rp->wup) * (1.0-get_fraction_done(rp));
}
x = seconds_remaining / SECONDS_PER_DAY;
x /= host_info.p_ncpus;
@ -114,7 +114,7 @@ void CLIENT_STATE::update_avg_cpu(PROJECT* p) {
double deltat = now - p->exp_avg_mod_time;
if (deltat > 0) {
if (p->exp_avg_cpu != 0) {
p->exp_avg_cpu *= exp(deltat*EXP_DECAY_RATE);
p->exp_avg_cpu *= exp(-deltat*EXP_DECAY_RATE);
}
p->exp_avg_mod_time = now;
}

View File

@ -30,6 +30,7 @@
#include <string.h>
#endif
#include "util.h"
#include "parse.h"
#include "client_state.h"

View File

@ -22,7 +22,7 @@
#include <vector>
#include "util.h"
#include "messages.h"
#include "client_types.h"
// Show a message, preceded by timestamp and project name

View File

@ -115,7 +115,7 @@ The work manager's menu items are as follows:
<p>
Menu names and other text in the work manager can be displayed in
<a href=gui_languages.php>languages other than English</a>.
<a href=language.php>languages other than English</a>.
<p>
The <b>BOINC screensaver</b> can be selected using the Display Properties dialog.
The BOINC screensaver draws graphics from a running application,

View File

@ -5,9 +5,15 @@ echo "
Menu names and other text in the work manager are stored in
a file called <i>language.ini</i>.
The release uses American English.
Other languages are available
<a href=http://216.198.119.31/BOINC/language_ini/language.htm>here</a>
Many other languages are available;
a complete list is
<a href=http://www.boinc.dk/index.php?page=download_languages>here</a>
(thanks to Robi Buechler and other volunteers for this).
<p>
The BOINC distribution now includes all current language files.
To use a particular language file,
just rename it to 'language.ini'.
";
page_tail();
?>

View File

@ -400,6 +400,30 @@ int boinc_rmdir(const char* name) {
#endif
}
int lock_file(char* filename) {
int retval;
// some systems have both!
#ifdef HAVE_FLOCK
int lock = open(filename, O_WRONLY|O_CREAT, 0644);
retval = flock(lock, LOCK_EX|LOCK_NB);
#elif HAVE_LOCKF
int lock = open(filename, O_WRONLY|O_CREAT, 0644);
retval = lockf(lock, F_TLOCK, 1);
// must leave fd open
#endif
#ifdef _WIN32
HANDLE hfile = CreateFile(
filename, GENERIC_WRITE,
0, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0
);
if (hfile == INVALID_HANDLE_VALUE) retval = 1;
else retval = 0;
#endif
return retval;
}
#ifdef _WIN32
void full_path(char* relname, char* path) {
_getcwd(path, 256);

View File

@ -70,6 +70,7 @@ extern int boinc_copy(const char* orig, const char* newf);
extern int boinc_rename(const char* old, const char* newf);
extern int boinc_mkdir(const char*);
extern int boinc_rmdir(const char*);
extern int lock_file(char*);
#ifdef _WIN32
extern void full_path(char* relname, char* path);
#endif

View File

@ -30,6 +30,7 @@ using namespace std;
#endif
#include "util.h"
#include "messages.h"
//////////////////////////////////////////////////////////////////////
//

52
lib/messages.h Normal file
View File

@ -0,0 +1,52 @@
#include <stdio.h>
#include <cstdarg>
// the __attribute((format...)) tags are GCC extensions that let the compiler
// do like-checking on printf-like arguments
#if !defined(__GNUC__) && !defined(__attribute__)
#define __attribute__(x) /*nothing*/
#endif
class Messages {
int debug_level;
int indent_level;
char spaces[80];
FILE* output;
public:
Messages(FILE* output);
void enter_level(int = 1);
void leave_level() { enter_level(-1); }
Messages& operator++() { enter_level(); return *this; }
Messages& operator--() { leave_level(); return *this; }
void printf(int kind, const char* format, ...) __attribute__ ((format (printf, 3, 4)));
void printf_multiline(int kind, const char* str, const char* prefix_format, ...) __attribute__ ((format (printf, 4, 5)));
void printf_file(int kind, const char* filename, const char* prefix_format, ...) __attribute__ ((format (printf, 4, 5)));
void vprintf(int kind, const char* format, va_list va);
void vprintf_multiline(int kind, const char* str, const char* prefix_format, va_list va);
void vprintf_file(int kind, const char* filename, const char* prefix_format, va_list va);
protected:
virtual const char* v_format_kind(int kind) const = 0;
virtual bool v_message_wanted(int kind) const = 0;
};
// automatically ++/--Messages on scope entry / exit. See lib/messages.C for commentary
class ScopeMessages
{
Messages& messages;
int kind;
public:
ScopeMessages(Messages& messages_, int kind_) : messages(messages_), kind(kind_)
{ ++messages; }
~ScopeMessages() { --messages; }
ScopeMessages& operator++() { ++messages; return *this; }
ScopeMessages& operator--() { --messages; return *this; }
void printf(const char* format, ...) __attribute__ ((format (printf, 2, 3)));
void printf_multiline(const char* str, const char* prefix_format, ...) __attribute__ ((format (printf, 3, 4)));
void printf_file(const char* filename, const char* prefix_format, ...) __attribute__ ((format (printf, 3, 4)));
};

View File

@ -236,30 +236,6 @@ int parse_command_line(char* p, char** argv) {
return argc;
}
int lock_file(char* filename) {
int retval;
// some systems have both!
#ifdef HAVE_FLOCK
int lock = open(filename, O_WRONLY|O_CREAT, 0644);
retval = flock(lock, LOCK_EX|LOCK_NB);
#elif HAVE_LOCKF
int lock = open(filename, O_WRONLY|O_CREAT, 0644);
retval = lockf(lock, F_TLOCK, 1);
// must leave fd open
#endif
#ifdef _WIN32
HANDLE hfile = CreateFile(
filename, GENERIC_WRITE,
0, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0
);
if (hfile == INVALID_HANDLE_VALUE) retval = 1;
else retval = 0;
#endif
return retval;
}
static char x2c(char *what) {
register char digit;
@ -607,3 +583,34 @@ char* windows_format_error_string( unsigned long dwError, char* pszBuf, int iSiz
}
#endif
// Update an estimate of "units per day" of something (credit or CPU time).
// The estimate is exponentially averaged with a given half-life
// (i.e. if no new work is done, the average will decline by 50% in this time).
// This function can be called either with new work,
// or with zero work to decay an existing average.
//
void update_average(
double work_start_time, // when new work was started
// (or zero if no new work)
double work, // amount of new work
double half_life,
double& avg, // average work per day (in and out)
double& avg_time // when average was last computed
) {
double now = dtime();
if (avg_time) {
double diff = now - avg_time;
double diff_days = diff/SECONDS_PER_DAY;
double weight = exp(-diff*M_LN2/half_life);
avg *= weight;
avg += (1-weight)*(work/diff_days);
} else {
double dd = (now - work_start_time)/SECONDS_PER_DAY;
avg = work/dd;
}
avg_time = now;
}

View File

@ -27,7 +27,6 @@
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdarg>
#include <algorithm>
#include <string>
using std::string;
@ -76,57 +75,6 @@ inline void downcase_string(string& w) {
// NOTE: use #include <functional> to get max,min
// the __attribute((format...)) tags are GCC extensions that let the compiler
// do like-checking on printf-like arguments
#if !defined(__GNUC__) && !defined(__attribute__)
#define __attribute__(x) /*nothing*/
#endif
// See lib/messages.C for commentary
class Messages {
int debug_level;
int indent_level;
char spaces[80];
FILE* output;
public:
Messages(FILE* output);
void enter_level(int = 1);
void leave_level() { enter_level(-1); }
Messages& operator++() { enter_level(); return *this; }
Messages& operator--() { leave_level(); return *this; }
void printf(int kind, const char* format, ...) __attribute__ ((format (printf, 3, 4)));
void printf_multiline(int kind, const char* str, const char* prefix_format, ...) __attribute__ ((format (printf, 4, 5)));
void printf_file(int kind, const char* filename, const char* prefix_format, ...) __attribute__ ((format (printf, 4, 5)));
void vprintf(int kind, const char* format, va_list va);
void vprintf_multiline(int kind, const char* str, const char* prefix_format, va_list va);
void vprintf_file(int kind, const char* filename, const char* prefix_format, va_list va);
protected:
virtual const char* v_format_kind(int kind) const = 0;
virtual bool v_message_wanted(int kind) const = 0;
};
// automatically ++/--Messages on scope entry / exit. See lib/messages.C for commentary
class ScopeMessages
{
Messages& messages;
int kind;
public:
ScopeMessages(Messages& messages_, int kind_) : messages(messages_), kind(kind_)
{ ++messages; }
~ScopeMessages() { --messages; }
ScopeMessages& operator++() { ++messages; return *this; }
ScopeMessages& operator--() { --messages; return *this; }
void printf(const char* format, ...) __attribute__ ((format (printf, 2, 3)));
void printf_multiline(const char* str, const char* prefix_format, ...) __attribute__ ((format (printf, 3, 4)));
void printf_file(const char* filename, const char* prefix_format, ...) __attribute__ ((format (printf, 3, 4)));
};
#define SECONDS_PER_DAY 86400
static inline double drand() {
@ -157,4 +105,6 @@ char* windows_format_error_string( unsigned long dwError, char* pszBuf, int iSiz
#endif
extern void update_average(double, double, double, double&, double&);
#endif

View File

@ -38,6 +38,7 @@ libsched_a_SOURCES = \
../db/db_base.C \
../lib/util.C \
../lib/crypt.C \
../lib/filesys.C \
../lib/parse.C \
../lib/base64.C \
../lib/shmem.C \

View File

@ -207,6 +207,7 @@ libsched_a_SOURCES = \
../db/db_base.C \
../lib/util.C \
../lib/crypt.C \
../lib/filesys.C \
../lib/parse.C \
../lib/base64.C \
../lib/shmem.C \
@ -292,10 +293,10 @@ libsched_a_LIBADD =
am_libsched_a_OBJECTS = sched_shmem.$(OBJEXT) sched_util.$(OBJEXT) \
sched_config.$(OBJEXT) sched_messages.$(OBJEXT) \
boinc_db.$(OBJEXT) db_base.$(OBJEXT) util.$(OBJEXT) \
crypt.$(OBJEXT) parse.$(OBJEXT) base64.$(OBJEXT) \
shmem.$(OBJEXT) md5.$(OBJEXT) md5_file.$(OBJEXT) \
messages.$(OBJEXT) process_result_template.$(OBJEXT) \
backend_lib.$(OBJEXT)
crypt.$(OBJEXT) filesys.$(OBJEXT) parse.$(OBJEXT) \
base64.$(OBJEXT) shmem.$(OBJEXT) md5.$(OBJEXT) \
md5_file.$(OBJEXT) messages.$(OBJEXT) \
process_result_template.$(OBJEXT) backend_lib.$(OBJEXT)
libsched_a_OBJECTS = $(am_libsched_a_OBJECTS)
EXTRA_PROGRAMS = fcgi$(EXEEXT)
noinst_PROGRAMS = assimilator$(EXEEXT) cgi$(EXEEXT) feeder$(EXEEXT) \
@ -385,6 +386,7 @@ am__depfiles_maybe = depfiles
@AMDEP_TRUE@ ./$(DEPDIR)/fcgi-server_types.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/feeder.Po ./$(DEPDIR)/file_deleter.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/file_upload_handler.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/filesys.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/handle_request.Po ./$(DEPDIR)/main.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/make_work.Po ./$(DEPDIR)/md5.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/md5_file.Po ./$(DEPDIR)/messages.Po \
@ -444,6 +446,7 @@ boinc_db.$(OBJEXT): ../db/boinc_db.C
db_base.$(OBJEXT): ../db/db_base.C
util.$(OBJEXT): ../lib/util.C
crypt.$(OBJEXT): ../lib/crypt.C
filesys.$(OBJEXT): ../lib/filesys.C
parse.$(OBJEXT): ../lib/parse.C
base64.$(OBJEXT): ../lib/base64.C
shmem.$(OBJEXT): ../lib/shmem.C
@ -549,6 +552,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/feeder.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file_deleter.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file_upload_handler.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filesys.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/handle_request.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/make_work.Po@am__quote@
@ -689,6 +693,28 @@ crypt.obj: ../lib/crypt.C
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o crypt.obj `if test -f '../lib/crypt.C'; then $(CYGPATH_W) '../lib/crypt.C'; else $(CYGPATH_W) '$(srcdir)/../lib/crypt.C'`
filesys.o: ../lib/filesys.C
@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT filesys.o -MD -MP -MF "$(DEPDIR)/filesys.Tpo" \
@am__fastdepCXX_TRUE@ -c -o filesys.o `test -f '../lib/filesys.C' || echo '$(srcdir)/'`../lib/filesys.C; \
@am__fastdepCXX_TRUE@ then mv "$(DEPDIR)/filesys.Tpo" "$(DEPDIR)/filesys.Po"; \
@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/filesys.Tpo"; exit 1; \
@am__fastdepCXX_TRUE@ fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../lib/filesys.C' object='filesys.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/filesys.Po' tmpdepfile='$(DEPDIR)/filesys.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o filesys.o `test -f '../lib/filesys.C' || echo '$(srcdir)/'`../lib/filesys.C
filesys.obj: ../lib/filesys.C
@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT filesys.obj -MD -MP -MF "$(DEPDIR)/filesys.Tpo" \
@am__fastdepCXX_TRUE@ -c -o filesys.obj `if test -f '../lib/filesys.C'; then $(CYGPATH_W) '../lib/filesys.C'; else $(CYGPATH_W) '$(srcdir)/../lib/filesys.C'`; \
@am__fastdepCXX_TRUE@ then mv "$(DEPDIR)/filesys.Tpo" "$(DEPDIR)/filesys.Po"; \
@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/filesys.Tpo"; exit 1; \
@am__fastdepCXX_TRUE@ fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../lib/filesys.C' object='filesys.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/filesys.Po' tmpdepfile='$(DEPDIR)/filesys.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o filesys.obj `if test -f '../lib/filesys.C'; then $(CYGPATH_W) '../lib/filesys.C'; else $(CYGPATH_W) '$(srcdir)/../lib/filesys.C'`
parse.o: ../lib/parse.C
@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT parse.o -MD -MP -MF "$(DEPDIR)/parse.Tpo" \
@am__fastdepCXX_TRUE@ -c -o parse.o `test -f '../lib/parse.C' || echo '$(srcdir)/'`../lib/parse.C; \

View File

@ -34,7 +34,7 @@ using namespace std;
#include "sched_send.h"
const int MIN_SECONDS_TO_SEND = 0;
const int MAX_SECONDS_TO_SEND = (28*SECONDS_PER_DAY);
const int MAX_SECONDS_TO_SEND = (28*SECONDS_IN_DAY);
const double MIN_POSSIBLE_RAM = 64000000;

View File

@ -23,6 +23,7 @@ using namespace std;
#include <csignal>
#include <cstdarg>
#include <unistd.h>
#include <math.h>
#include "parse.h"
#include "util.h"
@ -77,30 +78,3 @@ bool is_stopfile_present() {
}
return false;
}
// decay an exponential average of credit per day,
// and possibly add an increment for new credit
//
void update_average(
double credit_assigned_time, // when work was started for new credit
// (or zero if no new credit)
double credit, // amount of new credit
double& avg, // average credit per day (in and out)
double& avg_time // when average was last computed
) {
double now = dtime();
if (avg_time) {
double diff = now - avg_time;
double diff_days = diff/SECONDS_IN_DAY;
double weight = exp(-diff*LOG2/AVG_HALF_LIFE);
avg *= weight;
avg += (1-weight)*(credit/diff_days);
} else {
double dd = (now - credit_assigned_time)/SECONDS_IN_DAY;
avg = credit/dd;
}
avg_time = now;
}

View File

@ -20,31 +20,20 @@
#ifndef SCHED_UTIL_H
#define SCHED_UTIL_H
#include <math.h>
#include "util.h"
#include "messages.h"
// "average credit" uses an exponential decay so that recent
// activity is weighted more heavily.
// AVG_HALF_LIFE is the "half-life" period:
// CREDIT_HALF_LIFE is the "half-life" period:
// the average decreases by 1/2 if idle for this period.
//
// After a period of T, average credit is multiplied by
// exp(-T*log(2)/AHL)
//
// When new credit is granted, the average credit is incremented
// by the new credit's average rate,
// i.e. the amount divided by the time since it was started
#define LOG2 M_LN2
// log(2)
#define SECONDS_IN_DAY (3600*24)
#define AVG_HALF_LIFE (SECONDS_IN_DAY*7)
#define CREDIT_HALF_LIFE (SECONDS_IN_DAY*7)
extern void write_pid_file(const char* filename);
extern void set_debug_level(int);
extern void check_stop_trigger();
extern bool is_stopfile_present();
extern void update_average(double, double, double&, double&);
extern void install_stop_signal_handler();
extern bool caught_stop_signal;

View File

@ -50,7 +50,7 @@ int update_users() {
while (!user.enumerate()) {
if (user.expavg_time > update_time_cutoff) continue;
update_average(0, 0, user.expavg_credit, user.expavg_time);
update_average(0, 0, CREDIT_HALF_LIFE, user.expavg_credit, user.expavg_time);
retval = user.update();
if (retval) {
log_messages.printf(SchedMessages::CRITICAL, "Can't update user %d\n", user.id);
@ -67,7 +67,7 @@ int update_hosts() {
while (!host.enumerate()) {
if (host.expavg_time > update_time_cutoff) continue;
update_average(0, 0, host.expavg_credit, host.expavg_time);
update_average(0, 0, CREDIT_HALF_LIFE, host.expavg_credit, host.expavg_time);
retval = host.update();
if (retval) {
log_messages.printf(SchedMessages::CRITICAL, "Can't update host %d\n", host.id);
@ -115,7 +115,7 @@ int update_teams() {
continue;
}
if (team.expavg_time < update_time_cutoff) {
update_average(0, 0, team.expavg_credit, team.expavg_time);
update_average(0, 0, CREDIT_HALF_LIFE, team.expavg_credit, team.expavg_time);
}
retval = team.update();
if (retval) {

View File

@ -74,12 +74,12 @@ int grant_credit(DB_RESULT& result, double credit) {
if (retval) return retval;
user.total_credit += credit;
update_average(result.sent_time, credit, user.expavg_credit, user.expavg_time);
update_average(result.sent_time, credit, CREDIT_HALF_LIFE, user.expavg_credit, user.expavg_time);
retval = user.update();
if (retval) return retval;
host.total_credit += credit;
update_average(result.sent_time, credit, host.expavg_credit, host.expavg_time);
update_average(result.sent_time, credit, CREDIT_HALF_LIFE, host.expavg_credit, host.expavg_time);
retval = host.update();
if (retval) return retval;
@ -87,7 +87,7 @@ int grant_credit(DB_RESULT& result, double credit) {
retval = team.lookup_id(user.teamid);
if (retval) return retval;
team.total_credit += credit;
update_average(result.sent_time, credit, team.expavg_credit, team.expavg_time);
update_average(result.sent_time, credit, CREDIT_HALF_LIFE, team.expavg_credit, team.expavg_time);
retval = team.update();
if (retval) return retval;
}

View File

@ -17,6 +17,7 @@
// Contributor(s):
//
#include "util.h"
#include "sched_util.h"
#include "validate_util.h"