Commit 5f075e9a authored by David Anderson's avatar David Anderson
Browse files

Merge branch 'master' of github.com:BOINC/boinc

parents bae397cc f33c4ed1
......@@ -390,7 +390,11 @@ void COPROC_ATI::get(
warnings.push_back("No ATI GPUs found");
}
leave:
#ifdef _WIN32
if (callib) FreeLibrary(callib);
#else
if (callib) dlclose(callib);
#endif
}
void COPROC_ATI::correlate(
......
......@@ -483,8 +483,6 @@ void CTaskBarIcon::MacCancelUserAttentionRequest()
void CTaskBarIcon::DisplayContextMenu() {
ResetTaskBar();
wxMenu* pMenu = BuildContextMenu();
PopupMenu(pMenu);
delete pMenu;
......@@ -657,10 +655,16 @@ void CTaskBarIcon::AdjustMenuItems(wxMenu* pMenu) {
break;
}
if (status.task_mode == RUN_MODE_NEVER) {
m_SnoozeGPUMenuItem->Check(false);
bool check_gpu_snooze = false;
if (status.task_mode_perm != RUN_MODE_NEVER) check_gpu_snooze = true;
if ((status.gpu_mode == RUN_MODE_NEVER) && (status.gpu_mode_perm != RUN_MODE_NEVER)) {
check_gpu_snooze = true;
}
m_SnoozeGPUMenuItem->Check(check_gpu_snooze);
m_SnoozeGPUMenuItem->Enable(false);
} else {
m_SnoozeGPUMenuItem->Enable(enableSnoozeItems);
}
m_SnoozeGPUMenuItem->Enable(enableSnoozeItems);
}
}
......
......@@ -1150,7 +1150,15 @@ function boincimport_quarrels_op($boinc_user, &$context) {
$ignored_users = explode('|', trim($boinc_user->ignorelist, '|'));
foreach ($ignored_users as $ignored_user) {
$ignored_user_uid = boincuser_lookup_uid($ignored_user);
if (!$ignored_user_uid) continue;
if (!$ignored_user_uid) {
$context['results']['warning'][] = "{$uid}:{$ignored_user_uid}";
watchdog('boincimport',
'Error adding to ignore list of user @uid: No Drupal ID found for BOINC user @boinc_id',
array('@boinc_id' => $ignored_user, '@uid' => $uid),
WATCHDOG_WARNING
);
continue;
}
$user_ignored = db_query("
INSERT IGNORE INTO {ignore_user}
SET uid = '%d', iuid = '%d'",
......@@ -1160,7 +1168,12 @@ function boincimport_quarrels_op($boinc_user, &$context) {
$success = TRUE;
}
else {
$context['results']['warning'][$uid] = $ignored_user_uid;
$context['results']['warning'][] = "{$uid}:{$ignored_user_uid}";
watchdog('boincimport',
'Could not add user @ignored_uid to the ignore list of user @uid',
array('@ignored_uid' => $ignored_user_uid, '@uid' => $uid),
WATCHDOG_WARNING
);
}
}
......@@ -1210,16 +1223,6 @@ function boincimport_preferences_finished($success, $results, $operations) {
array('@count' => $total_imported, '@warn' => $total_warnings),
WATCHDOG_INFO
);
// Record any warnings
if ($total_warnings) {
foreach ($results['warning'] as $uid => $ignored_user_uid) {
watchdog('boincimport',
'Could not add user @ignored_uid to the ignore list of user @uid',
array('@ignored_uid' => $ignored_user_uid, '@uid' => $uid),
WATCHDOG_WARNING
);
}
}
// Set the preference import successful flag in the variable table
variable_set('boincimport_import_preferences_successful', '1');
$_SESSION['boincimport_stage_selected'] = 'private messages';
......@@ -1634,7 +1637,7 @@ function boincimport_forum_categories_op($category, $forum_vid, $pre, $create_hi
if (!$category AND $create_hidden) {
// Create the special "hidden" container
$category = new stdClass();
$category->name = t('Hidden');
$category->name = 'Hidden';
$category->id = 0;
$hidden = TRUE;
}
......@@ -1679,8 +1682,13 @@ function boincimport_forum_categories_op($category, $forum_vid, $pre, $create_hi
$message = '';
if ($success) {
// Store some result for post-processing in the finished callback.
$context['results']['categories']['success'][] = $category->id;
$message = "Successfully imported container {$category->id}";
if (!$category AND $create_hidden) {
$message = "Created special hidden container";
}
else {
$context['results']['categories']['success'][] = $category->id;
$message = "Successfully imported container {$category->id}";
}
}
else {
$context['results']['categories']['failure'][] = $category->id;
......
......@@ -16,6 +16,8 @@
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
include_once("../inc/translation.inc");
global $team_types;
$team_types = array(
"",
......
......@@ -43,7 +43,8 @@
// Function return values.
// NOTE: add new errors to the end of the list and don't change
// old error numbers to avoid confusion between versions.
// Add a text description of your error to boincerror() in util.C.
// Add a text description of your error to the text description
// function boincerror() in str_util.cpp.
//
#define BOINC_SUCCESS 0
#define ERR_SELECT -100
......
......@@ -24,6 +24,7 @@ SCHED_MSG_LOG log_messages;
const char* SCHED_MSG_LOG::v_format_kind(int kind) const {
switch(kind) {
case MSG_CRITICAL: return "[CRITICAL]";
case MSG_WARNING: return "[warning]";
case MSG_NORMAL: return "";
case MSG_DEBUG: return "[debug]";
default: return "*** internal error: invalid MessageKind ***";
......
......@@ -24,14 +24,14 @@
#include "boinc_fcgi.h"
#endif
enum { MSG_CRITICAL=1, MSG_NORMAL, MSG_DEBUG };
enum { MSG_CRITICAL=1, MSG_WARNING, MSG_NORMAL, MSG_DEBUG };
class SCHED_MSG_LOG : public MSG_LOG {
const char* v_format_kind(int kind) const;
bool v_message_wanted(int kind) const;
public:
int debug_level;
enum { MSG_CRITICAL=1, MSG_NORMAL, MSG_DEBUG };
enum { MSG_CRITICAL=1, MSG_WARNING, MSG_NORMAL, MSG_DEBUG };
SCHED_MSG_LOG(): MSG_LOG(stderr) { debug_level = MSG_NORMAL; }
void set_debug_level(int new_level) { debug_level = new_level; }
void set_indent_level(const int new_indent_level);
......
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
// Copyright (C) 2015 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
......@@ -34,7 +34,5 @@ extern int assimilate_handler(
RESULT& // the canonical instance
);
extern int g_argc;
extern char** g_argv;
extern char* results_prefix;
extern char* transcripts_prefix;
extern int assimilate_handler_init(int argc, char** argv);
extern void assimilate_handler_usage();
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2014 University of California
// Copyright (C) 2015 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
......@@ -46,16 +46,11 @@ using std::vector;
#define SLEEP_INTERVAL 10
bool update_db = true;
bool noinsert = false;
int wu_id_modulus=0, wu_id_remainder=0;
int sleep_interval = SLEEP_INTERVAL;
int one_pass_N_WU=0;
int g_argc;
char** g_argv;
char* results_prefix = NULL;
char* transcripts_prefix = NULL;
void usage(char** argv) {
void usage(char* name) {
fprintf(stderr,
"This program is an 'assimilator'; it handles completed jobs.\n"
"Normally it is run as a daemon from config.xml.\n"
......@@ -70,13 +65,13 @@ void usage(char** argv) {
" [--one_pass] Do one DB enumeration, then exit\n"
" [--one_pass_N_WU N] Process at most N jobs\n"
" [-d | --debug_level N] Set verbosity level (1 to 4)\n"
" [--dont_update_db] Don't update DB (for testing)\n"
" [--noinsert] Don't insert records in app-specific DB\n"
" [--dont_update_db] Don't update BOINC DB (for testing)\n"
" [-h | --help] Show this\n"
" [-v | --version] Show version information\n",
argv[0]
" [-v | --version] Show version information\n"
"\n",
name
);
exit(0);
assimilate_handler_usage();
}
// assimilate all WUs that need it
......@@ -100,7 +95,7 @@ bool do_pass(APP& app) {
}
sprintf(buf,
"where appid=%lu and assimilate_state=%d %s limit %d",
"where appid=%ld and assimilate_state=%d %s limit %d",
app.id, ASSIMILATE_READY, mod_clause,
one_pass_N_WU ? one_pass_N_WU : 1000
);
......@@ -127,7 +122,7 @@ bool do_pass(APP& app) {
"[%s] assimilating WU %lu; state=%d\n", wu.name, wu.id, wu.assimilate_state
);
sprintf(buf, "where workunitid=%lu", wu.id);
sprintf(buf, "where workunitid=%ld", wu.id);
canonical_result.clear();
bool found = false;
while (1) {
......@@ -206,6 +201,13 @@ bool do_pass(APP& app) {
return did_something;
}
void missing_argument(char* name, char* arg) {
log_messages.printf(MSG_CRITICAL,
"%s requires an argument\n\n", arg
);
usage(name);
}
int main(int argc, char** argv) {
int retval;
bool one_pass = false;
......@@ -215,22 +217,38 @@ int main(int argc, char** argv) {
strcpy(app.name, "");
check_stop_daemons();
g_argc = argc;
g_argv = argv;
int j=1;
for (i=1; i<argc; i++) {
if (is_arg(argv[i], "one_pass_N_WU")) {
one_pass_N_WU = atoi(argv[++i]);
if (!argv[++i]) {
missing_argument(argv[0], argv[--i]);
exit(1);
}
one_pass_N_WU = atoi(argv[i]);
one_pass = true;
} else if (is_arg(argv[i], "sleep_interval")) {
sleep_interval = atoi(argv[++i]);
if (!argv[++i]) {
missing_argument(argv[0], argv[--i]);
exit(1);
}
sleep_interval = atoi(argv[i]);
} else if (is_arg(argv[i], "one_pass")) {
one_pass = true;
} else if (is_arg(argv[i], "d") || is_arg(argv[i], "debug_level")) {
int dl = atoi(argv[++i]);
if (!argv[++i]) {
missing_argument(argv[0], argv[--i]);
exit(1);
}
int dl = atoi(argv[i]);
log_messages.set_debug_level(dl);
if (dl ==4) g_print_queries = true;
} else if (is_arg(argv[i], "app")) {
safe_strcpy(app.name, argv[++i]);
if (!argv[++i]) {
missing_argument(argv[0], argv[--i]);
exit(1);
}
safe_strcpy(app.name, argv[i]);
} else if (is_arg(argv[i], "dont_update_db")) {
// This option is for testing your assimilator. When set,
// it ensures that the assimilator does not actually modify
......@@ -238,31 +256,32 @@ int main(int argc, char** argv) {
// your assimilator over and over again without affecting
// your project.
update_db = false;
} else if (is_arg(argv[i], "noinsert")) {
// This option is also for testing and is used to
// prevent the inserting of results into the *backend*
// (as opposed to the boinc) DB.
noinsert = true;
} else if (is_arg(argv[i], "mod")) {
wu_id_modulus = atoi(argv[++i]);
wu_id_remainder = atoi(argv[++i]);
if (!argv[++i]) {
missing_argument(argv[0], argv[--i]);
exit(1);
}
wu_id_modulus = atoi(argv[i]);
if (!argv[++i]) {
missing_argument(argv[0], argv[--i]);
exit(1);
}
wu_id_remainder = atoi(argv[i]);
} else if (is_arg(argv[i], "help") || is_arg(argv[i], "h")) {
usage(argv);
usage(argv[0]);
exit(0);
} else if (is_arg(argv[i], "v") || is_arg(argv[i], "version")) {
printf("%s\n", SVN_VERSION);
exit(0);
} else if (is_arg(argv[i], "results_prefix")) {
results_prefix=argv[++i];
} else if (is_arg(argv[i], "transcripts_prefix")) {
transcripts_prefix=argv[++i];
} else {
// project-specific part might parse extra args
//log_messages.printf(MSG_CRITICAL, "Unrecognized arg: %s\n", argv[i]);
// unknown arg - pass to handler
argv[j++] = argv[i];
}
}
if (!strlen(app.name)) {
usage(argv);
usage(argv[0]);
exit(1);
}
if (wu_id_modulus) {
......@@ -280,19 +299,24 @@ int main(int argc, char** argv) {
exit(1);
}
log_messages.printf(MSG_NORMAL, "Starting\n");
retval = boinc_db.open(config.db_name, config.db_host, config.db_user, config.db_passwd);
if (retval) {
log_messages.printf(MSG_CRITICAL, "Can't open DB\n");
log_messages.printf(MSG_CRITICAL, "boinc_db.open failed: %s\n", boincerror(retval));
exit(1);
}
sprintf(buf, "where name='%s'", app.name);
retval = app.lookup(buf);
if (retval) {
log_messages.printf(MSG_CRITICAL, "Can't find app\n");
log_messages.printf(MSG_CRITICAL, "Can't find app: %s\n", app.name);
exit(1);
}
argv[j] = 0;
retval = assimilate_handler_init(j, argv);
if (retval) exit(1);
log_messages.printf(MSG_NORMAL, "Starting assimilator handler\n");
install_stop_signal_handler();
do {
if (!do_pass(app)) {
......
......@@ -164,6 +164,10 @@ int copy_socket_to_file(FILE* in, char* path, double offset, double nbytes) {
// and made read-only;
// return success to the client won't keep trying
//
log_messages.printf(MSG_WARNING,
"client tried to reupload the read-only file %s\n",
path
);
return return_success(0);
}
return return_error(ERR_TRANSIENT,
......@@ -262,7 +266,9 @@ int copy_socket_to_file(FILE* in, char* path, double offset, double nbytes) {
}
// upload complete; make the file read-only so we won't try to upload it again.
//
fchmod(fd, S_IRUSR|S_IRGRP|S_IROTH);
if (fchmod(fd, S_IRUSR|S_IRGRP|S_IROTH)) {
log_messages.printf(MSG_CRITICAL, "can't make file %s read only: %s\n", path, strerror(errno));
}
close(fd);
return return_success(0);
}
......@@ -728,6 +734,12 @@ int main(int argc, char *argv[]) {
}
}
if (access(config.upload_dir, W_OK)) {
log_messages.printf(MSG_CRITICAL, "can't write to upload_dir\n");
return_error(ERR_TRANSIENT, "can't write to upload_dir");
exit(1);
}
#ifdef _USING_FCGI_
while(FCGI_Accept() >= 0) {
counter++;
......
......@@ -498,6 +498,17 @@ got_host:
return 0;
}
inline static const char* get_remote_addr() {
// Server is behind a load balancer or proxy
const char* p = getenv("HTTP_X_FORWARDED_FOR");
if (p) {
return p;
}
const char * r = getenv("REMOTE_ADDR");
return r ? r : "?.?.?.?";
}
// modify host struct based on request.
// Copy all fields that are determined by the client.
//
......@@ -585,7 +596,7 @@ static int update_host_record(HOST& initial_host, HOST& xhost, USER& user) {
md5_block((const unsigned char*)buf, strlen(buf), host.host_cpid);
}
char* p = getenv("REMOTE_ADDR");
const char* p = get_remote_addr();
if (p) {
strlcpy(host.external_ip_addr, p, sizeof(host.external_ip_addr));
}
......@@ -1044,11 +1055,6 @@ bool wrong_core_client_version() {
return true;
}
inline static const char* get_remote_addr() {
const char * r = getenv("REMOTE_ADDR");
return r ? r : "?.?.?.?";
}
void handle_msgs_from_host() {
unsigned int i;
DB_MSG_FROM_HOST mfh;
......
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
// Copyright (C) 2015 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
......@@ -29,6 +29,7 @@
#include "sched_msgs.h"
#include "validate_util.h"
#include "sched_config.h"
#include "assimilate_handler.h"
using std::vector;
using std::string;
......@@ -44,6 +45,19 @@ int write_error(char* p) {
return 0;
}
int assimilate_handler_init(int argc, char** argv) {
// handle project specific arguments here
return 0;
}
void assimilate_handler_usage() {
// describe the project specific arguments here
//fprintf(stderr,
// " Custom options:\n"
// " [--project_option X] a project specific option\n"
//);
}
int assimilate_handler(
WORKUNIT& wu, vector<RESULT>& /*results*/, RESULT& canonical_result
) {
......
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
// Copyright (C) 2015 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
......@@ -31,6 +31,19 @@
using std::vector;
using std::string;
int assimilate_handler_init(int argc, char** argv) {
// handle project specific arguments here
return 0;
}
void assimilate_handler_usage() {
// describe the project specific arguments here
//fprintf(stderr,
// " Custom options:\n"
// " [--project_option X] a project specific option\n"
//);
}
int assimilate_handler(
WORKUNIT& wu, vector<RESULT>& /*results*/, RESULT& canonical_result
) {
......
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2014 University of California
// Copyright (C) 2015 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
......@@ -47,6 +47,7 @@
#include "boinc_db.h"
#include "error_numbers.h"
#include "sched_msgs.h"
#include "sched_util.h"
#include "validate_util.h"
#include "validator.h"
#include "sched_config.h"
......@@ -54,13 +55,13 @@
using std::vector;
using std::string;
bool first = true;
vector<string> script;
void parse_cmdline() {
for (int i=1; i<g_argc; i++) {
if (!strcmp(g_argv[i], "--script")) {
script = split(g_argv[++i], ' ');
int assimilate_handler_init(int argc, char** argv) {
// handle project specific arguments here
for (int i=1; i<argc; i++) {
if (is_arg(argv[i], "script")) {
script = split(argv[++i], ' ');
if (script.size() == 1) {
script.push_back("wu_id");
script.push_back("files");
......@@ -71,8 +72,18 @@ void parse_cmdline() {
log_messages.printf(MSG_CRITICAL,
"script name missing from command line\n"
);
exit(1);
return 1;
}
return 0;
}
void assimilate_handler_usage() {
// describe the project specific arguments here
fprintf(stderr,
" Custom options:\n"
" --script \"X\" call script to assimilate job\n"
" see comment in script_assimilator.cpp for details\n"
);
}
int assimilate_handler(
......@@ -82,11 +93,6 @@ int assimilate_handler(
char cmd[4096], buf[256];
unsigned int i, j;
if (first) {
parse_cmdline();
first = false;
}
if (wu.canonical_resultid) {
sprintf(cmd, "../bin/%s", script[0].c_str());
vector<string> paths;
......
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
// Copyright (C) 2015 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
......@@ -39,6 +39,19 @@
using std::vector;
using std::string;
int assimilate_handler_init(int argc, char** argv) {
// handle project specific arguments here
return 0;
}
void assimilate_handler_usage() {
// describe the project specific arguments here
//fprintf(stderr,
// " Custom options:\n"
// " [--project_option X] a project specific option\n"
//);
}
int assimilate_handler(
WORKUNIT& wu, vector<RESULT>& /*results*/, RESULT& canonical_result
) {
......
......@@ -97,7 +97,7 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Midl>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_DEBUG;_WCG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MkTypLibCompatible>true</MkTypLibCompatible>
<SuppressStartupBanner>true</SuppressStartupBanner>
<TargetEnvironment>Win32</TargetEnvironment>
......@@ -108,7 +108,7 @@
<ClCompile>