// The contents of this file are subject to the Mozilla Public License // Version 1.0 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License at // http://www.mozilla.org/MPL/ // // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the // License for the specific language governing rights and limitations // under the License. // // The Original Code is the Berkeley Open Infrastructure for Network Computing. // // The Initial Developer of the Original Code is the SETI@home project. // Portions created by the SETI@home project are Copyright (C) 2002 // University of California at Berkeley. All Rights Reserved. // // Contributor(s): // #include #include #include #include #include #include "db.h" #include "parse.h" #include "config.h" #include "assimilate_handler.h" CONFIG config; void write_log(char* p) { time_t now = time(0); char* timestr = ctime(&now); *(strchr(timestr, '\n')) = 0; fprintf(stderr, "%s: %s", timestr, p); } // assimilate all WUs that need it // return nonzero if did anything // bool do_pass(APP& app) { WORKUNIT wu; RESULT canonical_result, result; vector results; bool did_something = false, delete_inputs, delete_outputs; char buf[MAX_BLOB_SIZE]; unsigned int i; wu.appid = app.id; wu.assimilate_state = ASSIMILATE_READY; while (!db_workunit_enum_app_assimilate_state(wu)) { did_something = true; sprintf(buf, "Assimilating WU %s, assim state %d\n", wu.name, wu.assimilate_state ); write_log(buf); result.workunitid = wu.id; while (!db_result_enum_wuid(result)) { results.push_back(result); if (result.id == wu.canonical_resultid) { canonical_result = result; } } assimilate_handler(wu, results, canonical_result); delete_outputs = true; delete_inputs = true; for (i=0; i