| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
#include "asterisk.h" |
| 24 |
|
| 25 |
#include "asterisk/_private.h" |
| 26 |
#include "asterisk/astobj2.h" |
| 27 |
#include "astobj2_private.h" |
| 28 |
#include "astobj2_container_private.h" |
| 29 |
#include "asterisk/cli.h" |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
int ao2_container_count(struct ao2_container *c) |
| 35 |
{ |
| 36 |
return ast_atomic_fetchadd_int(&c->elements, 0); |
| 37 |
} |
| 38 |
|
| 39 |
int __container_unlink_node_debug(struct ao2_container_node *node, uint32_t flags, |
| 40 |
const char *tag, const char *file, int line, const char *func) |
| 41 |
{ |
| 42 |
struct ao2_container *container = node->my_container; |
| 43 |
|
| 44 |
if (container == NULL && (flags & AO2_UNLINK_NODE_DEC_COUNT)) { |
| 45 |
return 0; |
| 46 |
} |
| 47 |
|
| 48 |
if ((flags & AO2_UNLINK_NODE_UNLINK_OBJECT) |
| 49 |
&& !(flags & AO2_UNLINK_NODE_NOUNREF_OBJECT)) { |
| 50 |
__ao2_ref(node->obj, -1, tag ?: "Remove obj from container", file, line, func); |
| 51 |
} |
| 52 |
|
| 53 |
node->obj = NULL; |
| 54 |
|
| 55 |
if (flags & AO2_UNLINK_NODE_DEC_COUNT) { |
| 56 |
ast_atomic_fetchadd_int(&container->elements, -1); |
| 57 |
#if defined(AO2_DEBUG) |
| 58 |
{ |
| 59 |
int empty = container->nodes - container->elements; |
| 60 |
|
| 61 |
if (container->max_empty_nodes < empty) { |
| 62 |
container->max_empty_nodes = empty; |
| 63 |
} |
| 64 |
if (container->v_table->unlink_stat) { |
| 65 |
container->v_table->unlink_stat(container, node); |
| 66 |
} |
| 67 |
} |
| 68 |
#endif |
| 69 |
} |
| 70 |
|
| 71 |
if (flags & AO2_UNLINK_NODE_UNREF_NODE) { |
| 72 |
|
| 73 |
ao2_ref(node, -1); |
| 74 |
} |
| 75 |
|
| 76 |
return 1; |
| 77 |
} |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
int __ao2_link(struct ao2_container *self, void *obj_new, int flags, |
| 95 |
const char *tag, const char *file, int line, const char *func) |
| 96 |
{ |
| 97 |
int res; |
| 98 |
enum ao2_lock_req orig_lock; |
| 99 |
struct ao2_container_node *node; |
| 100 |
|
| 101 |
if (!__is_ao2_object(obj_new, file, line, func) |
| 102 |
|| !__is_ao2_object(self, file, line, func)) { |
| 103 |
return 0; |
| 104 |
} |
| 105 |
|
| 106 |
if (!self->v_table || !self->v_table->new_node || !self->v_table->insert) { |
| 107 |
|
| 108 |
__ast_assert_failed(0, "invalid container v_table", file, line, func); |
| 109 |
return 0; |
| 110 |
} |
| 111 |
|
| 112 |
if (flags & OBJ_NOLOCK) { |
| 113 |
orig_lock = __adjust_lock(self, AO2_LOCK_REQ_WRLOCK, 1); |
| 114 |
} else { |
| 115 |
ao2_wrlock(self); |
| 116 |
orig_lock = AO2_LOCK_REQ_MUTEX; |
| 117 |
} |
| 118 |
|
| 119 |
res = 0; |
| 120 |
node = self->v_table->new_node(self, obj_new, tag, file, line, func); |
| 121 |
if (node) { |
| 122 |
#if defined(AO2_DEBUG) |
| 123 |
if (ao2_container_check(self, OBJ_NOLOCK)) { |
| 124 |
ast_log(LOG_ERROR, "Container integrity failed before insert.\n"); |
| 125 |
} |
| 126 |
#endif |
| 127 |
|
| 128 |
|
| 129 |
switch (self->v_table->insert(self, node)) { |
| 130 |
case AO2_CONTAINER_INSERT_NODE_INSERTED: |
| 131 |
node->is_linked = 1; |
| 132 |
ast_atomic_fetchadd_int(&self->elements, 1); |
| 133 |
#if defined(AO2_DEBUG) |
| 134 |
AO2_DEVMODE_STAT(++self->nodes); |
| 135 |
if (self->v_table->link_stat) { |
| 136 |
self->v_table->link_stat(self, node); |
| 137 |
} |
| 138 |
#endif |
| 139 |
|
| 140 |
case AO2_CONTAINER_INSERT_NODE_OBJ_REPLACED: |
| 141 |
#if defined(AO2_DEBUG) |
| 142 |
if (ao2_container_check(self, OBJ_NOLOCK)) { |
| 143 |
ast_log(LOG_ERROR, "Container integrity failed after insert or replace.\n"); |
| 144 |
} |
| 145 |
#endif |
| 146 |
res = 1; |
| 147 |
break; |
| 148 |
case AO2_CONTAINER_INSERT_NODE_REJECTED: |
| 149 |
ao2_ref(node, -1); |
| 150 |
break; |
| 151 |
} |
| 152 |
} |
| 153 |
|
| 154 |
if (flags & OBJ_NOLOCK) { |
| 155 |
__adjust_lock(self, orig_lock, 0); |
| 156 |
} else { |
| 157 |
ao2_unlock(self); |
| 158 |
} |
| 159 |
|
| 160 |
return res; |
| 161 |
} |
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
int ao2_match_by_addr(void *user_data, void *arg, int flags) |
| 167 |
{ |
| 168 |
return (user_data == arg) ? (CMP_MATCH | CMP_STOP) : 0; |
| 169 |
} |
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
void *__ao2_unlink(struct ao2_container *c, void *user_data, int flags, |
| 176 |
const char *tag, const char *file, int line, const char *func) |
| 177 |
{ |
| 178 |
if (!__is_ao2_object(user_data, file, line, func)) { |
| 179 |
|
| 180 |
return NULL; |
| 181 |
} |
| 182 |
|
| 183 |
flags &= ~OBJ_SEARCH_MASK; |
| 184 |
flags |= (OBJ_UNLINK | OBJ_SEARCH_OBJECT | OBJ_NODATA); |
| 185 |
__ao2_callback(c, flags, ao2_match_by_addr, user_data, tag, file, line, func); |
| 186 |
|
| 187 |
return NULL; |
| 188 |
} |
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
static int cb_true(void *user_data, void *arg, int flags) |
| 194 |
{ |
| 195 |
return CMP_MATCH; |
| 196 |
} |
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
static int cb_true_data(void *user_data, void *arg, void *data, int flags) |
| 202 |
{ |
| 203 |
return CMP_MATCH; |
| 204 |
} |
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
static void *internal_ao2_traverse(struct ao2_container *self, enum search_flags flags, |
| 231 |
void *cb_fn, void *arg, void *data, enum ao2_callback_type type, |
| 232 |
const char *tag, const char *file, int line, const char *func) |
| 233 |
{ |
| 234 |
void *ret; |
| 235 |
ao2_callback_fn *cb_default = NULL; |
| 236 |
ao2_callback_data_fn *cb_withdata = NULL; |
| 237 |
struct ao2_container_node *node; |
| 238 |
void *traversal_state; |
| 239 |
|
| 240 |
enum ao2_lock_req orig_lock; |
| 241 |
struct ao2_container *multi_container = NULL; |
| 242 |
struct ao2_iterator *multi_iterator = NULL; |
| 243 |
|
| 244 |
if (!__is_ao2_object(self, file, line, func)) { |
| 245 |
return NULL; |
| 246 |
} |
| 247 |
|
| 248 |
if (!self->v_table |
| 249 |
|| !self->v_table->traverse_first || !self->v_table->traverse_next) { |
| 250 |
|
| 251 |
__ast_assert_failed(0, "invalid container v_table", file, line, func); |
| 252 |
return NULL; |
| 253 |
} |
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
if ((flags & (OBJ_MULTIPLE | OBJ_NODATA)) == OBJ_MULTIPLE) { |
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
multi_container = ao2_t_container_alloc_list(AO2_ALLOC_OPT_LOCK_NOLOCK, 0, NULL, |
| 269 |
NULL, "OBJ_MULTIPLE return container creation"); |
| 270 |
if (!multi_container) { |
| 271 |
return NULL; |
| 272 |
} |
| 273 |
if (!(multi_iterator = ast_calloc(1, sizeof(*multi_iterator)))) { |
| 274 |
ao2_t_ref(multi_container, -1, "OBJ_MULTIPLE iterator creation failed."); |
| 275 |
return NULL; |
| 276 |
} |
| 277 |
} |
| 278 |
|
| 279 |
if (!cb_fn) { |
| 280 |
|
| 281 |
if (type == AO2_CALLBACK_WITH_DATA) { |
| 282 |
cb_withdata = cb_true_data; |
| 283 |
} else { |
| 284 |
cb_default = cb_true; |
| 285 |
} |
| 286 |
} else { |
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
if (type == AO2_CALLBACK_WITH_DATA) { |
| 292 |
cb_withdata = cb_fn; |
| 293 |
} else { |
| 294 |
cb_default = cb_fn; |
| 295 |
} |
| 296 |
} |
| 297 |
|
| 298 |
|
| 299 |
if (flags & OBJ_NOLOCK) { |
| 300 |
if (flags & OBJ_UNLINK) { |
| 301 |
orig_lock = __adjust_lock(self, AO2_LOCK_REQ_WRLOCK, 1); |
| 302 |
} else { |
| 303 |
orig_lock = __adjust_lock(self, AO2_LOCK_REQ_RDLOCK, 1); |
| 304 |
} |
| 305 |
} else { |
| 306 |
orig_lock = AO2_LOCK_REQ_MUTEX; |
| 307 |
if (flags & OBJ_UNLINK) { |
| 308 |
ao2_wrlock(self); |
| 309 |
} else { |
| 310 |
ao2_rdlock(self); |
| 311 |
} |
| 312 |
} |
| 313 |
|
| 314 |
|
| 315 |
traversal_state = alloca(AO2_TRAVERSAL_STATE_SIZE); |
| 316 |
|
| 317 |
ret = NULL; |
| 318 |
for (node = self->v_table->traverse_first(self, flags, arg, traversal_state); |
| 319 |
node; |
| 320 |
node = self->v_table->traverse_next(self, traversal_state, node)) { |
| 321 |
int match; |
| 322 |
|
| 323 |
|
| 324 |
match = (CMP_MATCH | CMP_STOP); |
| 325 |
if (type == AO2_CALLBACK_WITH_DATA) { |
| 326 |
match &= cb_withdata(node->obj, arg, data, flags); |
| 327 |
} else { |
| 328 |
match &= cb_default(node->obj, arg, flags); |
| 329 |
} |
| 330 |
if (match == 0) { |
| 331 |
|
| 332 |
continue; |
| 333 |
} |
| 334 |
if (match == CMP_STOP) { |
| 335 |
|
| 336 |
break; |
| 337 |
} |
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
if (node->obj) { |
| 345 |
|
| 346 |
if (!(flags & OBJ_NODATA)) { |
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
if (multi_container) { |
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
__ao2_link(multi_container, node->obj, flags, tag, file, line, func); |
| 357 |
} else { |
| 358 |
ret = node->obj; |
| 359 |
|
| 360 |
if (!(flags & OBJ_UNLINK)) { |
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
__ao2_ref(ret, 1, tag ?: "Traversal found object", file, line, func); |
| 366 |
} |
| 367 |
} |
| 368 |
} |
| 369 |
|
| 370 |
if (flags & OBJ_UNLINK) { |
| 371 |
int ulflag = AO2_UNLINK_NODE_UNREF_NODE | AO2_UNLINK_NODE_DEC_COUNT; |
| 372 |
if (multi_container || (flags & OBJ_NODATA)) { |
| 373 |
ulflag |= AO2_UNLINK_NODE_UNLINK_OBJECT; |
| 374 |
} |
| 375 |
__container_unlink_node_debug(node, ulflag, tag, file, line, func); |
| 376 |
} |
| 377 |
} |
| 378 |
|
| 379 |
if ((match & CMP_STOP) || !(flags & OBJ_MULTIPLE)) { |
| 380 |
|
| 381 |
break; |
| 382 |
} |
| 383 |
} |
| 384 |
if (self->v_table->traverse_cleanup) { |
| 385 |
self->v_table->traverse_cleanup(traversal_state); |
| 386 |
} |
| 387 |
if (node) { |
| 388 |
|
| 389 |
ao2_ref(node, -1); |
| 390 |
} |
| 391 |
|
| 392 |
if (flags & OBJ_NOLOCK) { |
| 393 |
__adjust_lock(self, orig_lock, 0); |
| 394 |
} else { |
| 395 |
ao2_unlock(self); |
| 396 |
} |
| 397 |
|
| 398 |
|
| 399 |
if (multi_container) { |
| 400 |
*multi_iterator = ao2_iterator_init(multi_container, |
| 401 |
AO2_ITERATOR_UNLINK | AO2_ITERATOR_MALLOCD); |
| 402 |
ao2_t_ref(multi_container, -1, |
| 403 |
"OBJ_MULTIPLE for multiple objects traversal complete."); |
| 404 |
return multi_iterator; |
| 405 |
} else { |
| 406 |
return ret; |
| 407 |
} |
| 408 |
} |
| 409 |
|
| 410 |
void *__ao2_callback(struct ao2_container *c, enum search_flags flags, |
| 411 |
ao2_callback_fn *cb_fn, void *arg, const char *tag, const char *file, int line, |
| 412 |
const char *func) |
| 413 |
{ |
| 414 |
return internal_ao2_traverse(c, flags, cb_fn, arg, NULL, AO2_CALLBACK_DEFAULT, tag, file, line, func); |
| 415 |
} |
| 416 |
|
| 417 |
void *__ao2_callback_data(struct ao2_container *c, enum search_flags flags, |
| 418 |
ao2_callback_data_fn *cb_fn, void *arg, void *data, const char *tag, const char *file, |
| 419 |
int line, const char *func) |
| 420 |
{ |
| 421 |
return internal_ao2_traverse(c, flags, cb_fn, arg, data, AO2_CALLBACK_WITH_DATA, tag, file, line, func); |
| 422 |
} |
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
void *__ao2_find(struct ao2_container *c, const void *arg, enum search_flags flags, |
| 428 |
const char *tag, const char *file, int line, const char *func) |
| 429 |
{ |
| 430 |
void *arged = (void *) arg; |
| 431 |
|
| 432 |
if (!c) { |
| 433 |
|
| 434 |
ast_assert(0); |
| 435 |
return NULL; |
| 436 |
} |
| 437 |
return __ao2_callback(c, flags, c->cmp_fn, arged, tag, file, line, func); |
| 438 |
} |
| 439 |
|
| 440 |
void *__ao2_weakproxy_find(struct ao2_container *c, const void *arg, enum search_flags flags, |
| 441 |
const char *tag, const char *file, int line, const char *func) |
| 442 |
{ |
| 443 |
void *proxy; |
| 444 |
void *obj = NULL; |
| 445 |
enum ao2_lock_req orig_lock; |
| 446 |
|
| 447 |
ast_assert(!!c); |
| 448 |
ast_assert(flags & OBJ_SEARCH_MASK); |
| 449 |
ast_assert(!(flags & ~(OBJ_SEARCH_MASK | OBJ_NOLOCK))); |
| 450 |
|
| 451 |
if (flags & OBJ_NOLOCK) { |
| 452 |
orig_lock = __adjust_lock(c, AO2_LOCK_REQ_RDLOCK, 1); |
| 453 |
} else { |
| 454 |
orig_lock = AO2_LOCK_REQ_RDLOCK; |
| 455 |
ao2_rdlock(c); |
| 456 |
} |
| 457 |
|
| 458 |
while ((proxy = ao2_find(c, arg, flags | OBJ_NOLOCK))) { |
| 459 |
obj = __ao2_weakproxy_get_object(proxy, 0, tag ?: __PRETTY_FUNCTION__, file, line, func); |
| 460 |
|
| 461 |
if (obj) { |
| 462 |
ao2_ref(proxy, -1); |
| 463 |
break; |
| 464 |
} |
| 465 |
|
| 466 |
|
| 467 |
__adjust_lock(c, AO2_LOCK_REQ_WRLOCK, 1); |
| 468 |
ao2_unlink_flags(c, proxy, OBJ_NOLOCK); |
| 469 |
ao2_ref(proxy, -1); |
| 470 |
} |
| 471 |
|
| 472 |
if (flags & OBJ_NOLOCK) { |
| 473 |
|
| 474 |
__adjust_lock(c, orig_lock, 1); |
| 475 |
} else { |
| 476 |
ao2_unlock(c); |
| 477 |
} |
| 478 |
|
| 479 |
return obj; |
| 480 |
} |
| 481 |
|
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) |
| 486 |
{ |
| 487 |
struct ao2_iterator a = { |
| 488 |
.c = c, |
| 489 |
.flags = flags |
| 490 |
}; |
| 491 |
|
| 492 |
ao2_t_ref(c, +1, "Init iterator with container."); |
| 493 |
|
| 494 |
return a; |
| 495 |
} |
| 496 |
|
| 497 |
void ao2_iterator_restart(struct ao2_iterator *iter) |
| 498 |
{ |
| 499 |
if (!is_ao2_object(iter->c)) { |
| 500 |
|
| 501 |
return; |
| 502 |
} |
| 503 |
|
| 504 |
|
| 505 |
if (iter->last_node) { |
| 506 |
enum ao2_lock_req orig_lock; |
| 507 |
|
| 508 |
|
| 509 |
|
| 510 |
|
| 511 |
|
| 512 |
|
| 513 |
if (iter->flags & AO2_ITERATOR_DONTLOCK) { |
| 514 |
orig_lock = __adjust_lock(iter->c, AO2_LOCK_REQ_RDLOCK, 1); |
| 515 |
} else { |
| 516 |
orig_lock = AO2_LOCK_REQ_MUTEX; |
| 517 |
ao2_rdlock(iter->c); |
| 518 |
} |
| 519 |
|
| 520 |
ao2_ref(iter->last_node, -1); |
| 521 |
iter->last_node = NULL; |
| 522 |
|
| 523 |
if (iter->flags & AO2_ITERATOR_DONTLOCK) { |
| 524 |
__adjust_lock(iter->c, orig_lock, 0); |
| 525 |
} else { |
| 526 |
ao2_unlock(iter->c); |
| 527 |
} |
| 528 |
} |
| 529 |
|
| 530 |
|
| 531 |
iter->complete = 0; |
| 532 |
} |
| 533 |
|
| 534 |
void ao2_iterator_destroy(struct ao2_iterator *iter) |
| 535 |
{ |
| 536 |
|
| 537 |
ao2_iterator_restart(iter); |
| 538 |
|
| 539 |
|
| 540 |
ao2_t_ref(iter->c, -1, "Unref iterator in ao2_iterator_destroy"); |
| 541 |
iter->c = NULL; |
| 542 |
|
| 543 |
|
| 544 |
if (iter->flags & AO2_ITERATOR_MALLOCD) { |
| 545 |
ast_free(iter); |
| 546 |
} |
| 547 |
} |
| 548 |
|
| 549 |
void ao2_iterator_cleanup(struct ao2_iterator *iter) |
| 550 |
{ |
| 551 |
if (iter) { |
| 552 |
ao2_iterator_destroy(iter); |
| 553 |
} |
| 554 |
} |
| 555 |
|
| 556 |
void *__ao2_iterator_next(struct ao2_iterator *iter, |
| 557 |
const char *tag, const char *file, int line, const char *func) |
| 558 |
{ |
| 559 |
enum ao2_lock_req orig_lock; |
| 560 |
struct ao2_container_node *node; |
| 561 |
void *ret; |
| 562 |
|
| 563 |
if (!__is_ao2_object(iter->c, file, line, func)) { |
| 564 |
return NULL; |
| 565 |
} |
| 566 |
|
| 567 |
if (!iter->c->v_table || !iter->c->v_table->iterator_next) { |
| 568 |
|
| 569 |
__ast_assert_failed(0, "invalid iterator container v_table", file, line, func); |
| 570 |
return NULL; |
| 571 |
} |
| 572 |
|
| 573 |
if (iter->complete) { |
| 574 |
|
| 575 |
return NULL; |
| 576 |
} |
| 577 |
|
| 578 |
if (iter->flags & AO2_ITERATOR_DONTLOCK) { |
| 579 |
if (iter->flags & AO2_ITERATOR_UNLINK) { |
| 580 |
orig_lock = __adjust_lock(iter->c, AO2_LOCK_REQ_WRLOCK, 1); |
| 581 |
} else { |
| 582 |
orig_lock = __adjust_lock(iter->c, AO2_LOCK_REQ_RDLOCK, 1); |
| 583 |
} |
| 584 |
} else { |
| 585 |
orig_lock = AO2_LOCK_REQ_MUTEX; |
| 586 |
if (iter->flags & AO2_ITERATOR_UNLINK) { |
| 587 |
ao2_wrlock(iter->c); |
| 588 |
} else { |
| 589 |
ao2_rdlock(iter->c); |
| 590 |
} |
| 591 |
} |
| 592 |
|
| 593 |
node = iter->c->v_table->iterator_next(iter->c, iter->last_node, iter->flags); |
| 594 |
if (node) { |
| 595 |
ret = node->obj; |
| 596 |
|
| 597 |
if (iter->flags & AO2_ITERATOR_UNLINK) { |
| 598 |
|
| 599 |
__container_unlink_node_debug(node, AO2_UNLINK_NODE_DEC_COUNT, tag, file, line, func); |
| 600 |
|
| 601 |
|
| 602 |
} else { |
| 603 |
|
| 604 |
__ao2_ref(ret, +1, tag ?: "Next iterator object.", file, line, func); |
| 605 |
|
| 606 |
|
| 607 |
ao2_ref(node, +1); |
| 608 |
} |
| 609 |
} else { |
| 610 |
|
| 611 |
iter->complete = 1; |
| 612 |
ret = NULL; |
| 613 |
} |
| 614 |
|
| 615 |
|
| 616 |
if (iter->last_node) { |
| 617 |
ao2_ref(iter->last_node, -1); |
| 618 |
} |
| 619 |
iter->last_node = node; |
| 620 |
|
| 621 |
if (iter->flags & AO2_ITERATOR_DONTLOCK) { |
| 622 |
__adjust_lock(iter->c, orig_lock, 0); |
| 623 |
} else { |
| 624 |
ao2_unlock(iter->c); |
| 625 |
} |
| 626 |
|
| 627 |
return ret; |
| 628 |
} |
| 629 |
|
| 630 |
int ao2_iterator_count(struct ao2_iterator *iter) |
| 631 |
{ |
| 632 |
return ao2_container_count(iter->c); |
| 633 |
} |
| 634 |
|
| 635 |
void container_destruct(void *_c) |
| 636 |
{ |
| 637 |
struct ao2_container *c = _c; |
| 638 |
|
| 639 |
|
| 640 |
c->destroying = 1; |
| 641 |
ao2_t_callback(c, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, NULL, NULL, |
| 642 |
"container_destruct called"); |
| 643 |
|
| 644 |
|
| 645 |
if (c->v_table && c->v_table->destroy) { |
| 646 |
c->v_table->destroy(c); |
| 647 |
} |
| 648 |
|
| 649 |
#if defined(AO2_DEBUG) |
| 650 |
ast_atomic_fetchadd_int(&ao2.total_containers, -1); |
| 651 |
#endif |
| 652 |
} |
| 653 |
|
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
|
| 664 |
|
| 665 |
|
| 666 |
static int dup_obj_cb(void *obj, void *arg, int flags) |
| 667 |
{ |
| 668 |
struct ao2_container *dest = arg; |
| 669 |
|
| 670 |
return ao2_link_flags(dest, obj, OBJ_NOLOCK) ? 0 : (CMP_MATCH | CMP_STOP); |
| 671 |
} |
| 672 |
|
| 673 |
int ao2_container_dup(struct ao2_container *dest, struct ao2_container *src, enum search_flags flags) |
| 674 |
{ |
| 675 |
void *obj; |
| 676 |
int res = 0; |
| 677 |
|
| 678 |
if (!(flags & OBJ_NOLOCK)) { |
| 679 |
ao2_rdlock(src); |
| 680 |
ao2_wrlock(dest); |
| 681 |
} |
| 682 |
obj = ao2_callback(src, OBJ_NOLOCK, dup_obj_cb, dest); |
| 683 |
if (obj) { |
| 684 |
|
| 685 |
ao2_t_ref(obj, -1, "Failed to put this object into the dest container."); |
| 686 |
|
| 687 |
|
| 688 |
ao2_callback(dest, OBJ_NOLOCK | OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, NULL, |
| 689 |
NULL); |
| 690 |
res = -1; |
| 691 |
} |
| 692 |
if (!(flags & OBJ_NOLOCK)) { |
| 693 |
ao2_unlock(dest); |
| 694 |
ao2_unlock(src); |
| 695 |
} |
| 696 |
|
| 697 |
return res; |
| 698 |
} |
| 699 |
|
| 700 |
|
| 701 |
|
| 702 |
|
| 703 |
|
| 704 |
|
| 705 |
|
| 706 |
|
| 707 |
|
| 708 |
|
| 709 |
|
| 710 |
static int dup_weakproxy_cb(void *proxy, void *arg, int flags) |
| 711 |
{ |
| 712 |
void *obj = ao2_weakproxy_get_object(proxy, 0); |
| 713 |
struct ao2_container *dest = arg; |
| 714 |
int ret; |
| 715 |
|
| 716 |
if (!obj) { |
| 717 |
return 0; |
| 718 |
} |
| 719 |
|
| 720 |
ret = ao2_link_flags(dest, obj, OBJ_NOLOCK) ? 0 : (CMP_MATCH | CMP_STOP); |
| 721 |
ao2_ref(obj, -1); |
| 722 |
|
| 723 |
return ret; |
| 724 |
} |
| 725 |
|
| 726 |
int ao2_container_dup_weakproxy_objs(struct ao2_container *dest, struct ao2_container *src, enum search_flags flags) |
| 727 |
{ |
| 728 |
void *obj; |
| 729 |
int res = 0; |
| 730 |
|
| 731 |
if (!(flags & OBJ_NOLOCK)) { |
| 732 |
ao2_rdlock(src); |
| 733 |
ao2_wrlock(dest); |
| 734 |
} |
| 735 |
obj = ao2_callback(src, OBJ_NOLOCK, dup_weakproxy_cb, dest); |
| 736 |
if (obj) { |
| 737 |
|
| 738 |
ao2_t_ref(obj, -1, "Failed to put this object into the dest container."); |
| 739 |
|
| 740 |
|
| 741 |
ao2_callback(dest, OBJ_NOLOCK | OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, NULL, |
| 742 |
NULL); |
| 743 |
res = -1; |
| 744 |
} |
| 745 |
if (!(flags & OBJ_NOLOCK)) { |
| 746 |
ao2_unlock(dest); |
| 747 |
ao2_unlock(src); |
| 748 |
} |
| 749 |
|
| 750 |
return res; |
| 751 |
} |
| 752 |
|
| 753 |
struct ao2_container *__ao2_container_clone(struct ao2_container *orig, enum search_flags flags, const char *tag, const char *file, int line, const char *func) |
| 754 |
{ |
| 755 |
struct ao2_container *clone; |
| 756 |
int failed; |
| 757 |
|
| 758 |
|
| 759 |
if (!__is_ao2_object(orig, file, line, func)) { |
| 760 |
return NULL; |
| 761 |
} |
| 762 |
|
| 763 |
if (!orig->v_table || !orig->v_table->alloc_empty_clone) { |
| 764 |
|
| 765 |
__ast_assert_failed(0, "invalid container v_table", file, line, func); |
| 766 |
return NULL; |
| 767 |
} |
| 768 |
|
| 769 |
clone = orig->v_table->alloc_empty_clone(orig, tag, file, line, func); |
| 770 |
if (!clone) { |
| 771 |
return NULL; |
| 772 |
} |
| 773 |
|
| 774 |
|
| 775 |
|
| 776 |
|
| 777 |
if (flags & OBJ_NOLOCK) { |
| 778 |
ao2_wrlock(clone); |
| 779 |
} |
| 780 |
failed = ao2_container_dup(clone, orig, flags); |
| 781 |
if (flags & OBJ_NOLOCK) { |
| 782 |
ao2_unlock(clone); |
| 783 |
} |
| 784 |
if (failed) { |
| 785 |
|
| 786 |
__ao2_ref(clone, -1, tag ?: "Clone creation failed", file, line, func); |
| 787 |
clone = NULL; |
| 788 |
} |
| 789 |
return clone; |
| 790 |
} |
| 791 |
|
| 792 |
void ao2_container_dump(struct ao2_container *self, enum search_flags flags, const char *name, void *where, ao2_prnt_fn *prnt, ao2_prnt_obj_fn *prnt_obj) |
| 793 |
{ |
| 794 |
if (!is_ao2_object(self) || !self->v_table) { |
| 795 |
prnt(where, "Invalid container\n"); |
| 796 |
ast_assert(0); |
| 797 |
return; |
| 798 |
} |
| 799 |
|
| 800 |
if (!(flags & OBJ_NOLOCK)) { |
| 801 |
ao2_rdlock(self); |
| 802 |
} |
| 803 |
if (name) { |
| 804 |
prnt(where, "Container name: %s\n", name); |
| 805 |
} |
| 806 |
#if defined(AO2_DEBUG) |
| 807 |
if (self->v_table->dump) { |
| 808 |
self->v_table->dump(self, where, prnt, prnt_obj); |
| 809 |
} else |
| 810 |
#endif |
| 811 |
{ |
| 812 |
prnt(where, "Container dump not available.\n"); |
| 813 |
} |
| 814 |
if (!(flags & OBJ_NOLOCK)) { |
| 815 |
ao2_unlock(self); |
| 816 |
} |
| 817 |
} |
| 818 |
|
| 819 |
void ao2_container_stats(struct ao2_container *self, enum search_flags flags, const char *name, void *where, ao2_prnt_fn *prnt) |
| 820 |
{ |
| 821 |
if (!is_ao2_object(self) || !self->v_table) { |
| 822 |
prnt(where, "Invalid container\n"); |
| 823 |
ast_assert(0); |
| 824 |
return; |
| 825 |
} |
| 826 |
|
| 827 |
if (!(flags & OBJ_NOLOCK)) { |
| 828 |
ao2_rdlock(self); |
| 829 |
} |
| 830 |
if (name) { |
| 831 |
prnt(where, "Container name: %s\n", name); |
| 832 |
} |
| 833 |
prnt(where, "Number of objects: %d\n", self->elements); |
| 834 |
#if defined(AO2_DEBUG) |
| 835 |
prnt(where, "Number of nodes: %d\n", self->nodes); |
| 836 |
prnt(where, "Number of empty nodes: %d\n", self->nodes - self->elements); |
| 837 |
|
| 838 |
|
| 839 |
|
| 840 |
|
| 841 |
|
| 842 |
|
| 843 |
|
| 844 |
|
| 845 |
|
| 846 |
prnt(where, "Maximum empty nodes: %d\n", self->max_empty_nodes); |
| 847 |
if (self->v_table->stats) { |
| 848 |
self->v_table->stats(self, where, prnt); |
| 849 |
} |
| 850 |
#endif |
| 851 |
if (!(flags & OBJ_NOLOCK)) { |
| 852 |
ao2_unlock(self); |
| 853 |
} |
| 854 |
} |
| 855 |
|
| 856 |
int ao2_container_check(struct ao2_container *self, enum search_flags flags) |
| 857 |
{ |
| 858 |
int res = 0; |
| 859 |
|
| 860 |
if (!is_ao2_object(self) || !self->v_table) { |
| 861 |
|
| 862 |
ast_assert(0); |
| 863 |
return -1; |
| 864 |
} |
| 865 |
#if defined(AO2_DEBUG) |
| 866 |
if (!self->v_table->integrity) { |
| 867 |
|
| 868 |
return 0; |
| 869 |
} |
| 870 |
|
| 871 |
if (!(flags & OBJ_NOLOCK)) { |
| 872 |
ao2_rdlock(self); |
| 873 |
} |
| 874 |
res = self->v_table->integrity(self); |
| 875 |
if (!(flags & OBJ_NOLOCK)) { |
| 876 |
ao2_unlock(self); |
| 877 |
} |
| 878 |
#endif |
| 879 |
return res; |
| 880 |
} |
| 881 |
|
| 882 |
#if defined(AO2_DEBUG) |
| 883 |
static struct ao2_container *reg_containers; |
| 884 |
|
| 885 |
struct ao2_reg_container { |
| 886 |
|
| 887 |
struct ao2_container *registered; |
| 888 |
|
| 889 |
ao2_prnt_obj_fn *prnt_obj; |
| 890 |
|
| 891 |
char name[1]; |
| 892 |
}; |
| 893 |
|
| 894 |
struct ao2_reg_partial_key { |
| 895 |
|
| 896 |
int len; |
| 897 |
|
| 898 |
const char *name; |
| 899 |
}; |
| 900 |
|
| 901 |
struct ao2_reg_match { |
| 902 |
|
| 903 |
int find_nth; |
| 904 |
|
| 905 |
int count; |
| 906 |
}; |
| 907 |
#endif |
| 908 |
|
| 909 |
#if defined(AO2_DEBUG) |
| 910 |
static int ao2_reg_sort_cb(const void *obj_left, const void *obj_right, int flags) |
| 911 |
{ |
| 912 |
const struct ao2_reg_container *reg_left = obj_left; |
| 913 |
int cmp; |
| 914 |
|
| 915 |
switch (flags & OBJ_SEARCH_MASK) { |
| 916 |
case OBJ_SEARCH_OBJECT: |
| 917 |
{ |
| 918 |
const struct ao2_reg_container *reg_right = obj_right; |
| 919 |
|
| 920 |
cmp = strcasecmp(reg_left->name, reg_right->name); |
| 921 |
} |
| 922 |
break; |
| 923 |
case OBJ_SEARCH_KEY: |
| 924 |
{ |
| 925 |
const char *name = obj_right; |
| 926 |
|
| 927 |
cmp = strcasecmp(reg_left->name, name); |
| 928 |
} |
| 929 |
break; |
| 930 |
case OBJ_SEARCH_PARTIAL_KEY: |
| 931 |
{ |
| 932 |
const struct ao2_reg_partial_key *partial_key = obj_right; |
| 933 |
|
| 934 |
cmp = strncasecmp(reg_left->name, partial_key->name, partial_key->len); |
| 935 |
} |
| 936 |
break; |
| 937 |
default: |
| 938 |
|
| 939 |
ast_assert(0); |
| 940 |
cmp = 0; |
| 941 |
break; |
| 942 |
} |
| 943 |
return cmp; |
| 944 |
} |
| 945 |
#endif |
| 946 |
|
| 947 |
#if defined(AO2_DEBUG) |
| 948 |
static void ao2_reg_destructor(void *v_doomed) |
| 949 |
{ |
| 950 |
struct ao2_reg_container *doomed = v_doomed; |
| 951 |
|
| 952 |
if (doomed->registered) { |
| 953 |
ao2_t_ref(doomed->registered, -1, "Releasing registered container."); |
| 954 |
} |
| 955 |
} |
| 956 |
#endif |
| 957 |
|
| 958 |
int ao2_container_register(const char *name, struct ao2_container *self, ao2_prnt_obj_fn *prnt_obj) |
| 959 |
{ |
| 960 |
int res = 0; |
| 961 |
#if defined(AO2_DEBUG) |
| 962 |
struct ao2_reg_container *reg; |
| 963 |
|
| 964 |
reg = ao2_t_alloc_options(sizeof(*reg) + strlen(name), ao2_reg_destructor, |
| 965 |
AO2_ALLOC_OPT_LOCK_NOLOCK, "Container registration object."); |
| 966 |
if (!reg) { |
| 967 |
return -1; |
| 968 |
} |
| 969 |
|
| 970 |
|
| 971 |
ao2_t_ref(self, +1, "Registering container."); |
| 972 |
reg->registered = self; |
| 973 |
reg->prnt_obj = prnt_obj; |
| 974 |
strcpy(reg->name, name); |
| 975 |
|
| 976 |
if (!ao2_t_link(reg_containers, reg, "Save registration object.")) { |
| 977 |
res = -1; |
| 978 |
} |
| 979 |
|
| 980 |
ao2_t_ref(reg, -1, "Done registering container."); |
| 981 |
#endif |
| 982 |
return res; |
| 983 |
} |
| 984 |
|
| 985 |
void ao2_container_unregister(const char *name) |
| 986 |
{ |
| 987 |
#if defined(AO2_DEBUG) |
| 988 |
ao2_t_find(reg_containers, name, OBJ_UNLINK | OBJ_NODATA | OBJ_SEARCH_KEY, |
| 989 |
"Unregister container"); |
| 990 |
#endif |
| 991 |
} |
| 992 |
|
| 993 |
#if defined(AO2_DEBUG) |
| 994 |
static int ao2_complete_reg_cb(void *obj, void *arg, int flags) |
| 995 |
{ |
| 996 |
struct ao2_reg_container *reg = obj; |
| 997 |
|
| 998 |
if (ast_cli_completion_add(ast_strdup(reg->name))) { |
| 999 |
return CMP_STOP; |
| 1000 |
} |
| 1001 |
|
| 1002 |
return 0; |
| 1003 |
} |
| 1004 |
#endif |
| 1005 |
|
| 1006 |
#if defined(AO2_DEBUG) |
| 1007 |
static char *complete_container_names(struct ast_cli_args *a) |
| 1008 |
{ |
| 1009 |
struct ao2_reg_partial_key partial_key; |
| 1010 |
|
| 1011 |
if (a->pos != 3) { |
| 1012 |
return NULL; |
| 1013 |
} |
| 1014 |
|
| 1015 |
partial_key.len = strlen(a->word); |
| 1016 |
partial_key.name = a->word; |
| 1017 |
ao2_callback(reg_containers, partial_key.len ? OBJ_SEARCH_PARTIAL_KEY : 0, |
| 1018 |
ao2_complete_reg_cb, &partial_key); |
| 1019 |
|
| 1020 |
return NULL; |
| 1021 |
} |
| 1022 |
#endif |
| 1023 |
|
| 1024 |
#if defined(AO2_DEBUG) |
| 1025 |
AST_THREADSTORAGE(ao2_out_buf); |
| 1026 |
|
| 1027 |
|
| 1028 |
|
| 1029 |
|
| 1030 |
|
| 1031 |
|
| 1032 |
|
| 1033 |
|
| 1034 |
static void cli_output(void *where, const char *fmt, ...) __attribute__((format(printf, 2, 3))); |
| 1035 |
static void cli_output(void *where, const char *fmt, ...) |
| 1036 |
{ |
| 1037 |
int res; |
| 1038 |
struct ast_str *buf; |
| 1039 |
va_list ap; |
| 1040 |
|
| 1041 |
buf = ast_str_thread_get(&ao2_out_buf, 256); |
| 1042 |
if (!buf) { |
| 1043 |
return; |
| 1044 |
} |
| 1045 |
|
| 1046 |
va_start(ap, fmt); |
| 1047 |
res = ast_str_set_va(&buf, 0, fmt, ap); |
| 1048 |
va_end(ap); |
| 1049 |
|
| 1050 |
if (res != AST_DYNSTR_BUILD_FAILED) { |
| 1051 |
ast_cli(*(int *) where, "%s", ast_str_buffer(buf)); |
| 1052 |
} |
| 1053 |
} |
| 1054 |
#endif |
| 1055 |
|
| 1056 |
#if defined(AO2_DEBUG) |
| 1057 |
|
| 1058 |
static char *handle_cli_astobj2_container_dump(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| 1059 |
{ |
| 1060 |
const char *name; |
| 1061 |
struct ao2_reg_container *reg; |
| 1062 |
|
| 1063 |
switch (cmd) { |
| 1064 |
case CLI_INIT: |
| 1065 |
e->command = "astobj2 container dump"; |
| 1066 |
e->usage = |
| 1067 |
"Usage: astobj2 container dump <name>\n" |
| 1068 |
" Show contents of the container <name>.\n"; |
| 1069 |
return NULL; |
| 1070 |
case CLI_GENERATE: |
| 1071 |
return complete_container_names(a); |
| 1072 |
} |
| 1073 |
|
| 1074 |
if (a->argc != 4) { |
| 1075 |
return CLI_SHOWUSAGE; |
| 1076 |
} |
| 1077 |
|
| 1078 |
name = a->argv[3]; |
| 1079 |
reg = ao2_t_find(reg_containers, name, OBJ_SEARCH_KEY, "Find registered container"); |
| 1080 |
if (reg) { |
| 1081 |
ao2_container_dump(reg->registered, 0, name, (void *) &a->fd, cli_output, |
| 1082 |
reg->prnt_obj); |
| 1083 |
ao2_t_ref(reg, -1, "Done with registered container object."); |
| 1084 |
} else { |
| 1085 |
ast_cli(a->fd, "Container '%s' not found.\n", name); |
| 1086 |
} |
| 1087 |
|
| 1088 |
return CLI_SUCCESS; |
| 1089 |
} |
| 1090 |
#endif |
| 1091 |
|
| 1092 |
#if defined(AO2_DEBUG) |
| 1093 |
|
| 1094 |
static char *handle_cli_astobj2_container_stats(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| 1095 |
{ |
| 1096 |
const char *name; |
| 1097 |
struct ao2_reg_container *reg; |
| 1098 |
|
| 1099 |
switch (cmd) { |
| 1100 |
case CLI_INIT: |
| 1101 |
e->command = "astobj2 container stats"; |
| 1102 |
e->usage = |
| 1103 |
"Usage: astobj2 container stats <name>\n" |
| 1104 |
" Show statistics about the specified container <name>.\n"; |
| 1105 |
return NULL; |
| 1106 |
case CLI_GENERATE: |
| 1107 |
return complete_container_names(a); |
| 1108 |
} |
| 1109 |
|
| 1110 |
if (a->argc != 4) { |
| 1111 |
return CLI_SHOWUSAGE; |
| 1112 |
} |
| 1113 |
|
| 1114 |
name = a->argv[3]; |
| 1115 |
reg = ao2_t_find(reg_containers, name, OBJ_SEARCH_KEY, "Find registered container"); |
| 1116 |
if (reg) { |
| 1117 |
ao2_container_stats(reg->registered, 0, name, (void *) &a->fd, cli_output); |
| 1118 |
ao2_t_ref(reg, -1, "Done with registered container object."); |
| 1119 |
} else { |
| 1120 |
ast_cli(a->fd, "Container '%s' not found.\n", name); |
| 1121 |
} |
| 1122 |
|
| 1123 |
return CLI_SUCCESS; |
| 1124 |
} |
| 1125 |
#endif |
| 1126 |
|
| 1127 |
#if defined(AO2_DEBUG) |
| 1128 |
|
| 1129 |
static char *handle_cli_astobj2_container_check(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| 1130 |
{ |
| 1131 |
const char *name; |
| 1132 |
struct ao2_reg_container *reg; |
| 1133 |
|
| 1134 |
switch (cmd) { |
| 1135 |
case CLI_INIT: |
| 1136 |
e->command = "astobj2 container check"; |
| 1137 |
e->usage = |
| 1138 |
"Usage: astobj2 container check <name>\n" |
| 1139 |
" Perform a container integrity check on <name>.\n"; |
| 1140 |
return NULL; |
| 1141 |
case CLI_GENERATE: |
| 1142 |
return complete_container_names(a); |
| 1143 |
} |
| 1144 |
|
| 1145 |
if (a->argc != 4) { |
| 1146 |
return CLI_SHOWUSAGE; |
| 1147 |
} |
| 1148 |
|
| 1149 |
name = a->argv[3]; |
| 1150 |
reg = ao2_t_find(reg_containers, name, OBJ_SEARCH_KEY, "Find registered container"); |
| 1151 |
if (reg) { |
| 1152 |
ast_cli(a->fd, "Container check of '%s': %s.\n", name, |
| 1153 |
ao2_container_check(reg->registered, 0) ? "failed" : "OK"); |
| 1154 |
ao2_t_ref(reg, -1, "Done with registered container object."); |
| 1155 |
} else { |
| 1156 |
ast_cli(a->fd, "Container '%s' not found.\n", name); |
| 1157 |
} |
| 1158 |
|
| 1159 |
return CLI_SUCCESS; |
| 1160 |
} |
| 1161 |
#endif |
| 1162 |
|
| 1163 |
#if defined(AO2_DEBUG) |
| 1164 |
static struct ast_cli_entry cli_astobj2[] = { |
| 1165 |
AST_CLI_DEFINE(handle_cli_astobj2_container_dump, "Show container contents"), |
| 1166 |
AST_CLI_DEFINE(handle_cli_astobj2_container_stats, "Show container statistics"), |
| 1167 |
AST_CLI_DEFINE(handle_cli_astobj2_container_check, "Perform a container integrity check"), |
| 1168 |
}; |
| 1169 |
#endif |
| 1170 |
|
| 1171 |
#if defined(AO2_DEBUG) |
| 1172 |
static void container_cleanup(void) |
| 1173 |
{ |
| 1174 |
ao2_t_ref(reg_containers, -1, "Releasing container registration container"); |
| 1175 |
reg_containers = NULL; |
| 1176 |
|
| 1177 |
ast_cli_unregister_multiple(cli_astobj2, ARRAY_LEN(cli_astobj2)); |
| 1178 |
} |
| 1179 |
#endif |
| 1180 |
|
| 1181 |
int container_init(void) |
| 1182 |
{ |
| 1183 |
#if defined(AO2_DEBUG) |
| 1184 |
reg_containers = ao2_t_container_alloc_list(AO2_ALLOC_OPT_LOCK_RWLOCK, |
| 1185 |
AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE, ao2_reg_sort_cb, NULL, |
| 1186 |
"Container registration container."); |
| 1187 |
if (!reg_containers) { |
| 1188 |
return -1; |
| 1189 |
} |
| 1190 |
|
| 1191 |
ast_cli_register_multiple(cli_astobj2, ARRAY_LEN(cli_astobj2)); |
| 1192 |
ast_register_cleanup(container_cleanup); |
| 1193 |
#endif |
| 1194 |
|
| 1195 |
return 0; |
| 1196 |
} |