GNU General Public License for more details.
*/
-/*
- * $Id$
- * $Log$
- * Revision 1.2 2000/09/28 08:50:31 priikone
- * Added silc_schedule_one function to run the scheduler only ones.
- * Patch by cras.
- *
- * Revision 1.1 2000/09/13 17:45:16 priikone
- * Splitted SILC core library. Core library includes now only
- * SILC protocol specific stuff. New utility library includes the
- * old stuff from core library that is more generic purpose stuff.
- *
- * Revision 1.3 2000/07/18 06:51:58 priikone
- * Debug version bug fixes.
- *
- * Revision 1.2 2000/07/05 06:06:35 priikone
- * Global cosmetic change.
- *
- * Revision 1.1.1.1 2000/06/27 11:36:55 priikone
- * Imported from internal CVS/Added Log headers.
- *
- *
- */
+/* $Id$ */
#include "silcincludes.h"
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);
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.timeout->tv_usec));
}
+ if (timeout_usecs >= 0) {
+ timeout.tv_sec = 0;
+ timeout.tv_usec = timeout_usecs;
+ schedule.timeout = &timeout;
+ }
+
/* This is the main select(). The program blocks here until some
of the selected file descriptors change status or the selected
timeout expires. */
SILC_LOG_DEBUG(("Select"));
- if (timeout_usecs < 0)
- memcpy(&timeout, schedule.timeout, sizeof(timeout));
- else {
- timeout.tv_sec = 0;
- timeout.tv_usec = timeout_usecs;
- }
switch (select(schedule.max_fd + 1, &schedule.in,
- &schedule.out, 0, &timeout)) {
+ &schedule.out, 0, schedule.timeout)) {
case -1:
/* Error */
+ if (errno == EINTR)
+ break;
SILC_LOG_ERROR(("Error in select(): %s", strerror(errno)));
break;
case 0:
}
/* Start the scheduler loop */
- while (silc_schedule_one(-1)) ;
+ while (silc_schedule_one(-1))
+ ;
}