summaryrefslogtreecommitdiff
path: root/pfinet/io-ops.c
diff options
context:
space:
mode:
Diffstat (limited to 'pfinet/io-ops.c')
-rw-r--r--pfinet/io-ops.c44
1 files changed, 35 insertions, 9 deletions
diff --git a/pfinet/io-ops.c b/pfinet/io-ops.c
index 5f3b1e90..69bd93c5 100644
--- a/pfinet/io-ops.c
+++ b/pfinet/io-ops.c
@@ -251,14 +251,14 @@ S_io_clear_some_openmodes (struct sock_user *user,
return 0;
}
-error_t
-S_io_select (struct sock_user *user,
- mach_port_t reply,
- mach_msg_type_name_t reply_type,
- int *select_type)
+static error_t
+io_select_common (struct sock_user *user,
+ mach_port_t reply,
+ mach_msg_type_name_t reply_type,
+ struct timespec *tsp, int *select_type)
{
const int want = *select_type | POLLERR;
- int avail;
+ int avail, timedout;
int ret = 0;
if (!user)
@@ -281,9 +281,16 @@ S_io_select (struct sock_user *user,
do
{
- /* Block until we are woken or cancelled. */
- interruptible_sleep_on (user->sock->sk->sleep);
- if (signal_pending (current)) /* This means we were cancelled. */
+ /* Block until we time out, are woken or cancelled. */
+ timedout = interruptible_sleep_on_timeout (user->sock->sk->sleep,
+ tsp);
+ if (timedout)
+ {
+ __mutex_unlock (&global_lock);
+ *select_type = 0;
+ return 0;
+ }
+ else if (signal_pending (current)) /* This means we were cancelled. */
{
pthread_mutex_unlock (&global_lock);
return EINTR;
@@ -307,6 +314,25 @@ S_io_select (struct sock_user *user,
}
error_t
+S_io_select (struct sock_user *user,
+ mach_port_t reply,
+ mach_msg_type_name_t reply_type,
+ int *select_type)
+{
+ return io_select_common (user, reply, reply_type, NULL, select_type);
+}
+
+error_t
+S_io_select_timeout (struct sock_user *user,
+ mach_port_t reply,
+ mach_msg_type_name_t reply_type,
+ struct timespec ts,
+ int *select_type)
+{
+ return io_select_common (user, reply, reply_type, &ts, select_type);
+}
+
+error_t
S_io_stat (struct sock_user *user,
struct stat *st)
{