From: Francesco Chemolli Date: Mon, 23 Jul 2012 07:02:06 +0000 (+0200) Subject: Merged from trunk X-Git-Tag: sourceformat-review-1~164^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=133c3ad634208df944eb0c5921bc23436d29ae9d;p=thirdparty%2Fsquid.git Merged from trunk --- 133c3ad634208df944eb0c5921bc23436d29ae9d diff --cc src/cf_gen.cc index fc82fb200c,e46fecaac7..5fdc4ad396 --- a/src/cf_gen.cc +++ b/src/cf_gen.cc @@@ -327,9 -306,82 +306,82 @@@ main(int argc, char *argv[] exit(1); } - curr.loc = ptr; - } else if (!strncmp(buff, "TYPE:", 5)) { - if ((ptr = strtok(buff + 5, WS)) == NULL) { + break; + + case s1: { + Entry &curr = entries.back(); + + if ((strlen(buff) == 0) || (!strncmp(buff, "#", 1))) { + /* ignore empty and comment lines */ + (void) 0; + } else if (!strncmp(buff, "COMMENT:", 8)) { + ptr = buff + 8; + + while (isspace((unsigned char)*ptr)) - ptr++; ++ ++ptr; + + curr.comment = ptr; + } else if (!strncmp(buff, "DEFAULT:", 8)) { + ptr = buff + 8; + + while (isspace((unsigned char)*ptr)) - ptr++; ++ ++ptr; + + curr.defaults.preset.push_back(ptr); + } else if (!strncmp(buff, "DEFAULT_IF_NONE:", 16)) { + ptr = buff + 16; + + while (isspace((unsigned char)*ptr)) - ptr++; ++ ++ptr; + + curr.defaults.if_none.push_back(ptr); + } else if (!strncmp(buff, "POSTSCRIPTUM:", 13)) { + ptr = buff + 13; + + while (isspace((unsigned char)*ptr)) - ptr++; ++ ++ptr; + + curr.defaults.postscriptum.push_back(ptr); + } else if (!strncmp(buff, "DEFAULT_DOC:", 12)) { + ptr = buff + 12; + + while (isspace((unsigned char)*ptr)) - ptr++; ++ ++ptr; + + curr.defaults.docs.push_back(ptr); + } else if (!strncmp(buff, "LOC:", 4)) { + if ((ptr = strtok(buff + 4, WS)) == NULL) { + std::cerr << "Error on line " << linenum << std::endl; + exit(1); + } + + curr.loc = ptr; + } else if (!strncmp(buff, "TYPE:", 5)) { + if ((ptr = strtok(buff + 5, WS)) == NULL) { + std::cerr << "Error on line " << linenum << std::endl; + exit(1); + } + + /* hack to support arrays, rather than pointers */ + if (0 == strcmp(ptr + strlen(ptr) - 2, "[]")) { + curr.array_flag = 1; + *(ptr + strlen(ptr) - 2) = '\0'; + } + + checkDepend(curr.name, ptr, types, entries); + curr.type = ptr; + } else if (!strncmp(buff, "IFDEF:", 6)) { + if ((ptr = strtok(buff + 6, WS)) == NULL) { + std::cerr << "Error on line " << linenum << std::endl; + exit(1); + } + + curr.ifdef = ptr; + } else if (!strcmp(buff, "DOC_START")) { + state = sDOC; + } else if (!strcmp(buff, "DOC_NONE")) { + state = sSTART; + } else { std::cerr << "Error on line " << linenum << std::endl; exit(1); } diff --cc src/format/Token.cc index 522914328b,c273a4f269..087a526ee1 --- a/src/format/Token.cc +++ b/src/format/Token.cc @@@ -207,10 -217,10 +217,10 @@@ Format::Token::Init( /// Scans a token table to see if the next token exists there /// returns a pointer to next unparsed byte and updates type member if found - char * - Format::Token::scanForToken(TokenTableEntry const table[], char *cur) + const char * + Format::Token::scanForToken(TokenTableEntry const table[], const char *cur) { - for (TokenTableEntry const *lte = table; lte->configTag != NULL; lte++) { + for (TokenTableEntry const *lte = table; lte->configTag != NULL; ++lte) { debugs(46, 8, HERE << "compare tokens '" << lte->configTag << "' with '" << cur << "'"); if (strncmp(lte->configTag, cur, strlen(lte->configTag)) == 0) { type = lte->tokenType; @@@ -315,14 -325,19 +325,19 @@@ Format::Token::parse(const char *def, Q if (*cur == '0') { zero = 1; - cur++; + ++cur; } - if (xisdigit(*cur)) - widthMin = strtol(cur, &cur, 10); + char *endp; + if (xisdigit(*cur)) { + widthMin = strtol(cur, &endp, 10); + cur = endp; + } - if (*cur == '.' && xisdigit(*(++cur))) - widthMax = strtol(cur, &cur, 10); + if (*cur == '.' && xisdigit(*(++cur))) { + widthMax = strtol(cur, &endp, 10); + cur = endp; + } if (*cur == '{') { char *cp; diff --cc src/forward.cc index 9325c3d3eb,ee61916350..ccfab97e81 --- a/src/forward.cc +++ b/src/forward.cc @@@ -891,11 -996,12 +996,12 @@@ FwdState::connectStart( // if we found an open persistent connection to use. use it. if (openedPconn) { serverConn = temp; + flags.connected_okay = true; debugs(17, 3, HERE << "reusing pconn " << serverConnection()); - n_tries++; + ++n_tries; if (!serverConnection()->getPeer()) - origin_tries++; + ++origin_tries; comm_add_close_handler(serverConnection()->fd, fwdServerClosedWrapper, this); @@@ -991,8 -1097,18 +1097,18 @@@ FwdState::dispatch( } #endif + #if USE_SSL + if (request->flags.sslPeek) { + CallJobHere1(17, 4, request->clientConnectionManager, ConnStateData, + ConnStateData::httpsPeeked, serverConnection()); + unregister(serverConn); // async call owns it now + complete(); // destroys us + return; + } + #endif + if (serverConnection()->getPeer() != NULL) { - serverConnection()->getPeer()->stats.fetches++; + ++ serverConnection()->getPeer()->stats.fetches; request->peer_login = serverConnection()->getPeer()->login; request->peer_domain = serverConnection()->getPeer()->domain; httpStart(this); diff --cc src/fs/ufs/ufscommon.cc index b329f96cc6,821806fa0a..c4af21183a --- a/src/fs/ufs/ufscommon.cc +++ b/src/fs/ufs/ufscommon.cc @@@ -567,27 -567,9 +567,9 @@@ RebuildState::rebuildFromSwapLog( currentEntry (Store::Root().get(swapData.key)); if (currentEntry() != NULL && swapData.lastref >= e->lastref) { - /* - * Make sure we don't unlink the file, it might be - * in use by a subsequent entry. Also note that - * we don't have to subtract from cur_size because - * adding to cur_size happens in the cleanup procedure. - */ - currentEntry()->expireNow(); - currentEntry()->releaseRequest(); - - if (currentEntry()->swap_filen > -1) { - UFSSwapDir *sdForThisEntry = dynamic_cast(INDEXSD(currentEntry()->swap_dirn)); - assert (sdForThisEntry); - sdForThisEntry->replacementRemove(currentEntry()); - sdForThisEntry->mapBitReset(currentEntry()->swap_filen); - currentEntry()->swap_filen = -1; - currentEntry()->swap_dirn = -1; - } - - currentEntry()->release(); + undoAdd(); - counts.objcount--; - counts.cancelcount++; + --counts.objcount; + ++counts.cancelcount; } return; } else { @@@ -682,20 -664,9 +664,9 @@@ } else if (currentEntry()) { /* key already exists, this swapfile not being used */ /* junk old, load new */ - currentEntry()->expireNow(); - currentEntry()->releaseRequest(); - - if (currentEntry()->swap_filen > -1) { - UFSSwapDir *sdForThisEntry = dynamic_cast(INDEXSD(currentEntry()->swap_dirn)); - sdForThisEntry->replacementRemove(currentEntry()); - /* Make sure we don't actually unlink the file */ - sdForThisEntry->mapBitReset(currentEntry()->swap_filen); - currentEntry()->swap_filen = -1; - currentEntry()->swap_dirn = -1; - } - - currentEntry()->release(); + undoAdd(); - counts.objcount--; - counts.dupcount++; ++ --counts.objcount; + ++counts.dupcount; } else { /* URL doesnt exist, swapfile not in use */ /* load new */ diff --cc src/ssl/ErrorDetail.cc index 8bf515f75b,c02c5dde52..4b6cc06d15 --- a/src/ssl/ErrorDetail.cc +++ b/src/ssl/ErrorDetail.cc @@@ -96,10 -137,16 +137,17 @@@ static void loadSslErrorMap( } } + static void loadSslErrorShortcutsMap() + { + assert(TheSslErrorShortcuts.empty()); + for (int i = 0; TheSslErrorShortcutsArray[i].name; i++) + TheSslErrorShortcuts[TheSslErrorShortcutsArray[i].name] = TheSslErrorShortcutsArray[i].errors; + } + Ssl::ssl_error_t Ssl::GetErrorCode(const char *name) { - for (int i = 0; TheSslErrorArray[i].name != NULL; i++) { + //TODO: use a std::map? + for (int i = 0; TheSslErrorArray[i].name != NULL; ++i) { if (strcmp(name, TheSslErrorArray[i].name) == 0) return TheSslErrorArray[i].value; } diff --cc src/store_rebuild.cc index 509f5ae71b,3f49a355a0..8d35bc4059 --- a/src/store_rebuild.cc +++ b/src/store_rebuild.cc @@@ -109,11 -110,15 +110,15 @@@ storeCleanup(void *datanotused debugs(20, 1, " Completed Validation Procedure"); debugs(20, 1, " Validated " << validated << " Entries"); debugs(20, 1, " store_swap_size = " << Store::Root().currentSize() / 1024.0 << " KB"); - StoreController::store_dirs_rebuilding--; + --StoreController::store_dirs_rebuilding; assert(0 == StoreController::store_dirs_rebuilding); - if (opt_store_doublecheck) - assert(store_errors == 0); + if (opt_store_doublecheck && store_errors) { + fatalf("Quitting after finding %d cache index inconsistencies. " \ + "Removing cache index will force its slow rebuild. " \ + "Removing -S will let Squid start with an inconsistent " \ + "cache index (at your own risk).\n", store_errors); + } if (store_digest) storeDigestNoteStoreReady();