apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Damir Dezeljin <program...@mbss.org>
Subject Poll() problem
Date Sat, 05 Jun 2004 05:33:30 GMT

I would like to use poll() functions to check for available data on read
part of a pipe to avoid blocked read. Unfortunately I can't get it
working. When executing an apr_pollset_add(), I always get 'Bad file
descriptor' error.

So I created a simplest pice of code and tried with it. Unfortunately also
it doesn't work. Do anyone have a clue what is going on (what I made wrong
? :) ):
apr_pollset_t *pSet_p=NULL;
apr_pollfd_t pollfd;
apr_file_t *aFd=NULL;

aRv = apr_file_open(&aFd, "c:\\test.txt", APR_READ, APR_UREAD, pool_p);

/* The below line is working fine if uncomented
 * aRv = apr_file_read(aFd, buf, &len);

aRv = apr_pollset_create(&pSet_p, 1, pool_p, 0);

// BTW: is the below line necesary (it doesn't matter
//      anyway it doesn't work.
// pollfd.p         = pool_p;
pollfd.desc_type    = APR_POLL_FILE;
pollfd.reqevents    = APR_POLLNVAL | APR_POLLIN | APR_POLLOUT;
pollfd.desc.f       = aFd;

aRv = apr_pollset_add(pSet_p, &pollfd);
APR_CHECK_ERR(aRv);   // Tu javi error


View raw message