Beispiel #1
0
void *io_loop(void *arg)
{
	struct io *io = (struct io *) arg;
	struct pfiled *pfiled = io->pfiled;
	struct xseg *xseg = pfiled->xseg;
	uint32_t portno = pfiled->portno;
	struct xseg_request *accepted;

	for (;;) {
		accepted = NULL;
		if (!isTerminate())
			accepted = xseg_accept(xseg, portno, 0);
		if (accepted) {
			io->req = accepted;
			wake_up_next_iothread(pfiled);
			handle_accepted(pfiled, io);
		}
		else {
			pthread_mutex_lock(&io->lock);
			free_io(pfiled, io);
			pthread_cond_wait(&io->cond, &io->lock);
			pthread_mutex_unlock(&io->lock);
		}
	}

	return NULL;
}
Beispiel #2
0
static int pfiled_loop(struct pfiled *pfiled)
{
	struct xseg *xseg = pfiled->xseg;
	uint32_t portno = pfiled->portno;
	/* GCC + pthreads glitch? */
	struct io *io;
	(void)io;

	for (;!(isTerminate() && xq_count(&pfiled->free_ops) == pfiled->nr_ops);) {
		io = wake_up_next_iothread(pfiled);
		xseg_prepare_wait(xseg, portno);
		xseg_wait_signal(xseg, 1000000UL);
	}

	return 0;
}
Beispiel #3
0
/**
 * \brief 服务程序框架的主函数
 */
void zService::main()
{
	Zebra::logger->trace("zService::main");
	//初始化程序,并确认服务器启动成功
	if (init()
	&& validate())
	{
		//运行主回调线程
		while(!isTerminate())
		{
			if (!serviceCallback())
			{
				break;
			}
		}
	}

	//结束程序,释放相应的资源
	final();
 CCategoryParserDriver::~CCategoryParserDriver()
 {
    CHECK_OBJECT_STATE( categoryStackSize() == 1 || isTerminate(), "Category stack is broken" );
 }