int proto_unregister(char *name) { struct proto *proto; for (proto = proto_head; proto && strcmp(proto->info->name, name); proto = proto->next); if (!proto) return POM_OK; proto_number_unregister(proto); if (proto->info->cleanup && proto->info->cleanup(proto->priv)) { pomlog(POMLOG_ERR "Error while cleaning up the protocol %s", name); return POM_ERR; } if (proto->reg_instance) registry_remove_instance(proto->reg_instance); conntrack_table_cleanup(proto->ct); if (proto->next) proto->next->prev = proto->prev; if (proto->prev) proto->prev->next = proto->next; else proto_head = proto->next; mod_refcount_dec(proto->info->mod); free(proto); return POM_OK; }
int ptype_unregister(char *name) { struct ptype_reg *reg; for (reg = ptype_reg_head; reg && strcmp(reg->info->name, name); reg = reg->next); if (!reg) { pomlog(POMLOG_WARN "Ptype %s is not registered, cannot unregister it.", name); return POM_OK; // Do not return an error so module unloading proceeds } if (reg->prev) reg->prev->next = reg->next; else ptype_reg_head = reg->next; if (reg->next) reg->next->prev = reg->prev; reg->next = NULL; reg->prev = NULL; mod_refcount_dec(reg->module); free(reg); return POM_OK; }
int output_unregister(char *name) { pom_mutex_lock(&output_lock); struct output_reg *tmp; for (tmp = output_reg_head; tmp && strcmp(tmp->reg_info->name, name); tmp = tmp->next); if (!tmp) { pom_mutex_unlock(&output_lock); return POM_OK; } registry_remove_instance_type(output_registry_class, name); if (tmp->prev) tmp->prev->next = tmp->next; else output_reg_head = tmp->next; if (tmp->next) tmp->next->prev = tmp->prev; mod_refcount_dec(tmp->reg_info->mod); free(tmp); pom_mutex_unlock(&output_lock); return POM_OK; }
int input_unregister(char *name) { struct input_reg *reg; for (reg = input_reg_head; reg && strcmp(reg->info->name, name); reg = reg->next); if (!reg) return POM_OK; registry_remove_instance_type(input_registry_class, name); if (reg->prev) reg->prev->next = reg->next; else input_reg_head = reg->next; if (reg->next) reg->next->prev = reg->prev; reg->next = NULL; reg->prev = NULL; mod_refcount_dec(reg->module); free(reg); return POM_OK; }
int decoder_cleanup_all() { while (decoder_reg_head) { struct decoder_reg *tmp = decoder_reg_head; decoder_reg_head = tmp->next; mod_refcount_dec(tmp->info->mod); free(tmp); } return POM_OK; }
int proto_cleanup() { struct proto *proto; for (proto = proto_head; proto; proto = proto->next) { if (proto->info->cleanup && proto->info->cleanup(proto->priv) == POM_ERR) pomlog(POMLOG_WARN "Error while cleaning up protocol %s", proto->info->name); conntrack_table_cleanup(proto->ct); mod_refcount_dec(proto->info->mod); } while (proto_head) { proto = proto_head; proto_head = proto->next; int res = pthread_rwlock_destroy(&proto->listeners_lock); if (res) pomlog(POMLOG_ERR "Error while destroying the listners lock : %s", pom_strerror(res)); res = pthread_rwlock_destroy(&proto->expectation_lock); if (res) pomlog(POMLOG_ERR "Error while destroying the listners lock : %s", pom_strerror(res)); free(proto); } if (proto_registry_class) registry_remove_class(proto_registry_class); proto_registry_class = NULL; while (proto_number_class_head) { struct proto_number_class *cls = proto_number_class_head; proto_number_class_head = cls->next; while (cls->nums) { struct proto_number *num = cls->nums; cls->nums = num->next; free(num); } free(cls->name); free(cls); } return POM_OK; }
int input_cleanup() { if (input_registry_class) registry_remove_class(input_registry_class); input_registry_class = NULL; while (input_reg_head) { struct input_reg *tmp = input_reg_head; input_reg_head = tmp->next; mod_refcount_dec(tmp->info->mod); free(tmp); } return POM_OK; }
int decoder_unregister(char *name) { struct decoder_reg *tmp; for (tmp = decoder_reg_head; tmp && strcmp(tmp->name, name); tmp = tmp->next); if (!tmp) return POM_OK; if (tmp->prev) tmp->prev->next = tmp->next; else decoder_reg_head = tmp->next; if (tmp->next) tmp->next->prev = tmp->prev; mod_refcount_dec(tmp->info->mod); free(tmp); return POM_OK; }
int output_cleanup() { pom_mutex_lock(&output_lock); if (output_registry_class) registry_remove_class(output_registry_class); output_registry_class = NULL; while (output_reg_head) { struct output_reg *tmp = output_reg_head; output_reg_head = tmp->next; mod_refcount_dec(tmp->reg_info->mod); free(tmp); } pom_mutex_unlock(&output_lock); return POM_OK; }