summaryrefslogtreecommitdiffstats
path: root/lib/libc_r/uthread/uthread_fd.c
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>1998-02-13 01:27:34 +0000
committerjulian <julian@FreeBSD.org>1998-02-13 01:27:34 +0000
commitb31dde27bfeaed94b1026c0788c4e98b1af47f3c (patch)
treefc79071c0e7ec3b06afa547a18a7327d4c544935 /lib/libc_r/uthread/uthread_fd.c
parentb28763a6b13c1f0830c84238266c8ad69f7455bd (diff)
downloadFreeBSD-src-b31dde27bfeaed94b1026c0788c4e98b1af47f3c.zip
FreeBSD-src-b31dde27bfeaed94b1026c0788c4e98b1af47f3c.tar.gz
Fixes from Jeremy Allison and Terry Lambert for pthreads:
specifically: uthread_accept.c: Fix for inherited socket not getting correct entry in pthread flags. uthread_create.c: Fix to allow pthread_t pointer return to be null if caller doesn't care about return. uthread_fd.c: Fix for return codes to be placed into correct errno. uthread_init.c: Changes to make gcc-2.8 thread aware for exception stack frames (WARNING: This is #ifdef'ed out by default and is different from the Cygnus egcs fix). uthread_ioctl.c: Fix for blocking/non-blocking ioctl. uthread_kern.c: Signal handling fixes (only one case left to fix, that of an externally sent SIGSEGV and friends - a fairly unusual case). uthread_write.c: Fix for lock of fd - ask for write lock, not read/write. uthread_writev.c: Fix for lock of fd - ask for write lock, not read/write. Pthreads now works well enough to run the LDAP and ACAPD(with the gcc 2.8 fix) sample implementations.
Diffstat (limited to 'lib/libc_r/uthread/uthread_fd.c')
-rw-r--r--lib/libc_r/uthread/uthread_fd.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/lib/libc_r/uthread/uthread_fd.c b/lib/libc_r/uthread/uthread_fd.c
index 1e61bb7..541f92f 100644
--- a/lib/libc_r/uthread/uthread_fd.c
+++ b/lib/libc_r/uthread/uthread_fd.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id$
+ * $Id: uthread_fd.c,v 1.4 1997/04/01 22:49:58 jb Exp $
*
*/
#include <errno.h>
@@ -39,6 +39,13 @@
#include <pthread.h>
#include "pthread_private.h"
+/*
+ * This function *must* return -1 and set the thread specific errno
+ * as a system call. This is because the error return from this
+ * function is propagated directly back from thread-wrapped system
+ * calls.
+ */
+
int
_thread_fd_table_init(int fd)
{
@@ -49,9 +56,11 @@ _thread_fd_table_init(int fd)
_thread_kern_sig_block(&status);
/* Check if the file descriptor is out of range: */
- if (fd < 0 || fd >= _thread_dtablesize)
+ if (fd < 0 || fd >= _thread_dtablesize) {
/* Return a bad file descriptor error: */
- ret = EBADF;
+ errno = EBADF;
+ ret = -1;
+ }
/*
* Check if memory has already been allocated for this file
@@ -62,9 +71,11 @@ _thread_fd_table_init(int fd)
}
/* Allocate memory for the file descriptor table entry: */
else if ((_thread_fd_table[fd] = (struct fd_table_entry *)
- malloc(sizeof(struct fd_table_entry))) == NULL)
+ malloc(sizeof(struct fd_table_entry))) == NULL) {
/* Return a bad file descriptor error: */
- ret = EBADF;
+ errno = EBADF;
+ ret = -1;
+ }
else {
/* Assume that the operation will succeed: */
ret = 0;
@@ -85,9 +96,9 @@ _thread_fd_table_init(int fd)
/* Get the flags for the file: */
if (fd >= 3 && (_thread_fd_table[fd]->flags =
- _thread_sys_fcntl(fd, F_GETFL, 0)) == -1)
- ret = errno;
-
+ _thread_sys_fcntl(fd, F_GETFL, 0)) == -1) {
+ ret = -1;
+ }
else {
/* Check if a stdio descriptor: */
if (fd < 3)
@@ -109,8 +120,9 @@ _thread_fd_table_init(int fd)
* Some devices don't support
* non-blocking calls (sigh):
*/
- if (errno != ENODEV)
- ret = errno;
+ if (errno != ENODEV) {
+ ret = -1;
+ }
}
}
OpenPOWER on IntegriCloud