From 0c948a656a01d2921fe243671f01b08c7f4c9e6c Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 20 Jul 2010 04:19:22 +0000 Subject: [PATCH] - client: init gstate.now early so that initial msgs have timestamps - lib: fix the above svn path=/trunk/boinc/; revision=22012 --- checkin_notes | 11 +++++++++ client/main.cpp | 1 + client/sim.h | 3 +++ lib/notice.cpp | 1 - lib/parse.cpp | 60 +++++++++++++++++++++++++++++-------------------- lib/parse.h | 1 + 6 files changed, 52 insertions(+), 25 deletions(-) diff --git a/checkin_notes b/checkin_notes index 054c2cdf30..4cda2fb491 100644 --- a/checkin_notes +++ b/checkin_notes @@ -5273,3 +5273,14 @@ David 19 Jul 2010 lib/ parse.cpp + +David 19 Jul 2010 + - client: init gstate.now early so that initial msgs have timestamps + - lib: fix the above + + client/ + main.cpp + sim.h + lib/ + notice.cpp + parse.cpp,h diff --git a/client/main.cpp b/client/main.cpp index 721e39ad8f..be5a7db1a8 100644 --- a/client/main.cpp +++ b/client/main.cpp @@ -210,6 +210,7 @@ static void init_core_client(int argc, char** argv) { config.clear(); gstate.parse_cmdline(argc, argv); + gstate.now = dtime(); #ifdef _WIN32 if (!config.allow_multiple_clients) { diff --git a/client/sim.h b/client/sim.h index 8239eba7a9..6b64688323 100644 --- a/client/sim.h +++ b/client/sim.h @@ -319,3 +319,6 @@ extern bool gpus_usable; #define START_TIME 946684800 // Jan 1 2000 + +#define WF_MIN_BACKOFF_INTERVAL 60 +#define WF_MAX_BACKOFF_INTERVAL 86400 diff --git a/lib/notice.cpp b/lib/notice.cpp index 51b407d4a4..8239d4665c 100644 --- a/lib/notice.cpp +++ b/lib/notice.cpp @@ -42,7 +42,6 @@ int NOTICE::parse(XML_PARSER& xp) { char tag[1024]; bool is_tag; -// memset(this, 0, sizeof(*this)); clear(); while (!xp.get(tag, sizeof(tag), is_tag)) { if (!is_tag) continue; diff --git a/lib/parse.cpp b/lib/parse.cpp index 6fcb954c20..124edc42de 100644 --- a/lib/parse.cpp +++ b/lib/parse.cpp @@ -467,6 +467,8 @@ bool XML_PARSER::scan_nonws(int& first_char) { #define XML_PARSE_COMMENT 1 #define XML_PARSE_EOF 2 #define XML_PARSE_CDATA 3 +#define XML_PARSE_TAG 4 +#define XML_PARSE_DATA 5 int XML_PARSER::scan_comment() { char buf[256]; @@ -512,10 +514,11 @@ int XML_PARSER::scan_cdata(char* buf, int len) { // - copy tag (or tag/) to tag_buf // - copy "attr=val attr=val" to attr_buf // -// Return: -// 0 if got a tag -// 1 if got a comment (ignore) -// 2 if reached EOF +// Return either +// XML_PARSE_TAG +// XML_PARSE_COMMENT +// XML_PARSE_EOF +// XML_PARSE_CDATA // int XML_PARSER::scan_tag( char* tag_buf, int _tag_len, char* attr_buf, int attr_len @@ -527,11 +530,11 @@ int XML_PARSER::scan_tag( for (int i=0; ; i++) { c = f->_getc(); - if (c == EOF) return 2; + if (c == EOF) return XML_PARSE_EOF; if (c == '>') { *tag_buf = 0; if (attr_buf) *attr_buf = 0; - return 0; + return XML_PARSE_TAG; } if (isspace(c)) { if (found_space && attr_buf) { @@ -591,36 +594,44 @@ bool XML_PARSER::copy_until_tag(char* buf, int len) { // Scan something, either tag or text. // Strip whitespace at start and end. +// Return true iff reached EOF // -int XML_PARSER::get( - char* buf, int len, bool& is_tag, char* attr_buf, int attr_len -) { +int XML_PARSER::get_aux(char* buf, int len, char* attr_buf, int attr_len) { bool eof; - int c; + int c, retval; while (1) { eof = scan_nonws(c); if (eof) return XML_PARSE_EOF; if (c == '<') { - int retval = scan_tag(buf, len, attr_buf, attr_len); - if (retval == XML_PARSE_EOF) return XML_PARSE_EOF; + retval = scan_tag(buf, len, attr_buf, attr_len); + if (retval == XML_PARSE_EOF) return retval; if (retval == XML_PARSE_COMMENT) continue; - if (retval == XML_PARSE_CDATA) { - is_tag = false; - } else { - is_tag = true; - } } else { buf[0] = c; eof = copy_until_tag(buf+1, len-1); - if (eof) return true; - is_tag = false; + if (eof) return XML_PARSE_EOF; + retval = XML_PARSE_DATA; } strip_whitespace(buf); - return retval;; + return retval; } } +bool XML_PARSER::get(char* buf, int len, bool& is_tag, char* attr_buf, int attr_len) { + switch (get_aux(buf, len, attr_buf, attr_len)) { + case XML_PARSE_EOF: return true; + case XML_PARSE_TAG: + is_tag = true; + break; + case XML_PARSE_DATA: + case XML_PARSE_CDATA: + is_tag = false; + break; + } + return false; +} + // We just parsed "parsed_tag". // If it matches "start_tag", and is followed by a string // and by the matching close tag, return the string in "buf", @@ -631,7 +642,6 @@ bool XML_PARSER::parse_str( ) { bool is_tag, eof; char end_tag[256], tag[256], tmp[64000]; - int retval; // handle the archaic form , which means empty string // @@ -651,12 +661,12 @@ bool XML_PARSER::parse_str( // get text after start tag // - retval = get(tmp, 64000, is_tag); + int retval = get_aux(tmp, 64000, 0, 0); if (retval == XML_PARSE_EOF) return false; // if it's the end tag, return empty string // - if (is_tag) { + if (retval == XML_PARSE_TAG) { if (strcmp(tmp, end_tag)) { return false; } else { @@ -669,7 +679,9 @@ bool XML_PARSER::parse_str( if (eof) return false; if (!is_tag) return false; if (strcmp(tag, end_tag)) return false; - if (retval != XML_PARSE_CDATA) { + if (retval == XML_PARSE_CDATA) { + strcpy(buf, tmp); + } else { xml_unescape(tmp, buf, len); } return true; diff --git a/lib/parse.h b/lib/parse.h index 340c6aa495..d92b2a1c4b 100644 --- a/lib/parse.h +++ b/lib/parse.h @@ -35,6 +35,7 @@ public: MIOFILE* f; XML_PARSER(MIOFILE*); bool get(char*, int, bool&, char* ab=0, int al=0); + int get_aux(char* buf, int len, char* attr_buf, int attr_len); bool parse_start(const char*); bool parse_str(char*, const char*, char*, int); bool parse_string(char*, const char*, std::string&);