Fix thread initialization to allow for the case where stdio file

descriptors are not opened.

PR:		bin/12853
Reviewed by:	jb
This commit is contained in:
Daniel Eischen 1999-08-05 12:08:10 +00:00
parent 1071410263
commit 8b5d18ec76
7 changed files with 51 additions and 39 deletions

View File

@ -20,7 +20,7 @@
* THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@ -31,7 +31,7 @@
*
* Private thread definitions for the uthread kernel.
*
* $Id: pthread_private.h,v 1.23 1999/07/11 05:56:35 jasone Exp $
* $Id: pthread_private.h,v 1.24 1999/07/12 16:09:30 dt Exp $
*/
#ifndef _PTHREAD_PRIVATE_H
@ -817,7 +817,7 @@ SCLASS const int dtablecount
#endif
SCLASS int _thread_dtablesize /* Descriptor table size. */
#ifdef GLOBAL_PTHREAD_PRIVATE
= 1024;
= 0;
#else
;
#endif

View File

@ -20,7 +20,7 @@
* THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: uthread_fd.c,v 1.10 1999/03/23 05:07:55 jb Exp $
* $Id: uthread_fd.c,v 1.11 1999/06/20 08:28:18 jb Exp $
*
*/
#include <errno.h>
@ -94,13 +94,13 @@ _thread_fd_table_init(int fd)
TAILQ_INIT(&entry->w_queue);
/* Get the flags for the file: */
if (fd >= 3 && (entry->flags =
_thread_sys_fcntl(fd, F_GETFL, 0)) == -1) {
if (((fd >= 3) || (_pthread_stdio_flags[fd] == -1)) &&
(entry->flags = _thread_sys_fcntl(fd, F_GETFL, 0)) == -1) {
ret = -1;
}
}
else {
/* Check if a stdio descriptor: */
if (fd < 3)
if ((fd < 3) && (_pthread_stdio_flags[fd] != -1))
/*
* Use the stdio flags read by
* _pthread_init() to avoid

View File

@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: uthread_init.c,v 1.15 1999/07/11 05:56:37 jasone Exp $
* $Id: uthread_init.c,v 1.16 1999/07/12 16:09:30 dt Exp $
*/
/* Allocate space for global thread variables here: */
@ -124,8 +124,9 @@ _thread_init(void)
/* Get the standard I/O flags before messing with them : */
for (i = 0; i < 3; i++)
if ((_pthread_stdio_flags[i] =
_thread_sys_fcntl(i,F_GETFL, NULL)) == -1)
if (((_pthread_stdio_flags[i] =
_thread_sys_fcntl(i,F_GETFL, NULL)) == -1) &&
(errno != EBADF))
PANIC("Cannot get stdio flags");
/*
@ -282,6 +283,9 @@ _thread_init(void)
}
/* Allocate memory for the file descriptor table: */
if ((_thread_fd_table = (struct fd_table_entry **) malloc(sizeof(struct fd_table_entry *) * _thread_dtablesize)) == NULL) {
/* Avoid accesses to file descriptor table on exit: */
_thread_dtablesize = 0;
/*
* Cannot allocate memory for the file descriptor
* table, so abort this process.
@ -306,11 +310,11 @@ _thread_init(void)
}
/* Initialize stdio file descriptor table entries: */
if ((_thread_fd_table_init(0) != 0) ||
(_thread_fd_table_init(1) != 0) ||
(_thread_fd_table_init(2) != 0)) {
PANIC("Cannot initialize stdio file descriptor "
"table entries");
for (i = 0; i < 3; i++) {
if ((_thread_fd_table_init(i) != 0) &&
(errno != EBADF))
PANIC("Cannot initialize stdio file "
"descriptor table entry");
}
}
}

View File

@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: uthread_init.c,v 1.15 1999/07/11 05:56:37 jasone Exp $
* $Id: uthread_init.c,v 1.16 1999/07/12 16:09:30 dt Exp $
*/
/* Allocate space for global thread variables here: */
@ -124,8 +124,9 @@ _thread_init(void)
/* Get the standard I/O flags before messing with them : */
for (i = 0; i < 3; i++)
if ((_pthread_stdio_flags[i] =
_thread_sys_fcntl(i,F_GETFL, NULL)) == -1)
if (((_pthread_stdio_flags[i] =
_thread_sys_fcntl(i,F_GETFL, NULL)) == -1) &&
(errno != EBADF))
PANIC("Cannot get stdio flags");
/*
@ -282,6 +283,9 @@ _thread_init(void)
}
/* Allocate memory for the file descriptor table: */
if ((_thread_fd_table = (struct fd_table_entry **) malloc(sizeof(struct fd_table_entry *) * _thread_dtablesize)) == NULL) {
/* Avoid accesses to file descriptor table on exit: */
_thread_dtablesize = 0;
/*
* Cannot allocate memory for the file descriptor
* table, so abort this process.
@ -306,11 +310,11 @@ _thread_init(void)
}
/* Initialize stdio file descriptor table entries: */
if ((_thread_fd_table_init(0) != 0) ||
(_thread_fd_table_init(1) != 0) ||
(_thread_fd_table_init(2) != 0)) {
PANIC("Cannot initialize stdio file descriptor "
"table entries");
for (i = 0; i < 3; i++) {
if ((_thread_fd_table_init(i) != 0) &&
(errno != EBADF))
PANIC("Cannot initialize stdio file "
"descriptor table entry");
}
}
}

View File

@ -20,7 +20,7 @@
* THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@ -31,7 +31,7 @@
*
* Private thread definitions for the uthread kernel.
*
* $Id: pthread_private.h,v 1.23 1999/07/11 05:56:35 jasone Exp $
* $Id: pthread_private.h,v 1.24 1999/07/12 16:09:30 dt Exp $
*/
#ifndef _PTHREAD_PRIVATE_H
@ -817,7 +817,7 @@ SCLASS const int dtablecount
#endif
SCLASS int _thread_dtablesize /* Descriptor table size. */
#ifdef GLOBAL_PTHREAD_PRIVATE
= 1024;
= 0;
#else
;
#endif

View File

@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: uthread_init.c,v 1.15 1999/07/11 05:56:37 jasone Exp $
* $Id: uthread_init.c,v 1.16 1999/07/12 16:09:30 dt Exp $
*/
/* Allocate space for global thread variables here: */
@ -124,8 +124,9 @@ _thread_init(void)
/* Get the standard I/O flags before messing with them : */
for (i = 0; i < 3; i++)
if ((_pthread_stdio_flags[i] =
_thread_sys_fcntl(i,F_GETFL, NULL)) == -1)
if (((_pthread_stdio_flags[i] =
_thread_sys_fcntl(i,F_GETFL, NULL)) == -1) &&
(errno != EBADF))
PANIC("Cannot get stdio flags");
/*
@ -282,6 +283,9 @@ _thread_init(void)
}
/* Allocate memory for the file descriptor table: */
if ((_thread_fd_table = (struct fd_table_entry **) malloc(sizeof(struct fd_table_entry *) * _thread_dtablesize)) == NULL) {
/* Avoid accesses to file descriptor table on exit: */
_thread_dtablesize = 0;
/*
* Cannot allocate memory for the file descriptor
* table, so abort this process.
@ -306,11 +310,11 @@ _thread_init(void)
}
/* Initialize stdio file descriptor table entries: */
if ((_thread_fd_table_init(0) != 0) ||
(_thread_fd_table_init(1) != 0) ||
(_thread_fd_table_init(2) != 0)) {
PANIC("Cannot initialize stdio file descriptor "
"table entries");
for (i = 0; i < 3; i++) {
if ((_thread_fd_table_init(i) != 0) &&
(errno != EBADF))
PANIC("Cannot initialize stdio file "
"descriptor table entry");
}
}
}

View File

@ -20,7 +20,7 @@
* THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@ -31,7 +31,7 @@
*
* Private thread definitions for the uthread kernel.
*
* $Id: pthread_private.h,v 1.23 1999/07/11 05:56:35 jasone Exp $
* $Id: pthread_private.h,v 1.24 1999/07/12 16:09:30 dt Exp $
*/
#ifndef _PTHREAD_PRIVATE_H
@ -817,7 +817,7 @@ SCLASS const int dtablecount
#endif
SCLASS int _thread_dtablesize /* Descriptor table size. */
#ifdef GLOBAL_PTHREAD_PRIVATE
= 1024;
= 0;
#else
;
#endif