Permalink
Browse files

MFH: fix #41134 (zend_ts_hash_clean not thread-safe)

fix also zend_ts_hash_*destroy()
  • Loading branch information...
tony2001 committed May 11, 2007
1 parent c1e84f1 commit c8cfd3b99aed9ca4bbcaf4f1221f38969f97965f
Showing with 10 additions and 2 deletions.
  1. +10 −2 Zend/zend_ts_hash.c
View
@@ -81,17 +81,22 @@ ZEND_API int _zend_ts_hash_init_ex(TsHashTable *ht, uint nSize, hash_func_t pHas
ZEND_API void zend_ts_hash_destroy(TsHashTable *ht)
{
+ begin_write(ht);
+ zend_hash_destroy(TS_HASH(ht));
+ end_write(ht);
+
#ifdef ZTS
tsrm_mutex_free(ht->mx_reader);
tsrm_mutex_free(ht->mx_writer);
#endif
- zend_hash_destroy(TS_HASH(ht));
}
ZEND_API void zend_ts_hash_clean(TsHashTable *ht)
{
ht->reader = 0;
+ begin_write(ht);
zend_hash_clean(TS_HASH(ht));
+ end_write(ht);
}
ZEND_API int _zend_ts_hash_add_or_update(TsHashTable *ht, char *arKey, uint nKeyLength, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC)
@@ -140,11 +145,14 @@ ZEND_API int zend_ts_hash_add_empty_element(TsHashTable *ht, char *arKey, uint n
ZEND_API void zend_ts_hash_graceful_destroy(TsHashTable *ht)
{
+ begin_write(ht);
+ zend_hash_graceful_destroy(TS_HASH(ht));
+ end_write(ht);
+
#ifdef ZTS
tsrm_mutex_free(ht->mx_reader);
tsrm_mutex_free(ht->mx_reader);
#endif
- zend_hash_graceful_destroy(TS_HASH(ht));
}
ZEND_API void zend_ts_hash_apply(TsHashTable *ht, apply_func_t apply_func TSRMLS_DC)

0 comments on commit c8cfd3b

Please sign in to comment.