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)
| r1380 | r1382 | |
|---|---|---|
| 117 | 117 | count++; |
| 118 | 118 | if (count > 10) { |
| 119 | 119 | opbx_log(LOG_ERROR, "Muxmon - unable to lock channel to stopmon \n"); |
| 120 | chan->spiers = NULL; | |
| 120 | 121 | return; |
| 121 | 122 | } |
| 122 | 123 | sched_yield(); |
openpbx/trunk/apps/icd/icd_list.c (unified diff)
| r1381 | r1382 | |
|---|---|---|
| 543 | 543 | |
| 544 | 544 | assert(that != NULL); |
| 545 | 545 | |
| 546 | if (icd_list__lock(that) != ICD_SUCCESS) { | |
| 547 | return -1; | |
| 548 | } | |
| 546 | 549 | iter = icd_list__get_node_iterator(that); |
| 547 | 550 | if (iter == NULL) { |
| 551 | icd_list__unlock(that); | |
| 548 | 552 | return -1; |
| 549 | 553 | } |
| 550 | 554 | count = 0; |
| 551 | while (icd_list_iterator__has_more(iter)) { | |
| 555 | while (icd_list_iterator__has_more_nolock(iter)) { | |
| 552 | 556 | node = icd_list_iterator__next(iter); |
| 553 | 557 | payload = icd_list__get_payload(node); |
| 554 | 558 | if (payload == target) { |
| 555 | 559 | destroy_icd_list_iterator(&iter); |
| 560 | icd_list__unlock(that); | |
| 556 | 561 | return count; |
| 557 | 562 | } |
| 558 | 563 | count++; |
| 559 | 564 | } |
| 560 | 565 | destroy_icd_list_iterator(&iter); |
| 566 | icd_list__unlock(that); | |
| 561 | 567 | return -1; |
| 562 | 568 | } |
| 563 | 569 | |
| --- | --- | |
| 1083 | 1089 | assert(that != NULL); |
| 1084 | 1090 | assert(match_fn != NULL); |
| 1085 | 1091 | |
| 1092 | if (icd_list__lock(that) != ICD_SUCCESS) { | |
| 1093 | return NULL; | |
| 1094 | } | |
| 1086 | 1095 | iter = icd_list__get_node_iterator(that); |
| 1087 | 1096 | if (iter == NULL) { |
| 1097 | icd_list__unlock(that); | |
| 1088 | 1098 | return NULL; |
| 1089 | 1099 | } |
| 1090 | while (icd_list_iterator__has_more(iter)) { | |
| 1100 | while (icd_list_iterator__has_more_nolock(iter)) { | |
| 1091 | 1101 | node = icd_list_iterator__next(iter); |
| 1092 | 1102 | payload = icd_list__get_payload(node); |
| 1093 | 1103 | if (match_fn(key, payload)) { |
| 1094 | 1104 | destroy_icd_list_iterator(&iter); |
| 1105 | icd_list__unlock(that); | |
| 1095 | 1106 | return node; |
| 1096 | 1107 | } |
| 1097 | 1108 | } |
| 1098 | 1109 | destroy_icd_list_iterator(&iter); |
| 1110 | icd_list__unlock(that); | |
| 1099 | 1111 | return NULL; |
| 1100 | 1112 | } |
| 1101 | 1113 | |
| --- | --- | |
| 1126 | 1138 | assert(that != NULL); |
| 1127 | 1139 | assert(match_fn != NULL); |
| 1128 | 1140 | |
| 1141 | if (icd_list__lock(that) != ICD_SUCCESS) { | |
| 1142 | return ICD_ELOCK; | |
| 1143 | } | |
| 1129 | 1144 | iter = icd_list__get_node_iterator((icd_list *) that); |
| 1130 | 1145 | if (iter == NULL) { |
| 1146 | icd_list__unlock(that); | |
| 1131 | 1147 | return ICD_ERESOURCE; |
| 1132 | 1148 | } |
| 1133 | while (icd_list_iterator__has_more(iter)) { | |
| 1149 | while (icd_list_iterator__has_more_nolock(iter)) { | |
| 1134 | 1150 | node = icd_list_iterator__next(iter); |
| 1135 | 1151 | payload = icd_list__get_payload(node); |
| 1136 | 1152 | if (match_fn(key, payload)) { |
| --- | --- | |
| 1138 | 1154 | vetoed = icd_event__notify(ICD_EVENT_REMOVE, node->payload, that->del_fn, that->del_fn_extra); |
| 1139 | 1155 | if (vetoed == ICD_EVETO) { |
| 1140 | 1156 | 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); | |
| 1141 | 1158 | return ICD_EVETO; |
| 1142 | 1159 | } |
| 1143 | 1160 | |
| 1144 | if (icd_list__lock(that) == ICD_SUCCESS) { | |
| 1145 | if (that->head == node) { | |
| 1161 | if (that->head == node) { | |
| 1146 | 1162 | that->head = node->next; |
| 1147 | } | |
| 1148 | if (that->tail == node) { | |
| 1163 | } | |
| 1164 | if (that->tail == node) { | |
| 1149 | 1165 | that->tail = prevnode; |
| 1150 | } | |
| 1151 | if (prevnode != NULL) { | |
| 1166 | } | |
| 1167 | if (prevnode != NULL) { | |
| 1152 | 1168 | prevnode->next = node->next; |
| 1153 | } | |
| 1154 | that->count--; | |
| 1155 | icd_list__free_node(that, node); | |
| 1156 | icd_list__unlock(that); | |
| 1157 | return ICD_SUCCESS; | |
| 1158 | 1169 | } |
| 1159 | return ICD_ELOCK; | |
| 1170 | that->count--; | |
| 1171 | icd_list__free_node(that, node); | |
| 1172 | icd_list__unlock(that); | |
| 1173 | return ICD_SUCCESS; | |
| 1160 | 1174 | } |
| 1161 | 1175 | prevnode = node; |
| 1162 | 1176 | } |
| 1163 | 1177 | destroy_icd_list_iterator(&iter); |
| 1178 | icd_list__unlock(that); | |
| 1164 | 1179 | return ICD_ENOTFOUND; |
| 1165 | 1180 | } |
| 1166 | 1181 |
![Home changeset 1382 [home]](/images/logo.png?1180520111)
RSS Feeds