call this directly if wanted. This can be called multiple times for
one file descriptor to set different iomasks. */
-void silc_schedule_set_listen_fd(int fd, unsigned int iomask)
+void silc_schedule_set_listen_fd(int fd, uint32 iomask)
{
assert(schedule.valid != FALSE);
assert(fd < schedule.fd_list.max_fd);
/* Calculate the next timeout for select() */ \
queue->timeout.tv_sec = task->timeout.tv_sec - curtime.tv_sec; \
queue->timeout.tv_usec = task->timeout.tv_usec - curtime.tv_usec; \
+ if (queue->timeout.tv_sec < 0) \
+ queue->timeout.tv_sec = 0; \
\
/* We wouldn't want to go under zero, check for it. */ \
if (queue->timeout.tv_usec < 0) { \
queue->timeout.tv_sec -= 1; \
+ if (queue->timeout.tv_sec < 0) \
+ queue->timeout.tv_sec = 0; \
queue->timeout.tv_usec += 1000000L; \
} \
} \
tasks. The select() listens to these file descriptors. */
SILC_SCHEDULE_SELECT_TASKS;
- if (schedule.max_fd == -1) {
- /*SILC_LOG_ERROR(("Nothing to listen, exiting"));*/
+ if (schedule.max_fd == -1 && !schedule.timeout)
return FALSE;
- }
if (schedule.timeout) {
SILC_LOG_DEBUG(("timeout: sec=%d, usec=%d", schedule.timeout->tv_sec,
&schedule.out, 0, schedule.timeout)) {
case -1:
/* Error */
+ if (errno == EINTR)
+ break;
+#if 1
+ if (errno == EINVAL && schedule.timeout) {
+ SILC_LOG_ERROR(("Invalid argument (invalid timeout): %lu %lu",
+ schedule.timeout->tv_sec, schedule.timeout->tv_usec));
+ }
+#endif
SILC_LOG_ERROR(("Error in select(): %s", strerror(errno)));
break;
case 0:
}
/* Start the scheduler loop */
- while (silc_schedule_one(-1)) ;
-}
-
-/* Run normal select() for `fd' and return after file descriptor changes
- status or timeout expires. The `event' is either SILC_TASK_READ or
- SILC_TASK_WRITE. */
-
-int silc_schedule_with_fd(int fd, unsigned int event,
- unsigned long usecs, unsigned long secs)
-{
- struct timeval *tp = NULL, timeout;
- fd_set *ip = NULL, in;
- fd_set *op = NULL, out;
- int ret;
-
- if (usecs + secs > 0) {
- timeout.tv_sec = secs;
- timeout.tv_usec = usecs;
- tp = &timeout;
- }
-
- if (event == SILC_TASK_READ) {
- FD_ZERO(&in);
- FD_SET(fd, &in);
- ip = ∈
- }
-
- if (event == SILC_TASK_WRITE) {
- FD_ZERO(&out);
- FD_SET(fd, &out);
- op = &out;
- }
-
- ret = select(fd + 1, ip, op, NULL, tp);
- switch (ret) {
- case -1:
- return FALSE;
- break;
- case 0:
- return FALSE;
- break;
- default:
- break;
- }
-
- return TRUE;
+ while (silc_schedule_one(-1))
+ ;
}