Added failure codes for proc_table_add()

This commit is contained in:
Nikos Mavrogiannopoulos
2015-02-10 18:36:40 +01:00
parent 85483e98e8
commit 0d999f5424
3 changed files with 10 additions and 7 deletions

View File

@@ -275,7 +275,10 @@ struct proc_st *old_proc;
memcpy(proc->ipv4_seed, &cmsg->ipv4_seed, sizeof(proc->ipv4_seed));
/* add the links to proc hash */
proc_table_add(s, proc);
if (proc_table_add(s, proc) < 0) {
mslog(s, proc, LOG_ERR, "failed to add proc hashes");
return -1;
}
return 0;
}

View File

@@ -83,29 +83,29 @@ void proc_table_deinit(main_server_st *s)
talloc_free(s->proc_table.db_sid);
}
void proc_table_add(main_server_st *s, struct proc_st *proc)
int proc_table_add(main_server_st *s, struct proc_st *proc)
{
size_t ip_hash = rehash_ip(proc, NULL);
size_t dtls_id_hash = rehash_dtls_id(proc, NULL);
if (htable_add(s->proc_table.db_ip, ip_hash, proc) == 0) {
return;
return -1;
}
if (htable_add(s->proc_table.db_dtls_id, dtls_id_hash, proc) == 0) {
htable_del(s->proc_table.db_ip, ip_hash, proc);
return;
return -1;
}
if (htable_add(s->proc_table.db_sid, rehash_sid(proc, NULL), proc) == 0) {
htable_del(s->proc_table.db_ip, ip_hash, proc);
htable_del(s->proc_table.db_dtls_id, dtls_id_hash, proc);
return;
return -1;
}
s->proc_table.total++;
return;
return 0;
}
void proc_table_del(main_server_st *s, struct proc_st *proc)

View File

@@ -36,7 +36,7 @@ struct proc_st *proc_search_sid(struct main_server_st *s,
void proc_table_init(main_server_st *s);
void proc_table_deinit(main_server_st *s);
void proc_table_add(main_server_st *s, struct proc_st *proc);
int proc_table_add(main_server_st *s, struct proc_st *proc);
void proc_table_del(main_server_st *s, struct proc_st *proc);
#endif