From 247e9702f0c78ce17e6e79e2ae639ac6b2c4830c Mon Sep 17 00:00:00 2001 From: Daniel Hsu Date: Tue, 15 Jun 2004 00:46:59 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=3573 --- checkin_notes | 18 ++++++++++++++++++ client/Makefile.in | 29 ++++++++++++++++++++++++++++- client/client_state.C | 1 + client/client_state.h | 3 ++- client/cs_cmdline.C | 2 ++ client/cs_scheduler.C | 26 +++++++++++++++----------- client/hostinfo_unix.C | 33 ++++++++++++++++++++++++++++++++- config.h.in | 3 +++ configure | 3 ++- configure.ac | 2 +- 10 files changed, 104 insertions(+), 16 deletions(-) diff --git a/checkin_notes b/checkin_notes index c25226fbf5..18b68d8f94 100755 --- a/checkin_notes +++ b/checkin_notes @@ -13530,3 +13530,21 @@ Rom 14 June 2004 client/ client_state.C + +Daniel 14 June 2004 + - client: Returning results due to "-return_results_immediately" + no longer tries to fetch work unless it's needed. + - client: Added "-check_all_logins" command-line option to force + idle checking to look at all users' terminals. + + config.h.in + configure + configure.ac + client/ + Makefile.in + client_state.C + client_state.h + cs_cmdline.C + cs_scheduler.C + hostinfo_unix.C + diff --git a/client/Makefile.in b/client/Makefile.in index 14c01797b0..38a6d27a91 100644 --- a/client/Makefile.in +++ b/client/Makefile.in @@ -213,6 +213,7 @@ boinc_client_SOURCES = \ time_stats.C \ whetstone.C \ ../lib/app_ipc.C \ + ../lib/base64.C \ ../lib/crypt.C \ ../lib/diagnostics.C \ ../lib/exception.C \ @@ -281,7 +282,8 @@ am_boinc_client_OBJECTS = boinc_client-app.$(OBJEXT) \ boinc_client-ss_logic.$(OBJEXT) \ boinc_client-time_stats.$(OBJEXT) \ boinc_client-whetstone.$(OBJEXT) boinc_client-app_ipc.$(OBJEXT) \ - boinc_client-crypt.$(OBJEXT) boinc_client-diagnostics.$(OBJEXT) \ + boinc_client-base64.$(OBJEXT) boinc_client-crypt.$(OBJEXT) \ + boinc_client-diagnostics.$(OBJEXT) \ boinc_client-exception.$(OBJEXT) boinc_client-filesys.$(OBJEXT) \ boinc_client-language.$(OBJEXT) boinc_client-md5_file.$(OBJEXT) \ boinc_client-md5.$(OBJEXT) boinc_client-mfile.$(OBJEXT) \ @@ -301,6 +303,7 @@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/boinc_client-app.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/boinc_client-app_ipc.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/boinc_client-base64.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/boinc_client-check_state.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/boinc_client-client_msgs.Po \ @AMDEP_TRUE@ ./$(DEPDIR)/boinc_client-client_state.Po \ @@ -430,6 +433,7 @@ boinc_client-ss_logic.$(OBJEXT): ss_logic.C boinc_client-time_stats.$(OBJEXT): time_stats.C boinc_client-whetstone.$(OBJEXT): whetstone.C boinc_client-app_ipc.$(OBJEXT): ../lib/app_ipc.C +boinc_client-base64.$(OBJEXT): ../lib/base64.C boinc_client-crypt.$(OBJEXT): ../lib/crypt.C boinc_client-diagnostics.$(OBJEXT): ../lib/diagnostics.C boinc_client-exception.$(OBJEXT): ../lib/exception.C @@ -457,6 +461,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/boinc_client-app.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/boinc_client-app_ipc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/boinc_client-base64.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/boinc_client-check_state.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/boinc_client-client_msgs.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/boinc_client-client_state.Po@am__quote@ @@ -1301,6 +1306,28 @@ boinc_client-app_ipc.obj: ../lib/app_ipc.C @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boinc_client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o boinc_client-app_ipc.obj `if test -f '../lib/app_ipc.C'; then $(CYGPATH_W) '../lib/app_ipc.C'; else $(CYGPATH_W) '$(srcdir)/../lib/app_ipc.C'` +boinc_client-base64.o: ../lib/base64.C +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boinc_client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT boinc_client-base64.o -MD -MP -MF "$(DEPDIR)/boinc_client-base64.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o boinc_client-base64.o `test -f '../lib/base64.C' || echo '$(srcdir)/'`../lib/base64.C; \ +@am__fastdepCXX_TRUE@ then mv "$(DEPDIR)/boinc_client-base64.Tpo" "$(DEPDIR)/boinc_client-base64.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/boinc_client-base64.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../lib/base64.C' object='boinc_client-base64.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/boinc_client-base64.Po' tmpdepfile='$(DEPDIR)/boinc_client-base64.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boinc_client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o boinc_client-base64.o `test -f '../lib/base64.C' || echo '$(srcdir)/'`../lib/base64.C + +boinc_client-base64.obj: ../lib/base64.C +@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boinc_client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT boinc_client-base64.obj -MD -MP -MF "$(DEPDIR)/boinc_client-base64.Tpo" \ +@am__fastdepCXX_TRUE@ -c -o boinc_client-base64.obj `if test -f '../lib/base64.C'; then $(CYGPATH_W) '../lib/base64.C'; else $(CYGPATH_W) '$(srcdir)/../lib/base64.C'`; \ +@am__fastdepCXX_TRUE@ then mv "$(DEPDIR)/boinc_client-base64.Tpo" "$(DEPDIR)/boinc_client-base64.Po"; \ +@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/boinc_client-base64.Tpo"; exit 1; \ +@am__fastdepCXX_TRUE@ fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../lib/base64.C' object='boinc_client-base64.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/boinc_client-base64.Po' tmpdepfile='$(DEPDIR)/boinc_client-base64.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boinc_client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o boinc_client-base64.obj `if test -f '../lib/base64.C'; then $(CYGPATH_W) '../lib/base64.C'; else $(CYGPATH_W) '$(srcdir)/../lib/base64.C'` + boinc_client-crypt.o: ../lib/crypt.C @am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boinc_client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT boinc_client-crypt.o -MD -MP -MF "$(DEPDIR)/boinc_client-crypt.Tpo" \ @am__fastdepCXX_TRUE@ -c -o boinc_client-crypt.o `test -f '../lib/crypt.C' || echo '$(srcdir)/'`../lib/crypt.C; \ diff --git a/client/client_state.C b/client/client_state.C index 0f701756e5..c6f78cafca 100644 --- a/client/client_state.C +++ b/client/client_state.C @@ -68,6 +68,7 @@ CLIENT_STATE::CLIENT_STATE() { scheduler_op = new SCHEDULER_OP(http_ops); client_state_dirty = false; exit_when_idle = false; + check_all_logins = false; return_results_immediately = false; allow_remote_gui_rpc = false; run_cpu_benchmarks = false; diff --git a/client/client_state.h b/client/client_state.h index 649d453a08..18770e5758 100644 --- a/client/client_state.h +++ b/client/client_state.h @@ -93,6 +93,7 @@ public: // same, just for network bool started_by_screensaver; bool exit_when_idle; + bool check_all_logins; bool return_results_immediately; bool allow_remote_gui_rpc; bool show_projects; @@ -247,7 +248,7 @@ private: bool contacted_sched_server; void compute_resource_debts(); - PROJECT* find_project_with_overdue_results(); + PROJECT* find_project_with_overdue_results(bool& overdue); void current_work_buf_days(double& work_buf, int& nactive_results); PROJECT* next_project_sched_rpc_pending(); bool some_project_rpc_ok(); diff --git a/client/cs_cmdline.C b/client/cs_cmdline.C index 4ed47dab0c..1bed5c3c8c 100644 --- a/client/cs_cmdline.C +++ b/client/cs_cmdline.C @@ -64,6 +64,8 @@ void CLIENT_STATE::parse_cmdline(int argc, char** argv) { for (i=1; iready_to_report && - (return_results_immediately || - r->report_deadline <= (now + fReportDeadlineToReport))) + r->report_deadline <= (now + fReportDeadlineToReport)) { + overdue = true; + return r->project; + } else if (r->ready_to_report && return_results_immediately) { + overdue = false; return r->project; } } @@ -429,13 +432,13 @@ bool CLIENT_STATE::scheduler_rpc_poll() { if (exit_when_idle && contacted_sched_server) { should_get_work = false; } else { - // TODO: the following is a kludge to prevent - // repeated work requests, but it defeats the - // work_buf_min concept - // + // TODO: the following is a kludge to prevent + // repeated work requests, but it defeats the + // work_buf_min concept + // //below_work_buf_min = (current_work_buf_days() <= global_prefs.work_buf_min_days); - current_work_buf_days(work_buf_days, nactive_results); - below_work_buf_min = nactive_results < host_info.p_ncpus; + current_work_buf_days(work_buf_days, nactive_results); + below_work_buf_min = nactive_results < host_info.p_ncpus; should_get_work = below_work_buf_min && some_project_rpc_ok(); } if (should_get_work) { @@ -450,10 +453,11 @@ bool CLIENT_STATE::scheduler_rpc_poll() { scheduler_op->init_return_results(p, 0); action = true; } else { - p = find_project_with_overdue_results(); + bool overdue = false; + p = find_project_with_overdue_results(overdue); if (p) { compute_resource_debts(); - if (p->debt_order == 0) { + if (overdue && p->debt_order == 0) { work_secs = work_needed_secs(); } else { work_secs = 0; diff --git a/client/hostinfo_unix.C b/client/hostinfo_unix.C index 1859aa1683..33fe653717 100644 --- a/client/hostinfo_unix.C +++ b/client/hostinfo_unix.C @@ -55,6 +55,9 @@ #if HAVE_UNISTD_H #include #endif +#if HAVE_UTMP_H +#include +#endif #if HAVE_NETINET_IN_H #include #endif @@ -420,11 +423,38 @@ inline bool all_tty_idle(time_t t, char *device, char first_char, int num_tty) { return true; } +inline bool user_idle(time_t t, struct utmp* u) { + char tty[5 + sizeof u->ut_line + 1] = "/dev/"; + unsigned int i; + + for (i=0; i < sizeof(u->ut_line); i++) /* clean up tty if garbled */ + if (isalnum((int) u->ut_line[i]) || (u->ut_line[i]=='/')) + tty[i+5] = u->ut_line[i]; + else + tty[i+5] = '\0'; + return device_idle(t, tty); +} + +inline bool all_logins_idle(time_t t) { + struct utmp* u; + setutent(); + + while ((u = getutent()) != NULL) { + if (!user_idle(t, u)) { + return false; + } + } + return true; +} + void CLIENT_STATE::check_idle() { +#ifdef HAVE__DEV_TTY1 char device_tty[] = "/dev/tty1"; +#endif time_t idle_time = time(NULL) - (long) (60 * global_prefs.idle_time_to_run); user_idle = true + && (!check_all_logins || all_logins_idle(idle_time)) #ifdef HAVE__DEV_MOUSE && device_idle(idle_time, "/dev/mouse") // solaris, linux #endif @@ -432,7 +462,8 @@ void CLIENT_STATE::check_idle() { && device_idle(idle_time, "/dev/kbd") // solaris #endif #ifdef HAVE__DEV_TTY1 - && all_tty_idle(idle_time, device_tty, '1', 7) // linux + && (check_all_logins || all_tty_idle(idle_time, device_tty, '1', 7)) #endif ; } + diff --git a/config.h.in b/config.h.in index 3c32558ada..09bdc96892 100644 --- a/config.h.in +++ b/config.h.in @@ -265,6 +265,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H +/* Define to 1 if you have the header file. */ +#undef HAVE_UTMP_H + /* Define to 1 if you have the `vprintf' function. */ #undef HAVE_VPRINTF diff --git a/configure b/configure index 77f12d7d02..c739628ec9 100755 --- a/configure +++ b/configure @@ -6047,7 +6047,8 @@ done -for ac_header in arpa/inet.h dirent.h fcntl.h malloc.h netdb.h netinet/in.h netinet/tcp.h signal.h strings.h sys/file.h sys/ipc.h sys/mount.h sys/resource.h sys/select.h sys/shm.h sys/socket.h sys/statvfs.h sys/statfs.h sys/swap.h sys/sysctl.h sys/systeminfo.h sys/time.h sys/types.h sys/utsname.h sys/vmmeter.h sys/wait.h unistd.h errno.h + +for ac_header in arpa/inet.h dirent.h fcntl.h malloc.h netdb.h netinet/in.h netinet/tcp.h signal.h strings.h sys/file.h sys/ipc.h sys/mount.h sys/resource.h sys/select.h sys/shm.h sys/socket.h sys/statvfs.h sys/statfs.h sys/swap.h sys/sysctl.h sys/systeminfo.h sys/time.h sys/types.h sys/utsname.h sys/vmmeter.h sys/wait.h unistd.h utmp.h errno.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if eval "test \"\${$as_ac_Header+set}\" = set"; then diff --git a/configure.ac b/configure.ac index c932e4af24..07965b8929 100644 --- a/configure.ac +++ b/configure.ac @@ -86,7 +86,7 @@ AC_HEADER_STDC AC_HEADER_SYS_WAIT AC_HEADER_TIME AC_TYPE_SIGNAL -AC_CHECK_HEADERS(arpa/inet.h dirent.h fcntl.h malloc.h netdb.h netinet/in.h netinet/tcp.h signal.h strings.h sys/file.h sys/ipc.h sys/mount.h sys/resource.h sys/select.h sys/shm.h sys/socket.h sys/statvfs.h sys/statfs.h sys/swap.h sys/sysctl.h sys/systeminfo.h sys/time.h sys/types.h sys/utsname.h sys/vmmeter.h sys/wait.h unistd.h errno.h) +AC_CHECK_HEADERS(arpa/inet.h dirent.h fcntl.h malloc.h netdb.h netinet/in.h netinet/tcp.h signal.h strings.h sys/file.h sys/ipc.h sys/mount.h sys/resource.h sys/select.h sys/shm.h sys/socket.h sys/statvfs.h sys/statfs.h sys/swap.h sys/sysctl.h sys/systeminfo.h sys/time.h sys/types.h sys/utsname.h sys/vmmeter.h sys/wait.h unistd.h utmp.h errno.h) SAH_GRX_INCLUDES AC_LANG_PUSH(C++) SAH_HEADER_STDCXX