Changeset 1382

ICD pretty many list locks added

Committed by:  piotrf
Date:  Feb 14 2006 * 16:30 (over 2 years ago)

Affected files:

openpbx/trunk/apps/app_muxmon.c (unified diff)

r1380r1382
117117 count++;
118118 if (count > 10) {
119119 opbx_log(LOG_ERROR, "Muxmon - unable to lock channel to stopmon \n");
120 chan->spiers = NULL;
120121 return;
121122 }
122123 sched_yield();

openpbx/trunk/apps/icd/icd_list.c (unified diff)

r1381r1382
543543
544544 assert(that != NULL);
545545
546 if (icd_list__lock(that) != ICD_SUCCESS) {
547 return -1;
548 }
546549 iter = icd_list__get_node_iterator(that);
547550 if (iter == NULL) {
551 icd_list__unlock(that);
548552 return -1;
549553 }
550554 count = 0;
551 while (icd_list_iterator__has_more(iter)) {
555 while (icd_list_iterator__has_more_nolock(iter)) {
552556 node = icd_list_iterator__next(iter);
553557 payload = icd_list__get_payload(node);
554558 if (payload == target) {
555559 destroy_icd_list_iterator(&iter);
560 icd_list__unlock(that);
556561 return count;
557562 }
558563 count++;
559564 }
560565 destroy_icd_list_iterator(&iter);
566 icd_list__unlock(that);
561567 return -1;
562568 }
563569
------
10831089 assert(that != NULL);
10841090 assert(match_fn != NULL);
10851091
1092 if (icd_list__lock(that) != ICD_SUCCESS) {
1093 return NULL;
1094 }
10861095 iter = icd_list__get_node_iterator(that);
10871096 if (iter == NULL) {
1097 icd_list__unlock(that);
10881098 return NULL;
10891099 }
1090 while (icd_list_iterator__has_more(iter)) {
1100 while (icd_list_iterator__has_more_nolock(iter)) {
10911101 node = icd_list_iterator__next(iter);
10921102 payload = icd_list__get_payload(node);
10931103 if (match_fn(key, payload)) {
10941104 destroy_icd_list_iterator(&iter);
1105 icd_list__unlock(that);
10951106 return node;
10961107 }
10971108 }
10981109 destroy_icd_list_iterator(&iter);
1110 icd_list__unlock(that);
10991111 return NULL;
11001112 }
11011113
------
11261138 assert(that != NULL);
11271139 assert(match_fn != NULL);
11281140
1141 if (icd_list__lock(that) != ICD_SUCCESS) {
1142 return ICD_ELOCK;
1143 }
11291144 iter = icd_list__get_node_iterator((icd_list *) that);
11301145 if (iter == NULL) {
1146 icd_list__unlock(that);
11311147 return ICD_ERESOURCE;
11321148 }
1133 while (icd_list_iterator__has_more(iter)) {
1149 while (icd_list_iterator__has_more_nolock(iter)) {
11341150 node = icd_list_iterator__next(iter);
11351151 payload = icd_list__get_payload(node);
11361152 if (match_fn(key, payload)) {
------
11381154 vetoed = icd_event__notify(ICD_EVENT_REMOVE, node->payload, that->del_fn, that->del_fn_extra);
11391155 if (vetoed == ICD_EVETO) {
11401156 opbx_log(LOG_NOTICE, "Removal of Node from ICD List %s has been vetoed\n", icd_list__get_name(that));
1157 icd_list__unlock(that);
11411158 return ICD_EVETO;
11421159 }
11431160
1144 if (icd_list__lock(that) == ICD_SUCCESS) {
1145 if (that->head == node) {
1161 if (that->head == node) {
11461162 that->head = node->next;
1147 }
1148 if (that->tail == node) {
1163 }
1164 if (that->tail == node) {
11491165 that->tail = prevnode;
1150 }
1151 if (prevnode != NULL) {
1166 }
1167 if (prevnode != NULL) {
11521168 prevnode->next = node->next;
1153 }
1154 that->count--;
1155 icd_list__free_node(that, node);
1156 icd_list__unlock(that);
1157 return ICD_SUCCESS;
11581169 }
1159 return ICD_ELOCK;
1170 that->count--;
1171 icd_list__free_node(that, node);
1172 icd_list__unlock(that);
1173 return ICD_SUCCESS;
11601174 }
11611175 prevnode = node;
11621176 }
11631177 destroy_icd_list_iterator(&iter);
1178 icd_list__unlock(that);
11641179 return ICD_ENOTFOUND;
11651180 }
11661181