- struct aim_snac_t *cur;
-
- if (cur == NULL)
- return(NULL);
-
- printf("faim: snac: searching for %08lx to remove\n", id);
-
- cur = sess->outstanding_snacs;
-
- if (cur->id == id) {
- sess->outstanding_snacs = cur->next;
- return(cur);
- }
- while (cur->next != NULL) {
- if (cur->next->id == id) {
- struct aim_snac_t *tmp = NULL;
-
- tmp = cur->next;
- cur->next = cur->next->next;
- return(tmp);
+ struct aim_snac_t *cur = NULL;
+ int index;
+
+ index = id % FAIM_SNAC_HASH_SIZE;
+
+ faim_mutex_lock(&sess->snac_hash_locks[index]);
+ if (!sess->snac_hash[index])
+ ;
+ else if (sess->snac_hash[index]->id == id) {
+ cur = sess->snac_hash[index];
+ sess->snac_hash[index] = cur->next;
+ } else {
+ cur = sess->snac_hash[index];
+ while (cur->next) {
+ if (cur->next->id == id) {
+ struct aim_snac_t *tmp;
+
+ tmp = cur->next;
+ cur->next = cur->next->next;
+ cur = tmp;
+ break;
+ }
+ cur = cur->next;