51 if (it->getSource() == source)
64 if (it->getSource() == source)
66 it->getMask() = eventMask;
86 fd_set inFd, outFd, excFd;
92 SourceList::iterator it;
94 int fd = it->getSource()->getfd();
97 if (it->getMask() &
Exception) FD_SET(fd, &excFd);
98 if (it->getMask() && fd > maxFd) maxFd = fd;
104 nEvents = select(maxFd+1, &inFd, &outFd, &excFd,
NULL);
108 tv.tv_sec = (int)floor(timeout);
109 tv.tv_usec = ((int)floor(1000000.0 * (timeout-floor(timeout)))) % 1000000;
110 nEvents = select(maxFd+1, &inFd, &outFd, &excFd, &tv);
115 XmlRpcUtil::error(
"Error in XmlRpcDispatch::work: error in select (%d).", nEvents);
123 SourceList::iterator thisIt = it++;
125 int fd = src->
getfd();
126 unsigned newMask = (unsigned) -1;
129 if (FD_ISSET(fd, &inFd))
131 if (FD_ISSET(fd, &outFd))
133 if (FD_ISSET(fd, &excFd))
140 }
else if (newMask != (
unsigned) -1) {
141 thisIt->getMask() = newMask;
151 for (SourceList::iterator it=closeList.begin(); it!=closeList.end(); ++it) {
161 std::cout<<
"XmlRpc : time out when connect to database " << std::endl;
188 for (SourceList::iterator it=closeList.begin(); it!=closeList.end(); ++it)
189 it->getSource()->close();
201 return ((
double) tbuff.time + ((
double)tbuff.millitm / 1000.0) +
202 ((
double) tbuff.timezone * 60));
207 gettimeofday(&tv, &tz);
208 return (tv.tv_sec + tv.tv_usec / 1000000.0);
XmlRpcDispatch()
Constructor.
void removeSource(XmlRpcSource *source)
@ ReadableEvent
data available to read
@ WritableEvent
connected/data can be written without blocking
void exit()
Exit from work routine.
void clear()
Clear all sources from the monitored sources list. Sources are closed.
void setSourceEvents(XmlRpcSource *source, unsigned eventMask)
Modify the types of events to watch for on this source.
std::list< MonitoredSource > SourceList
void addSource(XmlRpcSource *source, unsigned eventMask)
An RPC source represents a file descriptor to monitor.
virtual void close()
Close the owned fd. If deleteOnClose was specified at construction, the object is deleted.
int getfd() const
Return the file descriptor being monitored.
bool getKeepOpen() const
Return whether the file descriptor should be kept open if it is no longer monitored.
virtual unsigned handleEvent(unsigned eventType)=0
Return true to continue monitoring this source.
static void error(const char *fmt,...)
Dump error messages somewhere.