/** * @brief Compare NLM owners * * @param[in] owner1 A client * @param[in] owner2 Another client * * @retval 0 on equality. * @retval 1 on inequality. */ int compare_nlm_owner(state_owner_t *owner1, state_owner_t *owner2) { if (isFullDebug(COMPONENT_STATE) && isDebug(COMPONENT_HASHTABLE)) { char str1[LOG_BUFF_LEN / 2]; char str2[LOG_BUFF_LEN / 2]; struct display_buffer dspbuf1 = {sizeof(str1), str1, str1}; struct display_buffer dspbuf2 = {sizeof(str2), str2, str2}; display_nlm_owner(&dspbuf1, owner1); display_nlm_owner(&dspbuf2, owner2); LogFullDebug(COMPONENT_STATE, "{%s} vs {%s}", str1, str2); } if (owner1 == NULL || owner2 == NULL) return 1; if (owner1 == owner2) return 0; if (compare_nlm_client (owner1->so_owner.so_nlm_owner.so_client, owner2->so_owner.so_nlm_owner.so_client) != 0) return 1; if (owner1->so_owner.so_nlm_owner.so_nlm_svid != owner2->so_owner.so_nlm_owner.so_nlm_svid) return 1; if (owner1->so_owner_len != owner2->so_owner_len) return 1; return memcmp(owner1->so_owner_val, owner2->so_owner_val, owner1->so_owner_len); }
int compare_nlm_owner(state_owner_t *powner1, state_owner_t *powner2) { if(isFullDebug(COMPONENT_STATE) && isDebug(COMPONENT_HASHTABLE)) { char str1[HASHTABLE_DISPLAY_STRLEN]; char str2[HASHTABLE_DISPLAY_STRLEN]; display_nlm_owner(powner1, str1); display_nlm_owner(powner2, str2); LogFullDebug(COMPONENT_STATE, "{%s} vs {%s}", str1, str2); } if(powner1 == NULL || powner2 == NULL) return 1; if(powner1 == powner2) return 0; if(compare_nlm_client(powner1->so_owner.so_nlm_owner.so_client, powner2->so_owner.so_nlm_owner.so_client) != 0) return 1; /* Handle special owner that matches any lock owner with the same nlm client */ if(powner1->so_owner_len == -1 || powner2->so_owner_len == -1) return 0; if(powner1->so_owner.so_nlm_owner.so_nlm_svid != powner2->so_owner.so_nlm_owner.so_nlm_svid) return 1; if(powner1->so_owner_len != powner2->so_owner_len) return 1; return memcmp(powner1->so_owner_val, powner2->so_owner_val, powner1->so_owner_len); }
int compare_nlm_client_key(hash_buffer_t * buff1, hash_buffer_t * buff2) { return compare_nlm_client(buff1->pdata, buff2->pdata); } /* compare_nlm_client */
/** * @brief Compare NLM clients in the hash table * * @param[in] buff1 A key * @param[in] buff2 Another key * * @retval 0 on equality. * @retval 1 on inequality. */ int compare_nlm_client_key(struct gsh_buffdesc *buff1, struct gsh_buffdesc *buff2) { return compare_nlm_client(buff1->addr, buff2->addr); }