Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issues#107 https://github.com/Tencent/libco/issues/107 #120

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ endif
COLIB_OBJS=co_epoll.o co_routine.o co_hook_sys_call.o coctx_swap.o coctx.o
#co_swapcontext.o

PROGS = colib example_poll example_echosvr example_echocli example_thread example_cond example_specific example_copystack example_closure
PROGS = colib example_poll example_echosvr example_echocli example_thread example_cond \
example_specific example_copystack example_closure example_setenv

all:$(PROGS)

Expand Down
13 changes: 10 additions & 3 deletions example_poll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,23 +135,30 @@ static void *poll_routine( void *arg )
int ret = poll( pf,iWaitCnt,1000 );
printf("co %p poll wait %ld ret %d\n",
co_self(),iWaitCnt,ret);
int nready = ret;
for(int i=0;i<(int)iWaitCnt;i++)
{
printf("co %p fire fd %d revents 0x%X POLLOUT 0x%X POLLERR 0x%X POLLHUP 0x%X\n",
if ( nready <= 0 )
break;
if (pf[i].revents & (POLLOUT | POLLERR | POLLHUP))
{
printf("co %p fire fd %d revents 0x%X POLLOUT 0x%X POLLERR 0x%X POLLHUP 0x%X\n",
co_self(),
pf[i].fd,
pf[i].revents,
POLLOUT,
POLLERR,
POLLHUP
);
setRaiseFds.insert( pf[i].fd );
setRaiseFds.insert( pf[i].fd );
nready--;
}
}
if( setRaiseFds.size() == v.size())
{
break;
}
if( ret <= 0 )
if( ret < 0 )
{
break;
}
Expand Down