RThreadRepository<Thread, T>::RThreadRepository(int w) : Parent(curr::type<RThreadRepository<Thread, T>>::name(), 100 // the value is ignored for std::map ), wait_m(w) { // Disable signals. See RSignalRepository sigset_t ss; rCheck(::sigfillset(&ss) == 0); // enable SIGINT, ^C is useful rCheck(::sigdelset(&ss, SIGINT) == 0); rCheck(::pthread_sigmask(SIG_SETMASK, &ss, NULL) == 0); this->log_params().get_object_by_id = false; this->complete_construction(); }
void tagStormCheck(char *schemaFile, char *tagStormFile) /* tagStormCheck - Check that a tagStorm conforms to a schema.. */ { /* Load up schema from file. Make a hash of all non-wildcard * tags, and a list of wildcard tags. */ struct tagSchema *schema, *schemaList = tagSchemaFromFile(schemaFile); struct slRef *wildSchemaList = NULL, *requiredSchemaList = NULL; /* Split up schemaList into hash and wildSchemaList. Calculate schemaSize */ struct hash *hash = hashNew(0); int schemaSize = 0; for (schema = schemaList; schema != NULL; schema = schema->next) { ++schemaSize; if (anyWild(schema->name)) { refAdd(&wildSchemaList, schema); } else hashAdd(hash, schema->name, schema); if (schema->required != 0) refAdd(&requiredSchemaList, schema); } slReverse(&wildSchemaList); schemaList = NULL; struct tagStorm *tagStorm = tagStormFromFile(tagStormFile); struct dyString *scratch = dyStringNew(0); rCheck(tagStorm->forest, tagStormFile, wildSchemaList, hash, requiredSchemaList, scratch); if (gErrCount > 0) noWarnAbort(); else verbose(1, "No problems detected.\n"); }
static void rCheck(struct tagStanza *stanzaList, char *fileName, struct slRef *wildList, struct hash *hash, struct slRef *requiredList, struct dyString *scratch) /* Recurse through tagStorm */ { struct tagStanza *stanza; struct dyString *csvScratch = dyStringNew(0); for (stanza = stanzaList; stanza != NULL; stanza = stanza->next) { struct slPair *pair; for (pair = stanza->tagList; pair != NULL; pair = pair->next) { /* Break out tag and value */ char *tag = tagSchemaFigureArrayName(pair->name, scratch); char *val = pair->val; /* Make sure val exists and is non-empty */ if (isEmpty(val)) { reportError(fileName, stanza->startLineIx, "%s tag has no value", tag); continue; } /* Check against SQL reserved words */ if (gReservedHash != NULL) { if (sqlReservedCheck(gReservedHash, tag)) { reportError(fileName, stanza->startLineIx, "%s in tag name is a SQL reserved word", tag); continue; } } /* Find schema in hash or wildSchemaList */ struct tagSchema *schema = hashFindVal(hash, tag); if (schema == NULL) { struct slRef *ref; for (ref = wildList; ref != NULL; ref = ref->next) { struct tagSchema *s = ref->val; if (wildMatch(s->name, tag)) { schema = s; break; } } } /* Do checking on tag */ if (schema == NULL) reportError(fileName, stanza->startLineIx, "Unrecognized tag %s", tag); else { char type = schema->type; char *pos = val; char *oneVal; while ((oneVal =csvParseNext(&pos, csvScratch)) != NULL) { if (type == '#') { char *end; long long v = strtoll(oneVal, &end, 10); if (end == oneVal || *end != 0) // oneVal is not integer reportError(fileName, stanza->startLineIx, "Non-integer value %s for %s", oneVal, tag); else if (v < schema->minVal) reportError(fileName, stanza->startLineIx, "Value %s too low for %s", oneVal, tag); else if (v > schema->maxVal) reportError(fileName, stanza->startLineIx, "Value %s too high for %s", oneVal, tag); } else if (type == '%') { char *end; double v = strtod(oneVal, &end); if (end == oneVal || *end != 0) // val is not just a floating point number reportError(fileName, stanza->startLineIx, "Non-numerical value %s for %s", oneVal, tag); else if (v < schema->minVal) reportError(fileName, stanza->startLineIx, "Value %s too low for %s", oneVal, tag); else if (v > schema->maxVal) reportError(fileName, stanza->startLineIx, "Value %s too high for %s", oneVal, tag); } else { boolean gotMatch = FALSE; struct slName *okVal; for (okVal = schema->allowedVals; okVal != NULL; okVal = okVal->next) { if (wildMatch(okVal->name, oneVal)) { gotMatch = TRUE; break; } } if (!gotMatch) reportError(fileName, stanza->startLineIx, "Unrecognized value '%s' for tag %s", oneVal, tag); } struct hash *uniqHash = schema->uniqHash; if (uniqHash != NULL) { if (hashLookup(uniqHash, oneVal)) reportError(fileName, stanza->startLineIx, "Non-unique value '%s' for tag %s", oneVal, tag); else hashAdd(uniqHash, oneVal, NULL); } } } } if (stanza->children) { rCheck(stanza->children, fileName, wildList, hash, requiredList, scratch); } else { struct slRef *ref; for (ref = requiredList; ref != NULL; ref = ref->next) { struct tagSchema *schema = ref->val; if (schema->objArrayPieces != NULL) // It's an array, complex to handle, needs own routine { checkInAllArrayItems(fileName, stanza, schema, scratch); } else { if (tagFindVal(stanza, schema->name) == NULL) reportError(fileName, stanza->startLineIx, "Missing required '%s' tag", schema->name); } } } } dyStringFree(&csvScratch); }