@@ -108,10 +108,10 @@ static int php_memc_list_entry(void) {
108
108
#define MEMC_VAL_COMPRESSION_ZLIB (1<<1)
109
109
#define MEMC_VAL_COMPRESSION_FASTLZ (1<<2)
110
110
111
- #define MEMC_VAL_GET_FLAGS (internal_flags ) ((internal_flags & MEMC_MASK_INTERNAL) >> 4)
112
- #define MEMC_VAL_SET_FLAG (internal_flags , internal_flag ) ((internal_flags) |= ((internal_flag << 4) & MEMC_MASK_INTERNAL))
113
- #define MEMC_VAL_HAS_FLAG (internal_flags , internal_flag ) ((MEMC_VAL_GET_FLAGS(internal_flags) & internal_flag) == internal_flag)
114
- #define MEMC_VAL_DEL_FLAG (internal_flags , internal_flag ) internal_flags &= ~((internal_flag << 4) & MEMC_MASK_INTERNAL)
111
+ #define MEMC_VAL_GET_FLAGS (internal_flags ) ((( internal_flags) & MEMC_MASK_INTERNAL) >> 4)
112
+ #define MEMC_VAL_SET_FLAG (internal_flags , internal_flag ) ((internal_flags) |= ((( internal_flag) << 4) & MEMC_MASK_INTERNAL))
113
+ #define MEMC_VAL_HAS_FLAG (internal_flags , internal_flag ) ((MEMC_VAL_GET_FLAGS(internal_flags) & ( internal_flag)) == ( internal_flag) )
114
+ #define MEMC_VAL_DEL_FLAG (internal_flags , internal_flag ) ( internal_flags &= ( ~((( internal_flag) << 4) & MEMC_MASK_INTERNAL)) )
115
115
116
116
/****************************************
117
117
User-defined flags
@@ -838,7 +838,7 @@ zend_bool s_compress_value (php_memc_compression_type compression_type, zend_str
838
838
839
839
if (compressed_size > 0 ) {
840
840
compress_status = 1 ;
841
- MEMC_VAL_SET_FLAG (* flags , MEMC_VAL_COMPRESSION_FASTLZ );
841
+ MEMC_VAL_SET_FLAG (* flags , MEMC_VAL_COMPRESSED | MEMC_VAL_COMPRESSION_FASTLZ );
842
842
}
843
843
}
844
844
break ;
@@ -850,7 +850,7 @@ zend_bool s_compress_value (php_memc_compression_type compression_type, zend_str
850
850
851
851
if (status == Z_OK ) {
852
852
compress_status = 1 ;
853
- MEMC_VAL_SET_FLAG (* flags , MEMC_VAL_COMPRESSION_ZLIB );
853
+ MEMC_VAL_SET_FLAG (* flags , MEMC_VAL_COMPRESSED | MEMC_VAL_COMPRESSION_ZLIB );
854
854
}
855
855
}
856
856
break ;
@@ -862,13 +862,14 @@ zend_bool s_compress_value (php_memc_compression_type compression_type, zend_str
862
862
863
863
if (!compress_status ) {
864
864
php_error_docref (NULL , E_WARNING , "could not compress value" );
865
+ MEMC_VAL_DEL_FLAG (* flags , MEMC_VAL_COMPRESSED | MEMC_VAL_COMPRESSION_FASTLZ | MEMC_VAL_COMPRESSION_ZLIB );
865
866
efree (buffer );
866
867
return 0 ;
867
868
}
868
869
869
870
/* This means the value was too small to be compressed, still a success */
870
871
if (ZSTR_LEN (payload ) < (compressed_size * MEMC_G (compression_factor ))) {
871
- MEMC_VAL_DEL_FLAG (* flags , MEMC_VAL_COMPRESSED );
872
+ MEMC_VAL_DEL_FLAG (* flags , MEMC_VAL_COMPRESSED | MEMC_VAL_COMPRESSION_FASTLZ | MEMC_VAL_COMPRESSION_ZLIB );
872
873
efree (buffer );
873
874
return 1 ;
874
875
}
0 commit comments