Implement generalied IOMux implementation operations
Fix serious bug in iomix_timers_run
This commit is contained in:
+11
-9
@@ -48,7 +48,7 @@ struct IOMux *iomux_create_ex(enum IOMUX_TYPE type, struct UCoreClock *uclock)
|
||||
|
||||
void iomux_delete(struct IOMux *mux)
|
||||
{
|
||||
mux->delete_impl(mux);
|
||||
mux->ops.delete_impl(mux);
|
||||
memset(mux, 0xfa, sizeof *mux);
|
||||
free(mux);
|
||||
}
|
||||
@@ -74,17 +74,18 @@ static int iomux_run_timers(struct IOMux *mux, struct timeval *timeout)
|
||||
struct timeval now;
|
||||
mux->uclock->now(mux->uclock, &now);
|
||||
future_to_interval(&first_timer, &now, timeout);
|
||||
/* TRACEF("now %d %d future %d %d interval %d %d\n", mux->now.tv_sec, mux->now.tv_usec,
|
||||
/*TRACEF("now %d %d future %d %d interval %d %d\n", now.tv_sec, now.tv_usec,
|
||||
first_timer.tv_sec, first_timer.tv_usec,
|
||||
timeout.tv_sec, timeout.tv_usec);
|
||||
*/
|
||||
timeout->tv_sec, timeout->tv_usec);
|
||||
*/
|
||||
|
||||
assert(timeout->tv_sec >= 0);
|
||||
assert(timeout->tv_usec >= 0);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 9;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int iomux_run(struct IOMux *mux)
|
||||
@@ -95,12 +96,13 @@ int iomux_run(struct IOMux *mux)
|
||||
struct timeval *timeoutp;
|
||||
|
||||
if (iomux_run_timers(mux, &timeout)) {
|
||||
TRACEF("NULL\n");
|
||||
timeoutp = &timeout;
|
||||
} else {
|
||||
timeoutp = NULL;
|
||||
}
|
||||
|
||||
rc = mux->run_impl(mux, timeoutp);
|
||||
rc = mux->ops.run_impl(mux, timeoutp);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
@@ -128,7 +130,7 @@ int iomux_register_fd(struct IOMux *mux, struct IOMuxFD *fd)
|
||||
assert(fd != NULL);
|
||||
assert(fd->callback != NULL);
|
||||
assert(fd->fd >= 0);
|
||||
return mux->register_fd_impl(mux, fd);
|
||||
return mux->ops.register_fd_impl(mux, fd);
|
||||
}
|
||||
|
||||
int iomux_unregister_fd(struct IOMux *mux, struct IOMuxFD *fd)
|
||||
@@ -136,7 +138,7 @@ int iomux_unregister_fd(struct IOMux *mux, struct IOMuxFD *fd)
|
||||
assert(mux != NULL);
|
||||
assert(fd != NULL);
|
||||
assert(fd->fd >= 0);
|
||||
return mux->unregister_fd_impl(mux, fd);
|
||||
return mux->ops.unregister_fd_impl(mux, fd);
|
||||
}
|
||||
|
||||
int iomux_update_events(struct IOMux *mux, struct IOMuxFD *fd, unsigned int what)
|
||||
@@ -148,7 +150,7 @@ int iomux_update_events(struct IOMux *mux, struct IOMuxFD *fd, unsigned int what
|
||||
assert(fd->fd >= 0);
|
||||
|
||||
if (fd->what != what) {
|
||||
mux->update_events_impl(mux, fd);
|
||||
mux->ops.update_events_impl(mux, fd);
|
||||
} else {
|
||||
rc = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user