Ticket #463: boinc-idlefix.patch
File boinc-idlefix.patch, 4.1 KB (added by , 16 years ago) |
---|
-
client/client_state.C
old new 34 34 #endif 35 35 #endif 36 36 37 #ifdef linux 38 #include <sys/fcntl.h> 39 #endif 40 37 41 #include "parse.h" 38 42 #include "str_util.h" 39 43 #include "util.h" … … 125 129 launched_by_manager = false; 126 130 initialized = false; 127 131 last_wakeup_time = dtime(); 132 #ifdef linux 133 mouse_moved = true; 134 mouse_event_t = time(NULL); 135 mouse_fd = open("/dev/input/mouse0", O_RDONLY); 136 #endif 137 } 138 139 CLIENT_STATE::~CLIENT_STATE() 140 { 141 #ifdef linux 142 if(mouse_fd != -1) 143 close(mouse_fd); 144 #endif 128 145 } 129 146 130 147 void CLIENT_STATE::show_host_info() { … … 414 431 http_ops->get_fdset(curl_fds); 415 432 all_fds = curl_fds; 416 433 gui_rpcs.get_fdset(gui_rpc_fds, all_fds); 434 #ifdef linux 435 FD_SET(mouse_fd, &all_fds.read_fds); 436 if (mouse_fd > all_fds.max_fd) all_fds.max_fd = mouse_fd; 437 #endif 417 438 double_to_timeval(x, tv); 418 439 n = select( 419 440 all_fds.max_fd+1, … … 429 451 430 452 http_ops->got_select(all_fds, x); 431 453 gui_rpcs.got_select(all_fds); 454 #ifdef linux 455 if (mouse_fd != -1) { 456 if (FD_ISSET(mouse_fd, &all_fds.read_fds)) { 457 char ps2_packet[3]; //assume ps/2 mouse protocol 3 byte packet 458 if(read(mouse_fd, ps2_packet, 3) == 3) { 459 mouse_moved = true; 460 mouse_event_t = time(NULL); 461 } 462 } 463 } 464 #endif 432 465 433 466 if (n==0) break; 434 467 … … 496 529 #ifdef __APPLE__ 497 530 , &idletime 498 531 #endif 532 #ifdef linux 533 , &mouse_moved 534 , mouse_event_t 535 #endif 499 536 ); 500 537 501 538 if (user_active != old_user_active) { -
client/client_state.h
old new 213 213 // --------------- client_state.C: 214 214 public: 215 215 CLIENT_STATE(); 216 ~CLIENT_STATE(); 216 217 void show_host_info(); 217 218 int init(); 218 219 bool poll_slow_events(); … … 243 244 bool garbage_collect_always(); 244 245 bool update_results(); 245 246 int nresults_for_project(PROJECT*); 247 #ifdef linux 248 int mouse_fd; 249 bool mouse_moved; 250 time_t mouse_event_t; 251 #endif 246 252 247 253 // --------------- cpu_sched.C: 248 254 private: -
client/hostinfo_unix.C
old new 946 946 return (idleTime > (60 * idle_time_to_run)); 947 947 } 948 948 949 #elif linux 950 951 bool HOST_INFO::users_idle(bool check_all_logins, double idle_time_to_run, bool* mouse_moved, time_t mouse_event_t) { 952 time_t cur_time = time(NULL); 953 time_t idle_time = cur_time - (long) (60 * idle_time_to_run); 954 if (mouse_event_t != 0) { 955 if (mouse_moved && mouse_event_t < idle_time) 956 *mouse_moved = false; 957 } 958 959 bool idle_result = true; 960 #ifdef HAVE_UTMP_H 961 idle_result = idle_result && all_logins_idle(idle_time); 962 #endif 963 idle_result = idle_result && (mouse_moved ? !*mouse_moved : true); 964 return idle_result; 965 } 966 949 967 #else // ! __APPLE__ 950 968 951 969 bool HOST_INFO::users_idle(bool check_all_logins, double idle_time_to_run) { -
lib/hostinfo.h
old new 72 72 bool host_is_running_on_batteries(); 73 73 #ifdef __APPLE__ 74 74 bool users_idle(bool check_all_logins, double idle_time_to_run, double *actual_idle_time=NULL); 75 #elif linux 76 bool users_idle(bool check_all_logins, double idle_time_to_run, bool* mouse_moved = NULL, time_t mouse_event_t = 0); 75 77 #else 76 78 bool users_idle(bool check_all_logins, double idle_time_to_run); 77 79 #endif -
checkin_notes
old new 7985 7985 mac_installer/ 7986 7986 release_boinc.sh 7987 7987 release_GridRepublic.sh 7988 7989 Orson Teodoro 04 Jan 2008 7990 - Linux: Input event mouse idle detection and segfault fix 7991 client/ 7992 client_state.C 7993 client_state.h 7994 hostinfo_unix.C 7995 main.C 7996 lib/ 7997 hostinfo.h