]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Revert "add thread safe hash multi delete function and make callback optional"
authordschreiber <d@d-man.org>
Tue, 19 Jun 2012 15:51:28 +0000 (08:51 -0700)
committerdschreiber <d@d-man.org>
Tue, 19 Jun 2012 15:51:28 +0000 (08:51 -0700)
I don't see this command being used anywhere. Since I don't like to touch core files unless absolutely necessary I'm reverting these two changes. I've emailed the author, Tamas, for an explanation. The other patches for FS-3432 (merged in now) appear to work fine without this commit.

This reverts commit fbcb86226581cdcc66fc7b633b505906c207a4cd.

src/include/switch_core.h
src/switch_core_hash.c

index a3d40e690e83ff72b97f1aae9e9e62792bd3d0c4..05d6e0aa4813fd41509037ce3d4d869f752e0b4b 100644 (file)
@@ -1277,7 +1277,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_locked(_In_ switch_hash_
   \brief Delete data from a hash based on desired key
   \param hash the hash to delete from
   \param key the key from which to delete the data
-  \param rwlock optional rwlock to wrlock
+  \param mutex optional rwlock to wrlock
   \return SWITCH_STATUS_SUCCESS if the data is deleted
 */
 SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_wrlock(_In_ switch_hash_t *hash, _In_z_ const char *key, _In_opt_ switch_thread_rwlock_t *rwlock);
@@ -1290,26 +1290,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_wrlock(_In_ switch_hash_
 */
 SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_multi(_In_ switch_hash_t *hash, _In_ switch_hash_delete_callback_t callback, _In_opt_ void *pData);
 
-/*! 
-  \brief Delete data from a hash based on callback function
-  \param hash the hash to delete from
-  \param callback the function to call which returns SWITCH_TRUE to delete, SWITCH_FALSE to preserve
-  \param rwlock optional rwlock to wrlock
-  \return SWITCH_STATUS_SUCCESS if any data is deleted
-*/
-                                                               
-SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_multi_wrlock(_In_ switch_hash_t *hash, _In_ switch_hash_delete_callback_t callback, _In_opt_ void *pData, _In_ switch_thread_rwlock_t *rwlock);
-
-/*! 
-  \brief Delete data from a hash based on callback function
-  \param hash the hash to delete from
-  \param callback the function to call which returns SWITCH_TRUE to delete, SWITCH_FALSE to preserve
-  \param mutex optional mutex to lock
-  \return SWITCH_STATUS_SUCCESS if any data is deleted
-*/
-                                               
-SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_multi_locked(_In_ switch_hash_t *hash, _In_ switch_hash_delete_callback_t callback, _In_opt_ void *pData, _In_ switch_mutex_t *mutex);
-
 /*! 
   \brief Retrieve data from a given hash
   \param hash the hash to retrieve from
index ed5c4c2ca43b6b55b2e2a5bb103636504d65fa49..4ac3d2620eed7cbbb206e89e2cf39caa15197601 100644 (file)
@@ -157,7 +157,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_multi(switch_hash_t *has
        switch_event_create_subclass(&event, SWITCH_EVENT_CLONE, NULL);
        switch_assert(event);
        
-       /* iterate through the hash, call callback, if callback is NULL or returns true, put the key on the list (event)
+       /* iterate through the hash, call callback, if callback returns true, put the key on the list (event)
           When done, iterate through the list deleting hash entries
         */
        
@@ -165,7 +165,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_multi(switch_hash_t *has
                const void *key;
                void *val;
                switch_hash_this(hi, &key, NULL, &val);
-               if (!callback || callback(key, val, pData)) {
+               if (callback(key, val, pData)) {
                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "delete", (const char *) key);
                }
        }
@@ -182,40 +182,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_multi(switch_hash_t *has
        return status;
 }
 
-SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_multi_wrlock(switch_hash_t *hash, switch_hash_delete_callback_t callback, void *pData, switch_thread_rwlock_t *rwlock) 
-{
-       switch_status_t status = SWITCH_STATUS_SUCCESS;
-       
-       if (rwlock) {
-               switch_thread_rwlock_wrlock(rwlock);
-       }
-       
-       status = switch_core_hash_delete_multi(hash, callback, pData);
-
-       if (rwlock) {
-               switch_thread_rwlock_unlock(rwlock);
-       }
-
-       return status;
-}
-
-SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_multi_locked(switch_hash_t *hash, switch_hash_delete_callback_t callback, void *pData, switch_mutex_t *mutex)
-{
-       switch_status_t status = SWITCH_STATUS_SUCCESS;
-       
-       if (mutex) {
-               switch_mutex_lock(mutex);
-       }
-       
-       status = switch_core_hash_delete_multi(hash, callback, pData);
-
-       if (mutex) {
-               switch_mutex_unlock(mutex);
-       }
-
-       return status;
-}
-
 
 SWITCH_DECLARE(void *) switch_core_hash_find(switch_hash_t *hash, const char *key)
 {