@@ -504,15 +504,15 @@ PHP_APCU_API zend_bool apc_cache_store(
504
504
}
505
505
506
506
/* execute an insertion */
507
- if (!APC_WLOCK (cache -> header )) {
507
+ if (!apc_cache_wlock (cache )) {
508
508
free_entry (cache , entry );
509
509
return 0 ;
510
510
}
511
511
512
512
php_apc_try {
513
513
ret = apc_cache_wlocked_insert (cache , entry , exclusive );
514
514
} php_apc_finally {
515
- APC_WUNLOCK (cache -> header );
515
+ apc_cache_wunlock (cache );
516
516
} php_apc_end_try ();
517
517
518
518
if (!ret ) {
@@ -701,8 +701,7 @@ PHP_APCU_API void apc_cache_clear(apc_cache_t* cache)
701
701
return ;
702
702
}
703
703
704
- /* lock header */
705
- if (!APC_WLOCK (cache -> header )) {
704
+ if (!apc_cache_wlock (cache )) {
706
705
return ;
707
706
}
708
707
@@ -713,8 +712,7 @@ PHP_APCU_API void apc_cache_clear(apc_cache_t* cache)
713
712
cache -> header -> stime = apc_time ();
714
713
cache -> header -> nexpunges = 0 ;
715
714
716
- /* unlock header */
717
- APC_WUNLOCK (cache -> header );
715
+ apc_cache_wunlock (cache );
718
716
}
719
717
/* }}} */
720
718
@@ -734,7 +732,7 @@ PHP_APCU_API void apc_cache_default_expunge(apc_cache_t* cache, size_t size)
734
732
t = apc_time ();
735
733
736
734
/* get the lock for header */
737
- if (!APC_WLOCK (cache -> header )) {
735
+ if (!apc_cache_wlock (cache )) {
738
736
return ;
739
737
}
740
738
@@ -783,8 +781,7 @@ PHP_APCU_API void apc_cache_default_expunge(apc_cache_t* cache, size_t size)
783
781
}
784
782
}
785
783
786
- /* unlock header */
787
- APC_WUNLOCK (cache -> header );
784
+ apc_cache_wunlock (cache );
788
785
}
789
786
/* }}} */
790
787
@@ -797,12 +794,12 @@ PHP_APCU_API apc_cache_entry_t *apc_cache_find(apc_cache_t* cache, zend_string *
797
794
return NULL ;
798
795
}
799
796
800
- if (!APC_RLOCK (cache -> header )) {
797
+ if (!apc_cache_rlock (cache )) {
801
798
return NULL ;
802
799
}
803
800
804
801
entry = apc_cache_rlocked_find_incref (cache , key , t );
805
- APC_RUNLOCK (cache -> header );
802
+ apc_cache_runlock (cache );
806
803
807
804
return entry ;
808
805
}
@@ -818,12 +815,12 @@ PHP_APCU_API zend_bool apc_cache_fetch(apc_cache_t* cache, zend_string *key, tim
818
815
return 0 ;
819
816
}
820
817
821
- if (!APC_RLOCK (cache -> header )) {
818
+ if (!apc_cache_rlock (cache )) {
822
819
return 0 ;
823
820
}
824
821
825
822
entry = apc_cache_rlocked_find_incref (cache , key , t );
826
- APC_RUNLOCK (cache -> header );
823
+ apc_cache_runlock (cache );
827
824
828
825
if (!entry ) {
829
826
return 0 ;
@@ -847,12 +844,12 @@ PHP_APCU_API zend_bool apc_cache_exists(apc_cache_t* cache, zend_string *key, ti
847
844
return 0 ;
848
845
}
849
846
850
- if (!APC_RLOCK (cache -> header )) {
847
+ if (!apc_cache_rlock (cache )) {
851
848
return 0 ;
852
849
}
853
850
854
851
entry = apc_cache_rlocked_find_nostat (cache , key , t );
855
- APC_RUNLOCK (cache -> header );
852
+ apc_cache_runlock (cache );
856
853
857
854
return entry != NULL ;
858
855
}
@@ -872,7 +869,7 @@ PHP_APCU_API zend_bool apc_cache_update(
872
869
}
873
870
874
871
retry_update :
875
- if (!APC_WLOCK (cache -> header )) {
872
+ if (!apc_cache_wlock (cache )) {
876
873
return 0 ;
877
874
}
878
875
@@ -884,11 +881,11 @@ PHP_APCU_API zend_bool apc_cache_update(
884
881
entry -> mtime = t ;
885
882
}
886
883
887
- APC_WUNLOCK (cache -> header );
884
+ apc_cache_wunlock (cache );
888
885
return retval ;
889
886
}
890
887
891
- APC_WUNLOCK (cache -> header );
888
+ apc_cache_wunlock (cache );
892
889
if (insert_if_not_found ) {
893
890
/* Failed to find matching entry. Add key with value 0 and run the updater again. */
894
891
zval val ;
@@ -922,7 +919,7 @@ PHP_APCU_API zend_bool apc_cache_atomic_update_long(
922
919
}
923
920
924
921
retry_update :
925
- if (!APC_RLOCK (cache -> header )) {
922
+ if (!apc_cache_rlock (cache )) {
926
923
return 0 ;
927
924
}
928
925
@@ -934,11 +931,11 @@ PHP_APCU_API zend_bool apc_cache_atomic_update_long(
934
931
entry -> mtime = t ;
935
932
}
936
933
937
- APC_RUNLOCK (cache -> header );
934
+ apc_cache_runlock (cache );
938
935
return retval ;
939
936
}
940
937
941
- APC_RUNLOCK (cache -> header );
938
+ apc_cache_runlock (cache );
942
939
if (insert_if_not_found ) {
943
940
/* Failed to find matching entry. Add key with value 0 and run the updater again. */
944
941
zval val ;
@@ -971,8 +968,7 @@ PHP_APCU_API zend_bool apc_cache_delete(apc_cache_t *cache, zend_string *key)
971
968
/* calculate hash and slot */
972
969
apc_cache_hash_slot (cache , key , & h , & s );
973
970
974
- /* lock cache */
975
- if (!APC_WLOCK (cache -> header )) {
971
+ if (!apc_cache_wlock (cache )) {
976
972
return 0 ;
977
973
}
978
974
@@ -985,16 +981,14 @@ PHP_APCU_API zend_bool apc_cache_delete(apc_cache_t *cache, zend_string *key)
985
981
/* executing removal */
986
982
apc_cache_wlocked_remove_entry (cache , entry );
987
983
988
- /* unlock header */
989
- APC_WUNLOCK (cache -> header );
984
+ apc_cache_wunlock (cache );
990
985
return 1 ;
991
986
}
992
987
993
988
entry = & (* entry )-> next ;
994
989
}
995
990
996
- /* unlock header */
997
- APC_WUNLOCK (cache -> header );
991
+ apc_cache_wunlock (cache );
998
992
return 0 ;
999
993
}
1000
994
/* }}} */
@@ -1074,7 +1068,7 @@ PHP_APCU_API zend_bool apc_cache_info(zval *info, apc_cache_t *cache, zend_bool
1074
1068
return 0 ;
1075
1069
}
1076
1070
1077
- if (!APC_RLOCK (cache -> header )) {
1071
+ if (!apc_cache_rlock (cache )) {
1078
1072
return 0 ;
1079
1073
}
1080
1074
@@ -1127,7 +1121,7 @@ PHP_APCU_API zend_bool apc_cache_info(zval *info, apc_cache_t *cache, zend_bool
1127
1121
add_assoc_zval (info , "slot_distribution" , & slots );
1128
1122
}
1129
1123
} php_apc_finally {
1130
- APC_RUNLOCK (cache -> header );
1124
+ apc_cache_runlock (cache );
1131
1125
} php_apc_end_try ();
1132
1126
1133
1127
return 1 ;
@@ -1148,7 +1142,7 @@ PHP_APCU_API void apc_cache_stat(apc_cache_t *cache, zend_string *key, zval *sta
1148
1142
/* calculate hash and slot */
1149
1143
apc_cache_hash_slot (cache , key , & h , & s );
1150
1144
1151
- if (!APC_RLOCK (cache -> header )) {
1145
+ if (!apc_cache_rlock (cache )) {
1152
1146
return ;
1153
1147
}
1154
1148
@@ -1174,7 +1168,7 @@ PHP_APCU_API void apc_cache_stat(apc_cache_t *cache, zend_string *key, zval *sta
1174
1168
entry = entry -> next ;
1175
1169
}
1176
1170
} php_apc_finally {
1177
- APC_RUNLOCK (cache -> header );
1171
+ apc_cache_runlock (cache );
1178
1172
} php_apc_end_try ();
1179
1173
}
1180
1174
@@ -1234,19 +1228,11 @@ PHP_APCU_API void apc_cache_entry(apc_cache_t *cache, zend_string *key, zend_fca
1234
1228
return ;
1235
1229
}
1236
1230
1237
- #ifndef APC_LOCK_RECURSIVE
1238
- if (APCG (recursion )++ == 0 ) {
1239
- if (!APC_WLOCK (cache -> header )) {
1240
- APCG (recursion )-- ;
1241
- return ;
1242
- }
1243
- }
1244
- #else
1245
- if (!APC_WLOCK (cache -> header )) {
1231
+ if (!apc_cache_wlock (cache )) {
1246
1232
return ;
1247
1233
}
1248
- #endif
1249
1234
1235
+ APCG (entry_level )++ ;
1250
1236
php_apc_try {
1251
1237
entry = apc_cache_rlocked_find_incref (cache , key , now );
1252
1238
if (!entry ) {
@@ -1271,14 +1257,8 @@ PHP_APCU_API void apc_cache_entry(apc_cache_t *cache, zend_string *key, zend_fca
1271
1257
apc_cache_entry_release (cache , entry );
1272
1258
}
1273
1259
} php_apc_finally {
1274
- #ifndef APC_LOCK_RECURSIVE
1275
- if (-- APCG (recursion ) == 0 ) {
1276
- APC_WUNLOCK (cache -> header );
1277
- }
1278
- #else
1279
- APC_WUNLOCK (cache -> header );
1280
- #endif
1281
-
1260
+ APCG (entry_level )-- ;
1261
+ apc_cache_wunlock (cache );
1282
1262
} php_apc_end_try ();
1283
1263
}
1284
1264
/*}}}*/
0 commit comments