diff options
Diffstat (limited to 'pfinet/tunnel.c')
-rw-r--r-- | pfinet/tunnel.c | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/pfinet/tunnel.c b/pfinet/tunnel.c index 5d2544b2..4a6f616a 100644 --- a/pfinet/tunnel.c +++ b/pfinet/tunnel.c @@ -462,13 +462,14 @@ trivfs_S_io_readable (struct trivfs_protid *cred, return the types that are then available. ID_TAG is returned as passed; it is just for the convenience of the user in matching up reply messages with specific requests sent. */ -error_t -trivfs_S_io_select (struct trivfs_protid *cred, - mach_port_t reply, - mach_msg_type_name_t reply_type, - int *type) +static error_t +io_select_common (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t reply_type, + struct timespec *tsp, int *type) { struct tunnel_device *tdev; + error_t err; if (!cred) return EOPNOTSUPP; @@ -497,15 +498,40 @@ trivfs_S_io_select (struct trivfs_protid *cred, ports_interrupt_self_on_port_death (cred, reply); tdev->read_blocked = 1; - if (pthread_hurd_cond_wait_np (&tdev->select_alert, &tdev->lock)) + err = pthread_hurd_cond_timedwait_np (&tdev->select_alert, &tdev->lock, + tsp); + if (err) { *type = 0; pthread_mutex_unlock (&tdev->lock); - return EINTR; + + if (err == ETIMEDOUT) + err = 0; + + return err; } } } +error_t +trivfs_S_io_select (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t reply_type, + int *type) +{ + return io_select_common (cred, reply, reply_type, NULL, type); +} + +error_t +trivfs_S_io_select_timeout (struct trivfs_protid *cred, + mach_port_t reply, + mach_msg_type_name_t reply_type, + struct timespec ts, + int *type) +{ + return io_select_common (cred, reply, reply_type, &ts, type); +} + /* Change current read/write offset */ error_t trivfs_S_io_seek (struct trivfs_protid *cred, |