Example #1
0
static int aio_socket_release(struct epoll_context* ctx)
{
	if( 0 == __sync_sub_and_fetch_4(&ctx->ref, 1) )
	{
		if(0 != ctx->init && 0 != epoll_ctl(s_epoll, EPOLL_CTL_DEL, ctx->socket, &ctx->ev))
		{
			assert(EBADF == errno); // EBADF: socket close by user
			//		return errno;
		}

		if(ctx->own)
			close(ctx->socket);

		pthread_spin_destroy(&ctx->locker);

		if (ctx->ondestroy)
			ctx->ondestroy(ctx->param);

#if defined(DEBUG) || defined(_DEBUG)
		memset(ctx, 0xCC, sizeof(*ctx));
#endif
		free(ctx);
	}
	return 0;
}
Example #2
0
static int aio_socket_release(struct epoll_context* ctx)
{
	if( 0 == __sync_sub_and_fetch_4(&ctx->ref, 1) )
	{
		pthread_spin_destroy(&ctx->locker);

#if defined(DEBUG) || defined(_DEBUG)
		memset(ctx, 0xCC, sizeof(*ctx));
#endif
		free(ctx);
	}
	return 0;
}