Changeset: ffff74ab8db6 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ffff74ab8db6 Modified Files: tools/merovingian/daemon/forkmserver.c tools/merovingian/utils/properties.c tools/merovingian/utils/properties.h tools/merovingian/utils/utils.c tools/merovingian/utils/utils.h Branch: Oct2014 Log Message:
backout, merovingian changes Unterschiede (gekürzt von 316 auf 300 Zeilen): diff --git a/tools/merovingian/daemon/forkmserver.c b/tools/merovingian/daemon/forkmserver.c --- a/tools/merovingian/daemon/forkmserver.c +++ b/tools/merovingian/daemon/forkmserver.c @@ -63,7 +63,7 @@ forkMserver(char *database, sabdb** stat char upmin[8]; char upavg[8]; char upmax[8]; - confkeyval *ckv, *kv, *list; + confkeyval *ckv, *kv; SABdbState state; er = msab_getStatus(stats, database); @@ -113,7 +113,7 @@ forkMserver(char *database, sabdb** stat } ckv = getDefaultProps(); - readAllProps(ckv, (*stats)->path); + readProps(ckv, (*stats)->path); kv = findConfKey(ckv, "type"); if (kv->val == NULL) kv = findConfKey(_mero_db_props, "type"); @@ -280,8 +280,7 @@ forkMserver(char *database, sabdb** stat char nclients[24]; char pipeline[512]; char *readonly = NULL; - char *argv[512]; /* for the exec arguments */ - char property_other[1024]; + char *argv[24]; /* for the exec arguments */ int c = 0; unsigned int mport; @@ -324,6 +323,9 @@ forkMserver(char *database, sabdb** stat if (kv->val != NULL && strcmp(kv->val, "no") != 0) readonly = "--readonly"; + freeConfFile(ckv); + free(ckv); /* can make ckv static and reuse it all the time */ + /* redirect stdout and stderr to a new pair of fds for * logging help */ close(pfdo[0]); @@ -388,25 +390,10 @@ forkMserver(char *database, sabdb** stat if (readonly != NULL) { argv[c++] = readonly; } - /* get the rest (non-default) mserver props set in the conf file */ - list = ckv; - while (list->key != NULL) { - if (list->val != NULL && !defaultProperty(list->key)) { - argv[c++] = "--set"; - snprintf(property_other, sizeof(property_other), "%s=%s", list->key, list->val); - argv[c++] = property_other; - } - list++; - } - /* keep this one last for easy copy/paste with gdb */ argv[c++] = "--set"; argv[c++] = "monet_daemon=yes"; - argv[c++] = NULL; - freeConfFile(ckv); - free(ckv); /* can make ckv static and reuse it all the time */ - fprintf(stdout, "arguments:"); for (c = 0; argv[c] != NULL; c++) { /* very stupid heuristic to make copy/paste easier from diff --git a/tools/merovingian/utils/properties.c b/tools/merovingian/utils/properties.c --- a/tools/merovingian/utils/properties.c +++ b/tools/merovingian/utils/properties.c @@ -34,7 +34,7 @@ "# This file is used by monetdbd\n\n" /* these are the properties used for starting an mserver */ -static confkeyval _internal_prop_keys[50] = { +static confkeyval _internal_prop_keys[] = { {"type", NULL, 0, STR}, {"shared", NULL, 0, STR}, {"nthreads", NULL, 0, INT}, @@ -62,7 +62,7 @@ getDefaultProps(void) /** * Writes the given key-value list to MEROPROPFILE in the given path. - * Returns 0 when the properties could be successfully written to the file. + * Returns 0 when the properties could be written to the file. */ inline int writeProps(confkeyval *ckv, const char *path) @@ -88,30 +88,6 @@ writeProps(confkeyval *ckv, const char * } /** - * Appends additional (non-default) property MEROPROPFILE in the given path. - * Returns 0 when the property could be successfully appended to the file. - */ -static inline int -appendProp(confkeyval *ckv, const char *path) -{ - char file[1024]; - FILE *cnf; - - snprintf(file, 1024, "%s/" MEROPROPFILE, path); - if ((cnf = fopen(file, "a")) == NULL) - return(1); - - if (ckv->key != NULL && ckv->val != NULL) { - fprintf(cnf, "%s=%s\n", ckv->key, ckv->val); - } - - fflush(cnf); - fclose(cnf); - - return(0); -} - -/** * Writes the given key-value list to a buffer and sets its pointer to * buf. This function deals with the allocation of the buffer, hence * the caller should free it. @@ -161,25 +137,6 @@ readProps(confkeyval *ckv, const char *p } /** - * Read all properties from a property file. - * Returns 0 when reading the property file succeeded. - */ -inline int -readAllProps(confkeyval *ckv, const char *path) -{ - char file[1024]; - FILE *cnf; - - snprintf(file, 1024, "%s/" MEROPROPFILE, path); - if ((cnf = fopen(file, "r")) != NULL) { - readConfFileFull(ckv, cnf); - fclose(cnf); - return(0); - } - return(1); -} - -/** * Read properties from buf, filling in the requested key-values. */ inline void @@ -217,8 +174,15 @@ setProp(char *path, char *key, char *val readProps(props, path); kv = findConfKey(props, key); - if (kv != NULL && (err = setConfVal(kv, val)) != NULL) { - /* first just attempt to set the value (type-check) in memory */ + if (kv == NULL) { + snprintf(buf, sizeof(buf), "no such property: %s", key); + freeConfFile(props); + free(props); + return(strdup(buf)); + } + + /* first just attempt to set the value (type-check) in memory */ + if ((err = setConfVal(kv, val)) != NULL) { freeConfFile(props); free(props); return(err); @@ -261,24 +225,10 @@ setProp(char *path, char *key, char *val value++; } } - - /* ok, if we've reached this point we can write this stuff out! */ - /* Let's check if this was a default property of an additional one. - * Non-default properties will have a NULL kv */ - if (kv == NULL) { - confkeyval *addProperty = (struct _confkeyval *) malloc(sizeof(struct _confkeyval)); - addProperty->key = strdup(key); - addProperty->val = strdup(val); - addProperty->ival = 0; - addProperty->type = STR; - - appendProp(addProperty, path); - free(addProperty); - } else { - writeProps(props, path); - } } + /* ok, if we've reached this point we can write this stuff out! */ + writeProps(props, path); freeConfFile(props); free(props); diff --git a/tools/merovingian/utils/properties.h b/tools/merovingian/utils/properties.h --- a/tools/merovingian/utils/properties.h +++ b/tools/merovingian/utils/properties.h @@ -28,7 +28,6 @@ confkeyval *getDefaultProps(void); int writeProps(confkeyval *ckv, const char *path); void writePropsBuf(confkeyval *ckv, char **buf); int readProps(confkeyval *ckv, const char *path); -int readAllProps(confkeyval *ckv, const char *path); void readPropsBuf(confkeyval *ckv, char *buf); char *setProp(char *path, char *key, char *val); diff --git a/tools/merovingian/utils/utils.c b/tools/merovingian/utils/utils.c --- a/tools/merovingian/utils/utils.c +++ b/tools/merovingian/utils/utils.c @@ -72,45 +72,6 @@ readConfFile(confkeyval *list, FILE *cnf } /** - * Parses the given file stream matching the and writes all values to the list. - */ -void -readConfFileFull(confkeyval *list, FILE *cnf) { - char buf[1024]; - char *key, *val; - char *separator = "="; - char *err; - confkeyval *t = list; - - /* iterate until the end of the array */ - while (list->key != NULL) { - list++; - } - /* read the file a line at a time */ - while (fgets(buf, sizeof(buf), cnf) != NULL) { - if (strlen(buf) > 1 && buf[0] != '#') { - /* tokenize */ - key = strtok(buf, separator); - val = strtok(NULL, separator); - /* strip trailing newline */ - val = strtok(val, "\n"); - /* check if it is default property or not. those are set in a special way */ - if (defaultProperty(key)) { - if ((err = setConfValForKey(t, key, val)) != NULL) { - free(err); /* ignore, just fall back to default */ - } - } else { - list->key = strdup(key); - list->val = strdup(val); - list->ival = 0; - list->type = STR; - list++; - } - } - } -} - -/** * Frees the values allocated by readConfFile(). */ inline void @@ -125,27 +86,6 @@ freeConfFile(confkeyval *list) { } /** - * True if the key is not a default property. - */ -inline int -defaultProperty(char *property) { - if (property != NULL && strcmp(property, "type") == 0) { - return 1; - } else if (property != NULL && strcmp(property, "shared") == 0) { - return 1; - } else if (property != NULL && strcmp(property, "nthreads") == 0) { - return 1; - } else if (property != NULL && strcmp(property, "readonly") == 0) { - return 1; - } else if (property != NULL && strcmp(property, "nclients") == 0) { - return 1; - } else if (property != NULL && strcmp(property, "mfunnel") == 0) { - return 1; - } - return 0; -} - -/** * Returns a pointer to the key-value that has a matching key with the * given key, or NULL if no key was found. */ @@ -278,19 +218,6 @@ setConfVal(confkeyval *ckv, char *val) { return(NULL); } -char * -setConfValForKey(confkeyval *list, char *key, char *val) { - while (list->key != NULL) { - if (strcmp(list->key, key) == 0) { - return setConfVal(list, val); - } - list++; - } - char buf[256]; - snprintf(buf, sizeof(buf), "key '%s' is not recognized, internal error", key); - return(strdup(buf)); -} - /** * Fills the array pointed to by buf with a human representation of t. * The argument longness represents the number of units to print diff --git a/tools/merovingian/utils/utils.h b/tools/merovingian/utils/utils.h --- a/tools/merovingian/utils/utils.h _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list