diff --git a/checkin_notes b/checkin_notes index 3e3b86cc0b..880d24b326 100755 --- a/checkin_notes +++ b/checkin_notes @@ -9656,3 +9656,50 @@ Charlie 1 Sep 2006 (HEAD and boinc_core_release_5_6_1 tag) mac_build/ boinc.xcodeproj/ project.pbxproj + +David 1 Sep 2006 + - Aargh! A recent Manager bug (run-mode selection acting weird) + was because the core client and the Manager had different + #defines for always/auto/never: + one used 0/1/2 and the other used 1/2/3. + + There were a number of accidents of this sort waiting to happen, + i.e. the same #defines cut-and-pasted into 2 different files. + + To keep this from ever happening again, + I added a new file (lib/common_defs.h) that includes + all #defines and enums shared among different BOINC + components (client/Manager, screensaver/client, client/server etc.). + This replaces result_state.h. + + In principle error_numbers.h should be merged into this file + but this would required too much editing so I didn't do it. + + - Linux compile fix + + client/ + app.h + client_msgs.h + client_state.C,h + client_types.h + cs_cmdline.C + cs_prefs.C + gui_rpc_server.h + gui_rpc_server_ops.C + http_curl.h + log_flags.C + main.C + ss_logic.h + clientgui/ + MainDocument.h + lib/ + app_ipc.h + boinc_cmd.C + error_numbers.h + gui_rpc_client.C,h + gui_rpc_client_ops.C + procinfo_unix.C + results_state.h (removed) + util.C + sched/ + server_types.h diff --git a/client/app.h b/client/app.h index e64e271de7..8df39e2579 100644 --- a/client/app.h +++ b/client/app.h @@ -58,12 +58,6 @@ typedef int PROCESS_ID; #define PROCESS_IN_LIMBO 8 // process exited zero, but no finish file; leave the task there. -// values of ACTIVE_TASK::scheduler_state and ACTIVE_TASK::next_scheduler_state -#define CPU_SCHED_UNINITIALIZED 0 -#define CPU_SCHED_PREEMPTED 1 -#define CPU_SCHED_SCHEDULED 2 - - // Represents a task in progress. // // "CPU time" refers to the sum over all episodes. diff --git a/client/client_msgs.h b/client/client_msgs.h index f88e7331d1..8e5bfcb8d4 100644 --- a/client/client_msgs.h +++ b/client/client_msgs.h @@ -32,15 +32,6 @@ class PROJECT; -// Show a message, preceded by timestamp and project name -// priorities (this MUST match those in lib/gui_rpc_client.h) - -#define MSG_INFO 1 - // write to stdout - // GUI: write to msg window -#define MSG_ERROR 2 - // write to stdout - // GUI: write to msg window in bold or red // the following stores a message in memory, where it can be retrieved via RPC // @@ -63,6 +54,8 @@ extern void show_message(class PROJECT *p, char* message, int priority); #define __attribute__(x) /*nothing*/ #endif +// Show a message, preceded by timestamp and project name +// extern void msg_printf(PROJECT *p, int priority, const char *fmt, ...) __attribute__ ((format (printf, 3, 4))); #endif diff --git a/client/client_state.C b/client/client_state.C index a44874986d..11ac7c2560 100644 --- a/client/client_state.C +++ b/client/client_state.C @@ -82,8 +82,8 @@ CLIENT_STATE::CLIENT_STATE() { strcpy(main_host_venue, ""); strcpy(attach_project_url, ""); strcpy(attach_project_auth, ""); - user_run_request = USER_RUN_REQUEST_AUTO; - user_network_request = USER_RUN_REQUEST_AUTO; + user_run_request = RUN_MODE_AUTO; + user_network_request = RUN_MODE_AUTO; started_by_screensaver = false; requested_exit = false; master_fetch_period = MASTER_FETCH_PERIOD; diff --git a/client/client_state.h b/client/client_state.h index f71ca6491c..0e4a8c9f0a 100644 --- a/client/client_state.h +++ b/client/client_state.h @@ -45,10 +45,6 @@ using std::vector; #include "time_stats.h" #include "http_curl.h" -#define USER_RUN_REQUEST_ALWAYS 1 -#define USER_RUN_REQUEST_AUTO 2 -#define USER_RUN_REQUEST_NEVER 3 - #define WORK_FETCH_DONT_NEED 0 // project: suspended, deferred, or no new work (can't ask for more work) // overall: not work_fetch_ok (from CPU policy) @@ -62,16 +58,6 @@ using std::vector; // project: no downloading or runnable results // overall: at least one idle CPU -enum SUSPEND_REASON { - SUSPEND_REASON_BATTERIES = 1, - SUSPEND_REASON_USER_ACTIVE = 2, - SUSPEND_REASON_USER_REQ = 4, - SUSPEND_REASON_TIME_OF_DAY = 8, - SUSPEND_REASON_BENCHMARKS = 16, - SUSPEND_REASON_DISK_SIZE = 32, - SUSPEND_REASON_CPU_USAGE_LIMIT = 64, -}; - // CLIENT_STATE encapsulates the global variables of the core client. // If you add anything here, initialize it in the constructor // diff --git a/client/client_types.h b/client/client_types.h index af322debf0..32ed447e6b 100644 --- a/client/client_types.h +++ b/client/client_types.h @@ -35,7 +35,6 @@ #include "md5_file.h" #include "hostinfo.h" #include "miofile.h" -#include "result_state.h" #define P_LOW 1 #define P_MEDIUM 3 diff --git a/client/cs_cmdline.C b/client/cs_cmdline.C index 3be725f11a..1c5067fe46 100644 --- a/client/cs_cmdline.C +++ b/client/cs_cmdline.C @@ -90,7 +90,7 @@ void CLIENT_STATE::parse_cmdline(int argc, char** argv) { if (i == argc-1) show_options = true; else file_xfer_giveup_period = atoi(argv[++i]); } else if (ARG(suspend)) { - user_run_request = USER_RUN_REQUEST_NEVER; + user_run_request = RUN_MODE_NEVER; } else if (ARG(saver)) { started_by_screensaver = true; } else if (!strncmp(argv[i], "-psn_", strlen("-psn_"))) { diff --git a/client/cs_prefs.C b/client/cs_prefs.C index 7e23299ab5..342fff4598 100644 --- a/client/cs_prefs.C +++ b/client/cs_prefs.C @@ -138,8 +138,8 @@ void CLIENT_STATE::check_suspend_activities(int& reason) { } switch(user_run_request) { - case USER_RUN_REQUEST_ALWAYS: break; - case USER_RUN_REQUEST_NEVER: + case RUN_MODE_ALWAYS: break; + case RUN_MODE_NEVER: reason = SUSPEND_REASON_USER_REQ; return; default: @@ -237,9 +237,9 @@ int CLIENT_STATE::resume_tasks(int reason) { void CLIENT_STATE::check_suspend_network(int& reason) { reason = 0; - if (user_network_request == USER_RUN_REQUEST_ALWAYS) return; + if (user_network_request == RUN_MODE_ALWAYS) return; - if (user_network_request == USER_RUN_REQUEST_NEVER) { + if (user_network_request == RUN_MODE_NEVER) { reason |= SUSPEND_REASON_USER_REQ; return; } diff --git a/client/gui_rpc_server.h b/client/gui_rpc_server.h index d3ba2465df..ec907cdb2a 100644 --- a/client/gui_rpc_server.h +++ b/client/gui_rpc_server.h @@ -59,6 +59,3 @@ public: void close(); bool got_recent_rpc(double interval); }; - - -#define GUI_RPC_PORT 31416 diff --git a/client/gui_rpc_server_ops.C b/client/gui_rpc_server_ops.C index 062a80d37a..f2e9af85e5 100644 --- a/client/gui_rpc_server_ops.C +++ b/client/gui_rpc_server_ops.C @@ -261,11 +261,11 @@ static void handle_project_op(char* buf, MIOFILE& fout, const char* op) { static void handle_set_run_mode(char* buf, MIOFILE& fout) { if (match_tag(buf, "Missing mode\n"); return; @@ -278,13 +278,13 @@ static void handle_set_run_mode(char* buf, MIOFILE& fout) { static void handle_get_run_mode(char* , MIOFILE& fout) { fout.printf("\n"); switch (gstate.user_run_request) { - case USER_RUN_REQUEST_ALWAYS: + case RUN_MODE_ALWAYS: fout.printf("\n"); break; - case USER_RUN_REQUEST_NEVER: + case RUN_MODE_NEVER: fout.printf("\n"); break; - case USER_RUN_REQUEST_AUTO: + case RUN_MODE_AUTO: fout.printf("\n"); break; default: @@ -295,11 +295,11 @@ static void handle_get_run_mode(char* , MIOFILE& fout) { static void handle_set_network_mode(char* buf, MIOFILE& fout) { if (match_tag(buf, "Missing mode\n"); return; @@ -312,13 +312,13 @@ static void handle_set_network_mode(char* buf, MIOFILE& fout) { static void handle_get_network_mode(char* , MIOFILE& fout) { fout.printf("\n"); switch (gstate.user_network_request) { - case USER_RUN_REQUEST_ALWAYS: + case RUN_MODE_ALWAYS: fout.printf("\n"); break; - case USER_RUN_REQUEST_NEVER: + case RUN_MODE_NEVER: fout.printf("\n"); break; - case USER_RUN_REQUEST_AUTO: + case RUN_MODE_AUTO: fout.printf("\n"); break; default: diff --git a/client/http_curl.h b/client/http_curl.h index 488ca0f5df..ac6c44fa6f 100644 --- a/client/http_curl.h +++ b/client/http_curl.h @@ -38,19 +38,6 @@ extern int curl_init(); extern int curl_cleanup(); -// official HTTP status codes - -#define HTTP_STATUS_CONTINUE 100 -#define HTTP_STATUS_OK 200 -#define HTTP_STATUS_PARTIAL_CONTENT 206 -#define HTTP_STATUS_MOVED_PERM 301 -#define HTTP_STATUS_MOVED_TEMP 302 -#define HTTP_STATUS_NOT_FOUND 404 -#define HTTP_STATUS_PROXY_AUTH_REQ 407 -#define HTTP_STATUS_RANGE_REQUEST_ERROR 416 -#define HTTP_STATUS_INTERNAL_SERVER_ERROR 500 -#define HTTP_STATUS_SERVICE_UNAVAILABLE 503 - #define HTTP_OP_NONE 0 #define HTTP_OP_GET 1 // data sink is a file (used for file download) diff --git a/client/log_flags.C b/client/log_flags.C index bd5462f23a..ad9e998544 100644 --- a/client/log_flags.C +++ b/client/log_flags.C @@ -30,10 +30,10 @@ #endif #include "error_numbers.h" +#include "common_defs.h" #include "file_names.h" #include "client_msgs.h" #include "parse.h" - #include "filesys.h" LOG_FLAGS log_flags; diff --git a/client/main.C b/client/main.C index 24ac1b8b0c..e4fc3faa47 100644 --- a/client/main.C +++ b/client/main.C @@ -268,10 +268,10 @@ static void signal_handler(int signum) { #endif break; case SIGTSTP: - gstate.user_run_request = USER_RUN_REQUEST_NEVER; + gstate.user_run_request = RUN_MODE_NEVER; break; case SIGCONT: - gstate.user_run_request = USER_RUN_REQUEST_AUTO; + gstate.user_run_request = RUN_MODE_AUTO; break; default: msg_printf(NULL, MSG_ERROR, "Signal not handled"); @@ -543,13 +543,13 @@ int boinc_main_loop() { } #ifdef _WIN32 if (requested_suspend) { - gstate.user_run_request = USER_RUN_REQUEST_NEVER; - gstate.user_network_request = USER_RUN_REQUEST_NEVER; + gstate.user_run_request = RUN_MODE_NEVER; + gstate.user_network_request = RUN_MODE_NEVER; requested_suspend = false; } if (requested_resume) { - gstate.user_run_request = USER_RUN_REQUEST_AUTO; - gstate.user_network_request = USER_RUN_REQUEST_AUTO; + gstate.user_run_request = RUN_MODE_AUTO; + gstate.user_network_request = RUN_MODE_AUTO; requested_resume = false; } #endif diff --git a/client/ss_logic.h b/client/ss_logic.h index 04b279362e..3dc0b2f7c9 100644 --- a/client/ss_logic.h +++ b/client/ss_logic.h @@ -24,25 +24,6 @@ #include #endif -// the core client can be requested to provide screensaver graphics (SSG). -// The following are states of this function: - -#define SS_STATUS_ENABLED 1 - // requested to provide SSG -#define SS_STATUS_BLANKED 3 - // not providing SSG, SS should blank screen -#define SS_STATUS_BOINCSUSPENDED 4 - // not providing SS because suspended -#define SS_STATUS_NOAPPSEXECUTING 6 - // no apps executing -#define SS_STATUS_NOGRAPHICSAPPSEXECUTING 7 - // apps executing, but none graphical -#define SS_STATUS_QUIT 8 - // not requested to provide SSG -#define SS_STATUS_NOPROJECTSDETECTED 9 - // SSG unsupported; client running as daemon -#define SS_STATUS_DAEMONALLOWSNOGRAPHICS 10 - class SS_LOGIC { public: diff --git a/clientgui/MainDocument.h b/clientgui/MainDocument.h index d8d88c21a1..098848cae7 100644 --- a/clientgui/MainDocument.h +++ b/clientgui/MainDocument.h @@ -24,6 +24,7 @@ #pragma interface "MainDocument.cpp" #endif +#include "common_defs.h" #include "gui_rpc_client.h" class CMainDocument; diff --git a/lib/app_ipc.h b/lib/app_ipc.h index 5314cbeb06..87dad4eb1c 100755 --- a/lib/app_ipc.h +++ b/lib/app_ipc.h @@ -27,6 +27,7 @@ #include "hostinfo.h" #include "proxy_info.h" #include "prefs.h" +#include "common_defs.h" // Communication between the core client and the BOINC app library. // This code is linked into both core client and app lib. @@ -116,18 +117,6 @@ struct MSG_QUEUE { #define SHM_PREFIX "shm_" #define QUIT_PREFIX "quit_" -// graphics messages -// -#define MODE_UNSUPPORTED 0 -#define MODE_HIDE_GRAPHICS 1 -#define MODE_WINDOW 2 -#define MODE_FULLSCREEN 3 -#define MODE_BLANKSCREEN 4 -#define MODE_REREAD_PREFS 5 -#define MODE_QUIT 6 - -#define NGRAPHICS_MSGS 7 - struct GRAPHICS_MSG { int mode; char window_station[256]; diff --git a/lib/boinc_cmd.C b/lib/boinc_cmd.C index 5dd993072c..fe58876c6b 100644 --- a/lib/boinc_cmd.C +++ b/lib/boinc_cmd.C @@ -42,6 +42,7 @@ using std::string; #include "error_numbers.h" #include "util.h" #include "version.h" +#include "common_defs.h" void usage() { diff --git a/lib/error_numbers.h b/lib/error_numbers.h index 8107664c0f..dec867b7f0 100755 --- a/lib/error_numbers.h +++ b/lib/error_numbers.h @@ -179,13 +179,4 @@ // PLEASE: add a text description of your error to // the text description function boincerror() in util.C. -//////////////// other #defines shared by client and Manager - -// values of "network status" -// -#define NETWORK_STATUS_ONLINE 0 -#define NETWORK_STATUS_WANT_CONNECTION 1 -#define NETWORK_STATUS_WANT_DISCONNECT 2 -#define NETWORK_STATUS_LOOKUP_PENDING 3 - #endif diff --git a/lib/gui_rpc_client.C b/lib/gui_rpc_client.C index f1af55bb06..2983a75094 100644 --- a/lib/gui_rpc_client.C +++ b/lib/gui_rpc_client.C @@ -47,6 +47,7 @@ #include "miofile.h" #include "md5_file.h" #include "network.h" +#include "common_defs.h" #include "gui_rpc_client.h" using std::string; diff --git a/lib/gui_rpc_client.h b/lib/gui_rpc_client.h index f0bd624e72..c02a4bce61 100644 --- a/lib/gui_rpc_client.h +++ b/lib/gui_rpc_client.h @@ -35,77 +35,6 @@ #include "prefs.h" #include "hostinfo.h" -#define GUI_RPC_PORT 31416 - -// official HTTP status codes -// -#define HTTP_STATUS_OK 200 -#define HTTP_STATUS_PARTIAL_CONTENT 206 -#define HTTP_STATUS_RANGE_REQUEST_ERROR 416 -#define HTTP_STATUS_MOVED_PERM 301 -#define HTTP_STATUS_MOVED_TEMP 302 -#define HTTP_STATUS_NOT_FOUND 404 -#define HTTP_STATUS_PROXY_AUTH_REQ 407 -#define HTTP_STATUS_INTERNAL_SERVER_ERROR 500 -#define HTTP_STATUS_SERVICE_UNAVAILABLE 503 - -#define RUN_MODE_ALWAYS 0 -#define RUN_MODE_NEVER 1 -#define RUN_MODE_AUTO 2 - -#define RESULT_NEW 0 -#define RESULT_FILES_DOWNLOADING 1 -#define RESULT_FILES_DOWNLOADED 2 -#define RESULT_COMPUTE_ERROR 3 -#define RESULT_FILES_UPLOADING 4 -#define RESULT_FILES_UPLOADED 5 -#define RESULT_ABORTED 6 - -// values for RESULT::scheduler_state -// -#define CPU_SCHED_UNINITIALIZED 0 -#define CPU_SCHED_PREEMPTED 1 -#define CPU_SCHED_SCHEDULED 2 - -// see client/ss_logic.h for explanation -// -#define SS_STATUS_ENABLED 1 -#define SS_STATUS_RESTARTREQUEST 2 -#define SS_STATUS_BLANKED 3 -#define SS_STATUS_BOINCSUSPENDED 4 -#define SS_STATUS_NOAPPSEXECUTING 6 -#define SS_STATUS_NOGRAPHICSAPPSEXECUTING 7 -#define SS_STATUS_QUIT 8 -#define SS_STATUS_NOPROJECTSDETECTED 9 -#define SS_STATUS_DAEMONALLOWSNOGRAPHICS 10 - -// see lib/app_ipc.h for explanation -// -#define MODE_UNSUPPORTED 0 -#define MODE_HIDE_GRAPHICS 1 -#define MODE_WINDOW 2 -#define MODE_FULLSCREEN 3 -#define MODE_BLANKSCREEN 4 -#define MODE_REREAD_PREFS 5 -#define MODE_QUIT 6 - -// These MUST match the constants in client/client_msgs.h -// -#define MSG_PRIORITY_INFO 1 - // show message in black -#define MSG_PRIORITY_ERROR 2 - // show message in red - -enum SUSPEND_REASON { - SUSPEND_REASON_BATTERIES = 1, - SUSPEND_REASON_USER_ACTIVE = 2, - SUSPEND_REASON_USER_REQ = 4, - SUSPEND_REASON_TIME_OF_DAY = 8, - SUSPEND_REASON_BENCHMARKS = 16, - SUSPEND_REASON_DISK_SIZE = 32, - SUSPEND_REASON_CPU_USAGE_LIMIT = 64, -}; - struct GUI_URL { std::string name; std::string description; diff --git a/lib/gui_rpc_client_ops.C b/lib/gui_rpc_client_ops.C index 6b3a33df76..7dd1d7cfff 100644 --- a/lib/gui_rpc_client_ops.C +++ b/lib/gui_rpc_client_ops.C @@ -69,6 +69,7 @@ #include "miofile.h" #include "md5_file.h" #include "network.h" +#include "common_defs.h" #include "gui_rpc_client.h" using std::string; diff --git a/lib/procinfo_unix.C b/lib/procinfo_unix.C index 5d1dc4288c..0555811cdd 100644 --- a/lib/procinfo_unix.C +++ b/lib/procinfo_unix.C @@ -21,13 +21,9 @@ #include "config.h" #include -#ifdef HAVE_SYS_TYPES_H +#include #include -#endif - -#ifdef HAVE_DIRENT_H #include -#endif #include "procinfo.h" #include "client_msgs.h" diff --git a/lib/result_state.h b/lib/result_state.h deleted file mode 100644 index 940b4a9882..0000000000 --- a/lib/result_state.h +++ /dev/null @@ -1,43 +0,0 @@ -// Berkeley Open Infrastructure for Network Computing -// http://boinc.berkeley.edu -// Copyright (C) 2005 University of California -// -// This is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; -// either version 2.1 of the License, or (at your option) any later version. -// -// This software is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -// See the GNU Lesser General Public License for more details. -// -// To view the GNU Lesser General Public License visit -// http://www.gnu.org/copyleft/lesser.html -// or write to the Free Software Foundation, Inc., -// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -#ifndef _RESULT_STATE_ -#define _RESULT_STATE_ - -// States of a result on a client. -// THESE MUST BE IN NUMERICAL ORDER -// (because of the > comparison in RESULT::computing_done()) -// -#define RESULT_NEW 0 - // New result -#define RESULT_FILES_DOWNLOADING 1 - // Input files for result (WU, app version) are being downloaded -#define RESULT_FILES_DOWNLOADED 2 - // Files are downloaded, result can be (or is being) computed -#define RESULT_COMPUTE_ERROR 3 - // computation failed; no file upload -#define RESULT_FILES_UPLOADING 4 - // Output files for result are being uploaded -#define RESULT_FILES_UPLOADED 5 - // Files are uploaded, notify scheduling server at some point -#define RESULT_ABORTED 6 - // result was aborted - -#endif - diff --git a/lib/util.C b/lib/util.C index 64647c4d82..b28c8dabbe 100755 --- a/lib/util.C +++ b/lib/util.C @@ -53,6 +53,7 @@ #include "error_numbers.h" +#include "common_defs.h" #include "filesys.h" #include "util.h" diff --git a/sched/server_types.h b/sched/server_types.h index 704dc3bc26..8de01d3be4 100644 --- a/sched/server_types.h +++ b/sched/server_types.h @@ -24,7 +24,7 @@ #include #include "boinc_db.h" -#include "result_state.h" +#include "common_defs.h" #include "md5_file.h" // summary of a client's request for work, and our response to it