Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 3 Dec 1998 13:39:27 -0500 (EST)
From:      HighWind Software Information <info@highwind.com>
To:        current@FreeBSD.ORG
Subject:   Re: Thread fd locking and fork()
Message-ID:  <199812031839.NAA01466@highwind.com>

next in thread | raw e-mail | index | archive | help

Again.. having a conversation with myself:

Wouldn't inserting this code in uthread_fork.c at line 122 fix this problem?

			/*
			 * Enter a loop to remove all locks on all locked fd's
			 */
			for (i = 0; i < _thread_dtablesize; i++) {
			    if (_thread_fd_table[i] != NULL) {
				memset(&_thread_fd_table[i]->lock,
				       0, sizeof(_thread_fd_table[i]->lock));
				_thread_fd_table[i]->r_owner = NULL;
				_thread_fd_table[i]->w_owner = NULL;
				_thread_fd_table[i]->r_fname = NULL;
				_thread_fd_table[i]->w_fname = NULL;
				_thread_fd_table[i]->r_lineno = 0;;
				_thread_fd_table[i]->w_lineno = 0;;
				_thread_fd_table[i]->r_lockcount = 0;
				_thread_fd_table[i]->w_lockcount = 0;

				/* Initialise the read/write queues: */
				_thread_queue_init(&_thread_fd_table[i]->r_queue);
				_thread_queue_init(&_thread_fd_table[i]->w_queue);
			    }
			}			


We know we are in the child, we know we are the only active thread, we
know we don't have any fd's locked and we just nuked all the other
threads. So, just go to the fd table and nuke any and all locks.

I'm going to give this a try, but, would appreciate if someone gave me
some comments.

-Rob

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199812031839.NAA01466>