implemented attributes in mongodb imperial monitor

This commit is contained in:
Unbit
2014-05-16 05:35:15 +02:00
parent ef8d9d6145
commit 4d6daded29
2 changed files with 11 additions and 5 deletions
-3
View File
@@ -817,7 +817,6 @@ void emperor_del(struct uwsgi_instance *c_ui) {
while(attr) {
struct uwsgi_dyn_dict *tmp = attr;
attr = attr->next;
if (tmp->key) free(tmp->key);
if (tmp->value) free(tmp->value);
free(tmp);
}
@@ -2437,7 +2436,6 @@ void uwsgi_emperor_simple_do_with_attrs(struct uwsgi_emperor_scanner *ues, char
while(attr) {
struct uwsgi_dyn_dict *tmp = attr;
attr = attr->next;
if (tmp->key) free(tmp->key);
if (tmp->value) free(tmp->value);
free(tmp);
}
@@ -2450,7 +2448,6 @@ void uwsgi_emperor_simple_do_with_attrs(struct uwsgi_emperor_scanner *ues, char
while(attr) {
struct uwsgi_dyn_dict *tmp = attr;
attr = attr->next;
if (tmp->key) free(tmp->key);
if (tmp->value) free(tmp->value);
free(tmp);
}
+11 -2
View File
@@ -77,8 +77,17 @@ extern "C" void uwsgi_imperial_monitor_mongodb(struct uwsgi_emperor_scanner *ues
if (strlen(socket_name) == 0) socket_name = NULL;
struct uwsgi_dyn_dict *attrs = NULL;
char *attr_key = NULL;
char *attr_value = NULL;
struct uwsgi_string_list *e_attrs = uwsgi.emperor_collect_attributes;
while(e_attrs) {
const char *attr_value = p.getStringField(e_attrs->value);
if (strlen(attr_value) == 0) attr_value = NULL;
if (attr_value) {
// the value memory is always reallocated
char *value = uwsgi_str((char *)attr_value);
uwsgi_dyn_dict_new(&attrs, e_attrs->value, e_attrs->len, value, strlen(value));
}
e_attrs = NULL;
}
if (attrs) {
// attrs will be freed in case of error