aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/main.c b/main.c
index 497f66e..77237bf 100644
--- a/main.c
+++ b/main.c
@@ -58,29 +58,19 @@ static void delete_conn_data(int fd){
debug("Deleting conn_data for fd=%d",fd);
struct hash_item *item=conn_hash[fd%CONN_HASH_SIZE];
assert(item);
- if(item->cd.fd==fd){
- if(item->cd.userid!=-1){
- userdata_unregister(item->cd.userid,fd);
- broadcast_online_change(item->cd.userid);
- }
- conn_hash[fd%CONN_HASH_SIZE]=item->next;
- conn_data_nullify(&item->cd);
- free(item);
- return;
- }
struct hash_item *parent=NULL;
while(item&&item->cd.fd!=fd){
parent=item;
item=item->next;
}
- assert(parent);
assert(item);
if(item->cd.userid!=-1){
userdata_unregister(item->cd.userid,fd);
broadcast_online_change(item->cd.userid);
}
conn_data_nullify(&item->cd);
- parent->next=item->next;
+ if(parent)parent->next=item->next;
+ else conn_hash[fd%CONN_HASH_SIZE]=item->next;
free(item);
}