| 258 | #define _RWLOCK_UNLOCK acl_pthread_mutex_unlock |
| 259 | |
| 260 | static int __init_table_rwlock(ACL_HTABLE *table, int enable) |
| 261 | { |
| 262 | const char *myname = "__init_table_rwlock"; |
| 263 | char tbuf[256]; |
| 264 | int ret; |
| 265 | |
| 266 | if (enable && table->rwlock == NULL) { |
| 267 | if (table->slice) { |
| 268 | table->rwlock = acl_slice_pool_calloc(__FILE__, __LINE__, |
| 269 | table->slice, 1, sizeof(_RWLOCK_TYPE)); |
| 270 | } else { |
| 271 | table->rwlock = acl_mycalloc(1, sizeof(_RWLOCK_TYPE)); |
| 272 | } |
| 273 | |
| 274 | if (table->rwlock == NULL) { |
| 275 | acl_msg_error("%s(%s): calloc error(%s)", __FILE__, |
| 276 | myname, acl_last_strerror(tbuf, sizeof(tbuf))); |
| 277 | return -1; |
| 278 | } |
| 279 | |
| 280 | ret = _RWLOCK_INIT(table->rwlock, NULL); |
| 281 | if (ret) { |
| 282 | acl_msg_error("%s(%d): init rwlock error(%s)", __FILE__, |
| 283 | __LINE__, acl_strerror(ret, tbuf, sizeof(tbuf))); |
| 284 | if (table->slice) { |
| 285 | acl_slice_pool_free(__FILE__, __LINE__, table->rwlock); |
| 286 | } else { |
| 287 | acl_myfree(table->rwlock); |
| 288 | } |
| 289 | return -1; |
| 290 | } |
| 291 | } else if (!enable && table->rwlock) { |
| 292 | _RWLOCK_DESTROY(table->rwlock); |
| 293 | if (table->slice) { |
| 294 | acl_slice_pool_free(__FILE__, __LINE__, table->rwlock); |
| 295 | } else { |
| 296 | acl_myfree(table->rwlock); |
| 297 | } |
| 298 | table->rwlock = NULL; |
| 299 | } |
| 300 | |
| 301 | return 0; |
| 302 | } |
| 303 | |
| 304 | /* acl_htable_create - create initial hash table */ |
| 305 |
no test coverage detected
searching dependent graphs…