fix initialization bug
This commit is contained in:
parent
5ff162d145
commit
49d46da35e
@ -48,7 +48,7 @@ htbuffer_t *htbuffer_init(unsigned int start_size) {
|
|||||||
b->max_size = DEFAULT_MAX_SIZE;
|
b->max_size = DEFAULT_MAX_SIZE;
|
||||||
|
|
||||||
b->buf = (char*) htmalloc(sizeof(char) * b->current_buf_size);
|
b->buf = (char*) htmalloc(sizeof(char) * b->current_buf_size);
|
||||||
memset(b->buf, 0, start_size);
|
memset(b->buf, 0, b->current_buf_size);
|
||||||
|
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
@ -79,12 +79,15 @@ htbuffer_t *htbuffer_memcpy_w_offset(htbuffer_t *dest, unsigned int offset, cons
|
|||||||
: pos;
|
: pos;
|
||||||
|
|
||||||
if (new_buf_size > dest->max_size) {
|
if (new_buf_size > dest->max_size) {
|
||||||
syslog(LOG_ERR, "htbuffer (%p) htbuffer_strcpy: new size too large %d (max=%d)",
|
syslog(LOG_ERR, "htbuffer (%p) htbuffer_memcpy_w_offset: new size too large %d (max=%d)",
|
||||||
dest, new_buf_size, dest->max_size);
|
dest, new_buf_size, dest->max_size);
|
||||||
exit(154);
|
exit(154);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("htbuffer (%p) htbuffer_memcpy_w_offset: increase buffer from %d to %d\n",
|
||||||
|
dest, dest->current_buf_size, new_buf_size);
|
||||||
dest->buf = (char*) htrealloc(dest->buf, sizeof(char) * new_buf_size);
|
dest->buf = (char*) htrealloc(dest->buf, sizeof(char) * new_buf_size);
|
||||||
|
memset(dest->buf + dest->current_buf_size, 0, new_buf_size - dest->current_buf_size);
|
||||||
dest->current_buf_size = new_buf_size;
|
dest->current_buf_size = new_buf_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@
|
|||||||
#define CFG_NAME_PLUGINS "plugins"
|
#define CFG_NAME_PLUGINS "plugins"
|
||||||
#define CFG_PLUGINS_DELIMITER " "
|
#define CFG_PLUGINS_DELIMITER " "
|
||||||
#define CFG_NAME_OBJ "obj"
|
#define CFG_NAME_OBJ "obj"
|
||||||
|
#define CFG_NAME "name"
|
||||||
|
|
||||||
extern cfg_t *cfg;
|
extern cfg_t *cfg;
|
||||||
|
|
||||||
@ -117,7 +118,7 @@ int containers_dispatcher(container_handle_t *ch, char *input, htbuffer_t *outpu
|
|||||||
syslog(LOG_DEBUG, "dispatcher: class: %s, data: %s", class, data);
|
syslog(LOG_DEBUG, "dispatcher: class: %s, data: %s", class, data);
|
||||||
|
|
||||||
for (classes = classes_root.next; classes != NULL; classes = classes->next) {
|
for (classes = classes_root.next; classes != NULL; classes = classes->next) {
|
||||||
if (0 == strcmp(class, classes->descr->name)) {
|
if (0 == strcmp(class, classes->alias)) {
|
||||||
syslog(LOG_DEBUG, "dispatcher: yes, we support it, it's id=%d", classes->id);
|
syslog(LOG_DEBUG, "dispatcher: yes, we support it, it's id=%d", classes->id);
|
||||||
for (wh = ch->worker_handle_root.next, wh_last = &ch->worker_handle_root, wh2 = NULL;
|
for (wh = ch->worker_handle_root.next, wh_last = &ch->worker_handle_root, wh2 = NULL;
|
||||||
wh != NULL;
|
wh != NULL;
|
||||||
@ -158,15 +159,15 @@ int containers_dispatcher(container_handle_t *ch, char *input, htbuffer_t *outpu
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int register_class(int id, class_descriptor_t *class_descriptor) {
|
static int register_class(int id, class_descriptor_t *class_descriptor, char *alias) {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
cfgl_t *c;
|
cfgl_t *c;
|
||||||
classes_t *w;
|
classes_t *w;
|
||||||
|
|
||||||
|
|
||||||
syslog(LOG_DEBUG, "register_class: registering class %s", class_descriptor->name);
|
syslog(LOG_DEBUG, "register_class: registering class %s, alias %s", class_descriptor->name, alias);
|
||||||
|
|
||||||
c = findcfgsection(cfg, class_descriptor->name);
|
c = findcfgsection(cfg, alias);
|
||||||
if (NULL == c) {
|
if (NULL == c) {
|
||||||
syslog(LOG_ERR, "register_class: no configuration section for this plugin available");
|
syslog(LOG_ERR, "register_class: no configuration section for this plugin available");
|
||||||
return -1;
|
return -1;
|
||||||
@ -190,6 +191,7 @@ static int register_class(int id, class_descriptor_t *class_descriptor) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
w->descr = class_descriptor;
|
w->descr = class_descriptor;
|
||||||
|
w->alias = alias;
|
||||||
w->id = id;
|
w->id = id;
|
||||||
w->next = NULL;
|
w->next = NULL;
|
||||||
|
|
||||||
@ -235,7 +237,7 @@ int register_all() {
|
|||||||
int register_worker(char *worker_name) {
|
int register_worker(char *worker_name) {
|
||||||
void *dl_handle;
|
void *dl_handle;
|
||||||
class_descriptor_t * class_descriptor;
|
class_descriptor_t * class_descriptor;
|
||||||
char *cfg_plugin_dir, *cfg_plugins, *cfg_plugin, *cfg_obj;
|
char *cfg_plugin_dir, *cfg_plugins, *cfg_plugin, *cfg_obj, *cfg_plugin_name;
|
||||||
char *obj_name;
|
char *obj_name;
|
||||||
const char *err_msg;
|
const char *err_msg;
|
||||||
int err;
|
int err;
|
||||||
@ -277,14 +279,16 @@ int register_worker(char *worker_name) {
|
|||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
free(obj_name);
|
free(obj_name);
|
||||||
|
|
||||||
class_descriptor = (class_descriptor_t*) dlsym(dl_handle, cfg_plugin);
|
cfg_plugin_name = findcfg(cfg, cfg_plugin, CFG_NAME);
|
||||||
|
cfg_plugin_name = cfg_plugin_name ? cfg_plugin_name : cfg_plugin;
|
||||||
|
class_descriptor = (class_descriptor_t*) dlsym(dl_handle, cfg_plugin_name);
|
||||||
if (NULL != (err_msg = dlerror())) {
|
if (NULL != (err_msg = dlerror())) {
|
||||||
syslog(LOG_ERR, "register_all: plugin %s not found, error %s", cfg_plugin, err_msg);
|
syslog(LOG_ERR, "register_all: plugin %s not found, error %s", cfg_plugin, err_msg);
|
||||||
return -5;
|
return -5;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = register_class(id++, class_descriptor);
|
err = register_class(id++, class_descriptor, cfg_plugin);
|
||||||
if (0 != err) {
|
if (0 != err) {
|
||||||
syslog(LOG_ERR, "register_all: unable to initialize plugin %s, error %d", cfg_plugin, err);
|
syslog(LOG_ERR, "register_all: unable to initialize plugin %s, error %d", cfg_plugin, err);
|
||||||
return -6;
|
return -6;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user