diff options
Diffstat (limited to 'lib/libc_r/uthread/uthread_select.c')
-rw-r--r-- | lib/libc_r/uthread/uthread_select.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/lib/libc_r/uthread/uthread_select.c b/lib/libc_r/uthread/uthread_select.c index a7cd5c3d260..61708fa7c39 100644 --- a/lib/libc_r/uthread/uthread_select.c +++ b/lib/libc_r/uthread/uthread_select.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_select.c,v 1.4 1999/11/25 07:01:42 d Exp $ */ +/* $OpenBSD: uthread_select.c,v 1.5 2001/08/21 19:24:53 fgsch Exp $ */ /* * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> * All rights reserved. @@ -49,6 +49,7 @@ int select(int numfds, fd_set * readfds, fd_set * writefds, fd_set * exceptfds, struct timeval * timeout) { + struct pthread *curthread = _get_curthread(); struct timespec ts; int i, ret = 0, f_wait = 1; int pfd_index, got_one = 0, fd_count = 0; @@ -92,9 +93,9 @@ select(int numfds, fd_set * readfds, fd_set * writefds, * Allocate memory for poll data if it hasn't already been * allocated or if previously allocated memory is insufficient. */ - if ((_thread_run->poll_data.fds == NULL) || - (_thread_run->poll_data.nfds < fd_count)) { - data.fds = (struct pollfd *) realloc(_thread_run->poll_data.fds, + if ((curthread->poll_data.fds == NULL) || + (curthread->poll_data.nfds < fd_count)) { + data.fds = (struct pollfd *) realloc(curthread->poll_data.fds, sizeof(struct pollfd) * MAX(128, fd_count)); if (data.fds == NULL) { errno = ENOMEM; @@ -106,13 +107,13 @@ select(int numfds, fd_set * readfds, fd_set * writefds, * indicates what is allocated, not what is * currently being polled. */ - _thread_run->poll_data.fds = data.fds; - _thread_run->poll_data.nfds = MAX(128, fd_count); + curthread->poll_data.fds = data.fds; + curthread->poll_data.nfds = MAX(128, fd_count); } } if (ret == 0) { /* Setup the wait data. */ - data.fds = _thread_run->poll_data.fds; + data.fds = curthread->poll_data.fds; data.nfds = fd_count; /* @@ -145,10 +146,10 @@ select(int numfds, fd_set * readfds, fd_set * writefds, } if (((ret = _thread_sys_poll(data.fds, data.nfds, 0)) == 0) && (f_wait != 0)) { - _thread_run->data.poll_data = &data; - _thread_run->interrupted = 0; + curthread->data.poll_data = &data; + curthread->interrupted = 0; _thread_kern_sched_state(PS_SELECT_WAIT, __FILE__, __LINE__); - if (_thread_run->interrupted) { + if (curthread->interrupted) { errno = EINTR; data.nfds = 0; ret = -1; |