예제 #1
0
/* Releases tcp_helper_resource_t on the tcp_helper_cluster_t.  If no
 * more tcp_helper_resource_t's, then frees it.
 *
 * This function will acquire the thc_mutex.
 */
void tcp_helper_cluster_release(tcp_helper_cluster_t* thc,
                                tcp_helper_resource_t* thr)
{
  mutex_lock(&thc_mutex);
  if( thr != NULL )
    thc_remove_thr(thc, thr);
  if( oo_atomic_dec_and_test(&thc->thc_ref_count) )
    thc_cluster_free(thc);
  mutex_unlock(&thc_mutex);
}
예제 #2
0
파일: epoll_fd.c 프로젝트: ido/openonload
static void citp_epoll_dtor(citp_fdinfo* fdi, int fdt_locked)
{
  struct citp_epoll_fd* ep = fdi_to_epoll(fdi);

  if (!oo_atomic_dec_and_test(&ep->refcount))
    return;

  CITP_FDTABLE_LOCK();
  ci_tcp_helper_close_no_trampoline(ep->shared->epfd);
  __citp_fdtable_reserve(ep->shared->epfd, 0);
  munmap(ep->shared, sizeof(*ep->shared));

  ci_tcp_helper_close_no_trampoline(ep->epfd_os);
  __citp_fdtable_reserve(ep->epfd_os, 0);
  CITP_FDTABLE_UNLOCK();

  CI_FREE_OBJ(ep);
}
예제 #3
0
void
oo_iobufset_resource_release(struct oo_iobufset *iobrs, int reset_pending)
{
  if (oo_atomic_dec_and_test(&iobrs->ref_count))
    oo_iobufset_resource_free(iobrs, reset_pending);
}
예제 #4
0
void oo_iobufset_pages_release(struct oo_buffer_pages *pages)
{
  if (oo_atomic_dec_and_test(&pages->ref_count))
    oo_iobufset_free_pages(pages);
}