#include "command.h"
#include "json.h"
#include "linklist.h"
+#include "frr_pthread.h"
DEFINE_MTYPE_STATIC(LIB, ERRINFO, "error information")
{
uint32_t i = 0;
- pthread_mutex_lock(&refs_mtx);
- {
+ frr_with_mutex(&refs_mtx) {
while (ref[i].code != END_FERR) {
hash_get(refs, &ref[i], hash_alloc_intern);
i++;
}
}
- pthread_mutex_unlock(&refs_mtx);
}
struct log_ref *log_ref_get(uint32_t code)
struct log_ref *ref;
holder.code = code;
- pthread_mutex_lock(&refs_mtx);
- {
+ frr_with_mutex(&refs_mtx) {
ref = hash_lookup(refs, &holder);
}
- pthread_mutex_unlock(&refs_mtx);
return ref;
}
if (json)
top = json_object_new_object();
- pthread_mutex_lock(&refs_mtx);
- {
+ frr_with_mutex(&refs_mtx) {
errlist = code ? list_new() : hash_to_list(refs);
}
- pthread_mutex_unlock(&refs_mtx);
if (code) {
ref = log_ref_get(code);
DEFUN_NOSH(show_error_code,
show_error_code_cmd,
- "show error <(1-4294967296)|all> [json]",
+ "show error <(1-4294967295)|all> [json]",
SHOW_STR
"Information on errors\n"
"Error code to get info about\n"
void log_ref_init(void)
{
- pthread_mutex_lock(&refs_mtx);
- {
+ frr_with_mutex(&refs_mtx) {
refs = hash_create(ferr_hash_key, ferr_hash_cmp,
"Error Reference Texts");
}
- pthread_mutex_unlock(&refs_mtx);
}
void log_ref_fini(void)
{
- pthread_mutex_lock(&refs_mtx);
- {
+ frr_with_mutex(&refs_mtx) {
hash_clean(refs, NULL);
hash_free(refs);
refs = NULL;
}
- pthread_mutex_unlock(&refs_mtx);
}
void log_ref_vty_init(void)