- Timestamp:
- 04/19/10 17:55:26 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/regfi.c
r185 r186 806 806 bool recursive_type; 807 807 808 if(!regfi_lock(file, file->cb_lock, "regfi_parse_subkeylist"))808 if(!regfi_lock(file, &file->cb_lock, "regfi_parse_subkeylist")) 809 809 goto fail; 810 810 … … 882 882 goto fail_locked; 883 883 884 if(!regfi_unlock(file, file->cb_lock, "regfi_parse_subkeylist"))884 if(!regfi_unlock(file, &file->cb_lock, "regfi_parse_subkeylist")) 885 885 goto fail; 886 886 … … 906 906 907 907 fail_locked: 908 regfi_unlock(file, file->cb_lock, "regfi_parse_subkeylist");908 regfi_unlock(file, &file->cb_lock, "regfi_parse_subkeylist"); 909 909 fail: 910 910 if(elements != NULL) … … 982 982 bool unalloc = false; 983 983 984 if(!regfi_lock(file, file->cb_lock, "regfi_parse_sk"))984 if(!regfi_lock(file, &file->cb_lock, "regfi_parse_sk")) 985 985 goto fail; 986 986 … … 1060 1060 } 1061 1061 1062 if(!regfi_unlock(file, file->cb_lock, "regfi_parse_sk"))1062 if(!regfi_unlock(file, &file->cb_lock, "regfi_parse_sk")) 1063 1063 goto fail; 1064 1064 … … 1076 1076 1077 1077 fail_locked: 1078 regfi_unlock(file, file->cb_lock, "regfi_parse_sk");1078 regfi_unlock(file, &file->cb_lock, "regfi_parse_sk"); 1079 1079 fail: 1080 1080 if(sec_desc_buf != NULL) … … 1092 1092 bool unalloc; 1093 1093 1094 if(!regfi_lock(file, file->cb_lock, "regfi_parse_valuelist"))1094 if(!regfi_lock(file, &file->cb_lock, "regfi_parse_valuelist")) 1095 1095 goto fail; 1096 1096 … … 1140 1140 } 1141 1141 1142 if(!regfi_unlock(file, file->cb_lock, "regfi_parse_valuelist"))1142 if(!regfi_unlock(file, &file->cb_lock, "regfi_parse_valuelist")) 1143 1143 goto fail; 1144 1144 … … 1167 1167 1168 1168 fail_locked: 1169 regfi_unlock(file, file->cb_lock, "regfi_parse_valuelist");1169 regfi_unlock(file, &file->cb_lock, "regfi_parse_valuelist"); 1170 1170 fail: 1171 1171 talloc_free(ret_val); … … 1423 1423 return regfi_parse_sk(file, offset, max_size, strict); 1424 1424 1425 if(!regfi_lock(file, file->sk_lock, "regfi_load_sk"))1425 if(!regfi_lock(file, &file->sk_lock, "regfi_load_sk")) 1426 1426 return NULL; 1427 1427 … … 1450 1450 } 1451 1451 1452 if(!regfi_unlock(file, file->sk_lock, "regfi_load_sk"))1452 if(!regfi_unlock(file, &file->sk_lock, "regfi_load_sk")) 1453 1453 { 1454 1454 talloc_unlink(NULL, ret_val); … … 1475 1475 { 1476 1476 1477 if(!regfi_lock(file, file->cb_lock, "regfi_find_root_nk"))1477 if(!regfi_lock(file, &file->cb_lock, "regfi_find_root_nk")) 1478 1478 return NULL; 1479 1479 … … 1485 1485 } 1486 1486 1487 if(!regfi_unlock(file, file->cb_lock, "regfi_find_root_nk"))1487 if(!regfi_unlock(file, &file->cb_lock, "regfi_find_root_nk")) 1488 1488 return NULL; 1489 1489 … … 1539 1539 1540 1540 1541 1541 /****************************************************************************** 1542 ******************************************************************************/ 1543 int regfi_free_cb(void* f) 1544 { 1545 REGFI_FILE* file = (REGFI_FILE*)f; 1546 1547 pthread_mutex_destroy(&file->cb_lock); 1548 pthread_rwlock_destroy(&file->hbins_lock); 1549 pthread_mutex_destroy(&file->sk_lock); 1550 1551 return 0; 1552 } 1553 1554 1555 /****************************************************************************** 1556 ******************************************************************************/ 1542 1557 REGFI_FILE* regfi_alloc_cb(REGFI_RAW_FILE* file_cb) 1543 1558 { … … 1568 1583 rb->file_length = file_length; 1569 1584 rb->cb = file_cb; 1570 rb->cb_lock = NULL; 1571 rb->hbins_lock = NULL; 1572 rb->sk_lock = NULL; 1573 1574 rb->cb_lock = talloc(rb, pthread_mutex_t); 1575 if(rb->cb_lock == NULL || pthread_mutex_init(rb->cb_lock, NULL) != 0) 1585 1586 if(pthread_mutex_init(&rb->cb_lock, NULL) != 0) 1576 1587 { 1577 1588 regfi_log_add(REGFI_LOG_ERROR, "Failed to create cb_lock mutex."); … … 1579 1590 } 1580 1591 1581 rb->hbins_lock = talloc(rb, pthread_rwlock_t); 1582 if(rb->hbins_lock == NULL || pthread_rwlock_init(rb->hbins_lock, NULL) != 0) 1592 if(pthread_rwlock_init(&rb->hbins_lock, NULL) != 0) 1583 1593 { 1584 1594 regfi_log_add(REGFI_LOG_ERROR, "Failed to create hbins_lock rwlock."); … … 1586 1596 } 1587 1597 1588 rb->sk_lock = talloc(rb, pthread_mutex_t); 1589 if(rb->sk_lock == NULL || pthread_mutex_init(rb->sk_lock, NULL) != 0) 1598 if(pthread_mutex_init(&rb->sk_lock, NULL) != 0) 1590 1599 { 1591 1600 regfi_log_add(REGFI_LOG_ERROR, "Failed to create sk_lock mutex."); … … 1626 1635 1627 1636 /* success */ 1637 talloc_set_destructor(rb, regfi_free_cb); 1628 1638 return rb; 1629 1639 1630 1640 fail: 1631 if(rb->cb_lock != NULL) 1632 pthread_mutex_destroy(rb->cb_lock); 1633 if(rb->hbins_lock != NULL) 1634 pthread_rwlock_destroy(rb->hbins_lock); 1635 if(rb->sk_lock != NULL) 1636 pthread_mutex_destroy(rb->sk_lock); 1641 pthread_mutex_destroy(&rb->cb_lock); 1642 pthread_rwlock_destroy(&rb->hbins_lock); 1643 pthread_mutex_destroy(&rb->sk_lock); 1637 1644 1638 1645 range_list_free(rb->hbins); 1639 talloc_free(rb->cb_lock);1640 talloc_free(rb->hbins_lock);1641 1646 talloc_free(rb); 1642 1647 return NULL; … … 1646 1651 /****************************************************************************** 1647 1652 ******************************************************************************/ 1648 void regfi_free(REGFI_FILE *file) 1649 { 1650 pthread_mutex_destroy(file->cb_lock); 1651 pthread_rwlock_destroy(file->hbins_lock); 1652 pthread_mutex_destroy(file->sk_lock); 1653 void regfi_free(REGFI_FILE* file) 1654 { 1655 /* Callback handles cleanup side effects */ 1653 1656 talloc_free(file); 1654 1657 } … … 1684 1687 */ 1685 1688 1686 if(!regfi_read_lock(file, file->hbins_lock, "regfi_rootkey"))1689 if(!regfi_read_lock(file, &file->hbins_lock, "regfi_rootkey")) 1687 1690 return NULL; 1688 1691 … … 1694 1697 } 1695 1698 1696 if(!regfi_rw_unlock(file, file->hbins_lock, "regfi_rootkey"))1699 if(!regfi_rw_unlock(file, &file->hbins_lock, "regfi_rootkey")) 1697 1700 return NULL; 1698 1701 … … 2498 2501 goto fail; 2499 2502 2500 if(!regfi_lock(file, file->cb_lock, "regfi_parse_hbin"))2503 if(!regfi_lock(file, &file->cb_lock, "regfi_parse_hbin")) 2501 2504 goto fail; 2502 2505 … … 2517 2520 } 2518 2521 2519 if(!regfi_unlock(file, file->cb_lock, "regfi_parse_hbin"))2522 if(!regfi_unlock(file, &file->cb_lock, "regfi_parse_hbin")) 2520 2523 goto fail; 2521 2524 … … 2562 2565 2563 2566 fail_locked: 2564 regfi_unlock(file, file->cb_lock, "regfi_parse_hbin");2567 regfi_unlock(file, &file->cb_lock, "regfi_parse_hbin"); 2565 2568 fail: 2566 2569 talloc_free(hbin); … … 2587 2590 } 2588 2591 2589 if(!regfi_lock(file, file->cb_lock, "regfi_parse_nk"))2592 if(!regfi_lock(file, &file->cb_lock, "regfi_parse_nk")) 2590 2593 goto fail; 2591 2594 … … 2700 2703 } 2701 2704 2702 if(!regfi_unlock(file, file->cb_lock, "regfi_parse_nk"))2705 if(!regfi_unlock(file, &file->cb_lock, "regfi_parse_nk")) 2703 2706 goto fail; 2704 2707 … … 2706 2709 2707 2710 fail_locked: 2708 regfi_unlock(file, file->cb_lock, "regfi_parse_nk");2711 regfi_unlock(file, &file->cb_lock, "regfi_parse_nk"); 2709 2712 fail: 2710 2713 talloc_free(ret_val); … … 2725 2728 { goto fail; } 2726 2729 2727 if(!regfi_lock(file, file->cb_lock, "regfi_parse_classname"))2730 if(!regfi_lock(file, &file->cb_lock, "regfi_parse_classname")) 2728 2731 goto fail; 2729 2732 … … 2775 2778 } 2776 2779 2777 if(!regfi_unlock(file, file->cb_lock, "regfi_parse_classname"))2780 if(!regfi_unlock(file, &file->cb_lock, "regfi_parse_classname")) 2778 2781 goto fail; 2779 2782 … … 2781 2784 2782 2785 fail_locked: 2783 regfi_unlock(file, file->cb_lock, "regfi_parse_classname");2786 regfi_unlock(file, &file->cb_lock, "regfi_parse_classname"); 2784 2787 fail: 2785 2788 talloc_free(ret_val); … … 2802 2805 goto fail; 2803 2806 2804 if(!regfi_lock(file, file->cb_lock, "regfi_parse_nk"))2807 if(!regfi_lock(file, &file->cb_lock, "regfi_parse_nk")) 2805 2808 goto fail; 2806 2809 … … 2887 2890 cell_length = REGFI_VK_MIN_LENGTH + 4; 2888 2891 2889 if(!regfi_unlock(file, file->cb_lock, "regfi_parse_nk"))2892 if(!regfi_unlock(file, &file->cb_lock, "regfi_parse_nk")) 2890 2893 goto fail; 2891 2894 … … 2900 2903 2901 2904 fail_locked: 2902 regfi_unlock(file, file->cb_lock, "regfi_parse_vk");2905 regfi_unlock(file, &file->cb_lock, "regfi_parse_vk"); 2903 2906 fail: 2904 2907 talloc_free(ret_val); … … 2952 2955 } 2953 2956 2954 if(!regfi_lock(file, file->cb_lock, "regfi_load_data"))2957 if(!regfi_lock(file, &file->cb_lock, "regfi_load_data")) 2955 2958 goto fail; 2956 2959 … … 2963 2966 } 2964 2967 2965 if(!regfi_unlock(file, file->cb_lock, "regfi_load_data"))2968 if(!regfi_unlock(file, &file->cb_lock, "regfi_load_data")) 2966 2969 goto fail; 2967 2970 … … 3013 3016 3014 3017 fail_locked: 3015 regfi_unlock(file, file->cb_lock, "regfi_load_data");3018 regfi_unlock(file, &file->cb_lock, "regfi_load_data"); 3016 3019 fail: 3017 3020 ret_val.buf = NULL; … … 3037 3040 ret_val.len = length; 3038 3041 3039 if(!regfi_lock(file, file->cb_lock, "regfi_parse_data"))3042 if(!regfi_lock(file, &file->cb_lock, "regfi_parse_data")) 3040 3043 goto fail; 3041 3044 … … 3056 3059 } 3057 3060 3058 if(!regfi_unlock(file, file->cb_lock, "regfi_parse_data"))3061 if(!regfi_unlock(file, &file->cb_lock, "regfi_parse_data")) 3059 3062 goto fail; 3060 3063 … … 3062 3065 3063 3066 fail_locked: 3064 regfi_unlock(file, file->cb_lock, "regfi_parse_data");3067 regfi_unlock(file, &file->cb_lock, "regfi_parse_data"); 3065 3068 fail: 3066 3069 talloc_free(ret_val.buf); … … 3123 3126 } 3124 3127 3125 if(!regfi_lock(file, file->cb_lock, "regfi_parse_big_data_header"))3128 if(!regfi_lock(file, &file->cb_lock, "regfi_parse_big_data_header")) 3126 3129 goto fail; 3127 3130 … … 3135 3138 } 3136 3139 3137 if(!regfi_unlock(file, file->cb_lock, "regfi_parse_big_data_header"))3140 if(!regfi_unlock(file, &file->cb_lock, "regfi_parse_big_data_header")) 3138 3141 goto fail; 3139 3142 … … 3151 3154 3152 3155 fail_locked: 3153 regfi_unlock(file, file->cb_lock, "regfi_parse_big_data_header");3156 regfi_unlock(file, &file->cb_lock, "regfi_parse_big_data_header"); 3154 3157 fail: 3155 3158 talloc_free(ret_val.buf); … … 3183 3186 goto fail; 3184 3187 3185 if(!regfi_lock(file, file->cb_lock, "regfi_parse_big_data_indirect"))3188 if(!regfi_lock(file, &file->cb_lock, "regfi_parse_big_data_indirect")) 3186 3189 goto fail; 3187 3190 … … 3196 3199 } 3197 3200 3198 if(!regfi_unlock(file, file->cb_lock, "regfi_parse_big_data_indirect"))3201 if(!regfi_unlock(file, &file->cb_lock, "regfi_parse_big_data_indirect")) 3199 3202 goto fail; 3200 3203 … … 3210 3213 3211 3214 fail_locked: 3212 regfi_unlock(file, file->cb_lock, "regfi_parse_big_data_indirect");3215 regfi_unlock(file, &file->cb_lock, "regfi_parse_big_data_indirect"); 3213 3216 fail: 3214 3217 talloc_free(ret_val); … … 3244 3247 for(i=0; i<num_chunks; i++) 3245 3248 { 3246 if(!regfi_lock(file, file->cb_lock, "regfi_parse_big_data_cells"))3249 if(!regfi_lock(file, &file->cb_lock, "regfi_parse_big_data_cells")) 3247 3250 goto fail; 3248 3251 … … 3257 3260 } 3258 3261 3259 if(!regfi_unlock(file, file->cb_lock, "regfi_parse_big_data_cells"))3262 if(!regfi_unlock(file, &file->cb_lock, "regfi_parse_big_data_cells")) 3260 3263 goto fail; 3261 3264 … … 3267 3270 3268 3271 fail_locked: 3269 regfi_unlock(file, file->cb_lock, "regfi_parse_big_data_cells");3272 regfi_unlock(file, &file->cb_lock, "regfi_parse_big_data_cells"); 3270 3273 fail: 3271 3274 if(ret_val != NULL) … … 3361 3364 } 3362 3365 3363 if(!regfi_lock(file, file->cb_lock, "regfi_load_big_data"))3366 if(!regfi_lock(file, &file->cb_lock, "regfi_load_big_data")) 3364 3367 goto fail; 3365 3368 … … 3382 3385 } 3383 3386 3384 if(!regfi_unlock(file, file->cb_lock, "regfi_load_big_data"))3387 if(!regfi_unlock(file, &file->cb_lock, "regfi_load_big_data")) 3385 3388 goto fail; 3386 3389 … … 3397 3400 3398 3401 fail_locked: 3399 regfi_unlock(file, file->cb_lock, "regfi_load_big_data");3402 regfi_unlock(file, &file->cb_lock, "regfi_load_big_data"); 3400 3403 fail: 3401 3404 talloc_free(ret_val.buf); … … 3421 3424 return NULL; 3422 3425 3423 if(!regfi_read_lock(file, file->hbins_lock, "regfi_parse_unalloc_cells"))3426 if(!regfi_read_lock(file, &file->hbins_lock, "regfi_parse_unalloc_cells")) 3424 3427 { 3425 3428 range_list_free(ret_val); … … 3438 3441 while(curr_off < hbin->block_size) 3439 3442 { 3440 if(!regfi_lock(file, file->cb_lock, "regfi_parse_unalloc_cells"))3443 if(!regfi_lock(file, &file->cb_lock, "regfi_parse_unalloc_cells")) 3441 3444 break; 3442 3445 … … 3444 3447 &cell_len, &is_unalloc)) 3445 3448 { 3446 regfi_unlock(file, file->cb_lock, "regfi_parse_unalloc_cells");3449 regfi_unlock(file, &file->cb_lock, "regfi_parse_unalloc_cells"); 3447 3450 break; 3448 3451 } 3449 3452 3450 if(!regfi_unlock(file, file->cb_lock, "regfi_parse_unalloc_cells"))3453 if(!regfi_unlock(file, &file->cb_lock, "regfi_parse_unalloc_cells")) 3451 3454 break; 3452 3455 … … 3474 3477 } 3475 3478 3476 if(!regfi_rw_unlock(file, file->hbins_lock, "regfi_parse_unalloc_cells"))3479 if(!regfi_rw_unlock(file, &file->hbins_lock, "regfi_parse_unalloc_cells")) 3477 3480 { 3478 3481 range_list_free(ret_val);
Note: See TracChangeset
for help on using the changeset viewer.