static void ngx_http_cp_hash_destory(ngx_http_cp_hash_t *hash) { ngx_http_cp_monitored_cookie_t *m_cookie, *next; ngx_uint_t i; if (!hash->buckets) { return; } for (i = 0; i < hash->nr_buckets; i++) { m_cookie = hash->buckets[i]; while (m_cookie != NULL) { /*the first one*/ next = m_cookie->next; /* free the memory */ ngx_http_session_shm_free_nolock(m_cookie->cookie_name.data); ngx_http_session_shm_free_nolock(m_cookie); m_cookie = next; } } ngx_http_session_shm_free_nolock(hash->buckets); }
static ngx_int_t ngx_http_cp_hash_delete(ngx_http_cp_hash_t *hash, ngx_str_t *cookie_name) { ngx_uint_t key = 0; ngx_http_cp_monitored_cookie_t *m_cookie, *prev; key = ngx_http_cp_hash_key(hash, cookie_name); prev = m_cookie = hash->buckets[key]; for (; m_cookie != NULL; prev = m_cookie, m_cookie = m_cookie->next) { if (m_cookie->cookie_name.len != cookie_name->len) { continue; } if (!memcmp(m_cookie->cookie_name.data, cookie_name->data, cookie_name->len)) { /* found the cookie */ if (prev == m_cookie) { /*the first one*/ hash->buckets[key] = m_cookie->next; } else { prev->next = m_cookie->next; } /* free the memory */ ngx_http_session_shm_free_nolock(m_cookie->cookie_name.data); ngx_http_session_shm_free_nolock(m_cookie); return NGX_OK; } } return NGX_ERROR; }
static void ngx_http_cp_destroy_session_ctx_handler(void *ctx) { ngx_http_session_ctx_t *session_ctx; session_ctx = (ngx_http_session_ctx_t *)ctx; return ngx_http_session_shm_free_nolock(session_ctx->data); }
static void ngx_http_cp_destroy_session_ctx_handler(void *ctx) { ngx_http_session_ctx_t *session_ctx; ngx_http_cp_session_ctx_t *cp_ctx; session_ctx = (ngx_http_session_ctx_t *)ctx; cp_ctx = session_ctx->data; ngx_http_cp_hash_destory(&cp_ctx->monitored_cookies); return ngx_http_session_shm_free_nolock(session_ctx->data); }