[224] in Pthreads mailing list archive
fd.c
daemon@ATHENA.MIT.EDU (Jin Guojun[ITG])
Thu Dec 7 17:45:19 1995
Date: Thu, 7 Dec 1995 14:03:35 -0800
From: "Jin Guojun[ITG]" <jin@george.lbl.gov>
To: proven@MIT.EDU
Cc: pthreads@MIT.EDU
Here is the segment in pthreads/fd.c
----------------------------- Begin------------------------------------------
Line 55:
/*
* These first functions really should not be called by the user.
*
* I really should dynamically figure out what the table size is.
*/
static pthread_mutex_t fd_table_mutex = PTHREAD_MUTEX_INITIALIZER;
static int dtablecount = 4096/sizeof(struct fd_table_entry);
int dtablesize;
/* ==========================================================================
* Allocate dtablecount entries at once and populate the fd_table.
*
* fd_init_entry()
*/
int fd_init_entry(int entry)
{
struct fd_table_entry *fd_entry;
int i, round;
if (fd_table[entry] == NULL) {
+ dtablecount = dtablesize; /* add on */
round = entry - entry % dtablecount;
if ((fd_entry = (struct fd_table_entry *)malloc(
sizeof(struct fd_table_entry) * dtablecount)) == NULL) {
return(NOTOK);
}
for (i = 0; i < dtablecount; i++) {
----------------------------- End ------------------------------------------
On line 62, the dtablecount is fixed to 41. It causes core dump when
useds try to use more than 41 file descriptors. I changed it
to be dynamically assigned to dtablesize (set by limit openfiles; see the
+ line, add on). It works well, and I believe it will not hurt the code.
Am I right?
-Jin