PARA_INFO_LOG("server_socket: %d\n", server_socket);
init_admissible_files(OPT_STRING_VAL(AFS_INITIAL_MODE));
register_command_task(&s);
- s.default_timeout.tv_sec = 0;
- s.default_timeout.tv_usec = 999 * 1000;
+ s.default_timeout = 1000;
ret = write(socket_fd, "\0", 1);
if (ret != 1) {
if (ret == 0)
sigaction(SIGINT, &act, NULL);
sched.select_function = i9e_select;
- sched.default_timeout.tv_sec = 1;
+ sched.default_timeout = 1000;
ret = i9e_open(&ici, &sched);
if (ret < 0)
goto out;
.context = signal_task,
}, &sched);
- sched.default_timeout.tv_sec = 2;
- sched.default_timeout.tv_usec = 999 * 1000;
+ sched.default_timeout = 2999;
ret = schedule(&sched);
audiod_cleanup();
sched_shutdown(&sched);
static int execute_client_command(const char *cmd, char **result)
{
int ret;
- struct sched command_sched = {.default_timeout = {.tv_sec = 1}};
+ struct sched command_sched = {.default_timeout = 1000};
struct exec_task exec_task = {
.result_buf = para_strdup(""),
.result_size = 1,
int ret;
crypt_init();
- sched.default_timeout.tv_sec = 1;
+ sched.default_timeout = 1000;
ret = client_parse_config(argc, argv, &ct, &client_loglevel);
if (ret < 0)
if test $HAVE_OSS = yes -o $HAVE_ALSA = yes; then
build_mixer="yes"
executables="$executables mixer"
- mixer_errlist_objs="mixer exec string fd lsu version"
+ mixer_errlist_objs="mixer exec string fd time lsu version"
if test $HAVE_OSS = yes; then
mixer_errlist_objs="$mixer_errlist_objs oss_mix"
fi
lsu
net
fd
+ time
version
"
if test $HAVE_READLINE = yes; then
buffer_tree
interactive
sched
- time
"
fi
audioc_objs="$audioc_errlist_objs"
* \param n The highest-numbered descriptor in any of the two sets, plus 1.
* \param readfds fds that should be checked for readability.
* \param writefds fds that should be checked for writablility.
- * \param timeout_tv upper bound on the amount of time elapsed before select()
- * returns.
+ * \param timeout Upper bound in milliseconds.
*
* \return The return value of the underlying select() call on success, the
* negative system error code on errors.
* All arguments are passed verbatim to select(2).
* \sa select(2) select_tut(2).
*/
-int para_select(int n, fd_set *readfds, fd_set *writefds,
- struct timeval *timeout_tv)
+int para_select(int n, fd_set *readfds, fd_set *writefds, int timeout)
{
int ret;
+ struct timeval tv;
+
+ ms2tv(timeout, &tv);
do
- ret = select(n, readfds, writefds, NULL, timeout_tv);
+ ret = select(n, readfds, writefds, NULL, &tv);
while (ret < 0 && errno == EINTR);
if (ret < 0)
return -ERRNO_TO_PARA_ERROR(errno);
int write_ok(int fd)
{
- struct timeval tv;
fd_set wfds;
FD_ZERO(&wfds);
FD_SET(fd, &wfds);
- tv.tv_sec = 0;
- tv.tv_usec = 0;
- return para_select(fd + 1, NULL, &wfds, &tv);
+ return para_select(fd + 1, NULL, &wfds, 0);
}
/**
int write_all(int fd, const char *buf, size_t len);
__printf_2_3 int write_va_buffer(int fd, const char *fmt, ...);
bool file_exists(const char *);
-int para_select(int n, fd_set *readfds, fd_set *writefds,
- struct timeval *timeout_tv);
+int para_select(int n, fd_set *readfds, fd_set *writefds, int timeout);
__must_check int mark_fd_nonblocking(int fd);
__must_check int mark_fd_blocking(int fd);
void para_fd_set(int fd, fd_set *fds, int *max_fileno);
EMBRACE(.name = "stdout", .parent = parent));
stdout_task_register(sot, &s);
- s.default_timeout.tv_sec = 1;
- s.default_timeout.tv_usec = 0;
+ s.default_timeout = 1000;
btr_log_tree(sit->btrn, LL_INFO);
ret = schedule(&s);
sched_shutdown(&s);
struct status_task status_task = {.fd = -1};
struct input_task input_task = {.task = NULL};
struct signal_task *signal_task;
- struct sched sched = {.default_timeout = {.tv_sec = 1}};
+ struct sched sched = {.default_timeout = 1000};
exec_task.task = task_register(&(struct task_info) {
.name = "exec",
static bool input_available(void)
{
fd_set rfds;
- struct timeval tv = {0, 0};
int ret;
FD_ZERO(&rfds);
FD_SET(i9ep->ici->fds[0], &rfds);
- ret = para_select(1, &rfds, NULL, &tv);
+ ret = para_select(1, &rfds, NULL, 0);
return ret > 0;
}
* \param n \sa \ref para_select().
* \param readfds \sa \ref para_select().
* \param writefds \sa \ref para_select().
- * \param timeout_tv \sa \ref para_select().
+ * \param timeout \sa \ref para_select().
*
* \return \sa \ref para_select().
*
* The only difference between this function and \ref para_select() is that
* \ref i9e_select() returns zero if the select call returned \p EINTR.
*/
-int i9e_select(int n, fd_set *readfds, fd_set *writefds,
- struct timeval *timeout_tv)
+int i9e_select(int n, fd_set *readfds, fd_set *writefds, int timeout)
{
- int ret = select(n, readfds, writefds, NULL, timeout_tv);
+ struct timeval tv;
+ int ret;
+
+ ms2tv(timeout, &tv);
+ ret = select(n, readfds, writefds, NULL, &tv);
if (ret < 0) {
if (errno == EINTR)
void i9e_close(void);
void i9e_signal_dispatch(int sig_num);
__printf_2_3 void i9e_log(int ll, const char* fmt,...);
-int i9e_select(int n, fd_set *readfds, fd_set *writefds,
- struct timeval *timeout_tv);
+int i9e_select(int n, fd_set *readfds, fd_set *writefds, int timeout);
int i9e_extract_completions(const char *word, char **string_list,
char ***result);
char **i9e_complete_commands(const char *word, struct i9e_completer *completers);
int ret;
unsigned num_inputs;
- sched.default_timeout.tv_sec = 5;
+ sched.default_timeout = 5000;
parse_config_or_die(argc, argv);
session_open();
num_inputs = lls_num_inputs(play_lpr);
ti.context = &rn;
rn.task = task_register(&ti, &s);
- s.default_timeout.tv_sec = 1;
- s.default_timeout.tv_usec = 0;
+ s.default_timeout = 1000;
ret = schedule(&s);
sched_shutdown(&s);
r->close(&rn);
again:
FD_ZERO(&s->rfds);
FD_ZERO(&s->wfds);
- s->select_timeout = s->default_timeout;
+ s->timeout = s->default_timeout;
s->max_fileno = -1;
clock_get_realtime(&now_struct);
sched_preselect(s);
ret = s->select_function(s->max_fileno + 1, &s->rfds, &s->wfds,
- &s->select_timeout);
+ s->timeout);
if (ret < 0)
return ret;
if (ret == 0) {
*/
void sched_min_delay(struct sched *s)
{
- s->select_timeout.tv_sec = s->select_timeout.tv_usec = 0;
+ s->timeout = 0;
}
/**
*/
void sched_request_timeout(struct timeval *to, struct sched *s)
{
- if (tv_diff(&s->select_timeout, to, NULL) > 0)
- s->select_timeout = *to;
+ long unsigned ms = tv2ms(to);
+ if (s->timeout > ms)
+ s->timeout = ms;
}
/**
* called after the select call.
*/
struct sched {
- /** Initial value before any pre_select call. */
- struct timeval default_timeout;
- /** The current timeout for the upcoming select call. */
- struct timeval select_timeout;
+ /** Initial value (in milliseconds) before any pre_select call. */
+ int default_timeout;
+ /** The timeout (also in milliseconds) for the next select call. */
+ int timeout;
/** fds that should be watched for readability. */
fd_set rfds;
/** fds that should be watched for writability. */
/** Highest numbered file descriptor in any of the above fd sets. */
int max_fileno;
/** If non-NULL, use this function instead of para_select. */
- int (*select_function)(int, fd_set *, fd_set *, struct timeval *);
+ int (*select_function)(int, fd_set *, fd_set *, int timeout);
/** Tasks which have been registered to the scheduler. */
struct list_head task_list;
};
}
static int server_select(int max_fileno, fd_set *readfds, fd_set *writefds,
- struct timeval *timeout_tv)
+ int timeout)
{
int ret;
status_refresh();
mutex_unlock(mmd_mutex);
- ret = para_select(max_fileno + 1, readfds, writefds, timeout_tv);
+ ret = para_select(max_fileno + 1, readfds, writefds, timeout);
mutex_lock(mmd_mutex);
return ret;
}
struct server_command_task server_command_task_struct,
*sct = &server_command_task_struct;
- sched.default_timeout.tv_sec = 1;
+ sched.default_timeout = 1000;
sched.select_function = server_select;
server_init(argc, argv, sct);
wns[i].wid = check_writer_arg_or_die(arg, &wns[i].lpr);
register_writer_node(wns + i, cw_btrn, &s);
}
- s.default_timeout.tv_sec = 10;
- s.default_timeout.tv_usec = 50000;
+ s.default_timeout = 10500;
ret = schedule(&s);
if (ret >= 0) {
int j, ts;