From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id JAA19118; Thu, 9 Aug 2001 09:57:36 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id JAA19252 for ; Thu, 9 Aug 2001 09:57:35 +0200 (MET DST) Received: from pochi.inria.fr (pochi.inria.fr [128.93.8.128]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f797vZH16622 for ; Thu, 9 Aug 2001 09:57:35 +0200 (MET DST) Received: (from mentre@localhost) by pochi.inria.fr (8.11.1/8.10.0) id f797vZv07441; Thu, 9 Aug 2001 09:57:35 +0200 X-Authentication-Warning: pochi.inria.fr: mentre set sender to David.Mentre@inria.fr using -f To: caml-list@inria.fr Subject: [Caml-list] Thread and sockets From: David Mentre Date: 09 Aug 2001 09:57:35 +0200 Message-ID: User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.4 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hello, I'm building a Caml client/server program using posix threads and sockets. Right now, I have 3 threads: 1. normal thread for user computation 2. a thread doing a blocking call to Unix.accept to setup new connections 3. a thread doing a blocking call to Thread.select (with infinite timeout) to get messages on opened connections I've observed that my design is bad and I have several race conditions. Worse problems are when I open and close connections. For example, if thread (3) is blocked and a new connection is opened by thread (2), thread (3) won't read new messages. I have similar problems when sockets are closed. How to do it properly? I think I should open a dedicated thread for each new socket [1]. However I don't know how to stop a thread waiting inside a blocking call. What happens if the remote part close the socket where a thread is doing a select (or a read). Does this thread get an exception? I also don't know how to stop cleanly thread (2). Should another thread close the socket where thread (2) is doing an Unix.accept on? I would accept with pleasure any advice on this subjet. Best regards, david [1] At first, I did not choose this design to avoid creating zillions of new posix (i.e. kernel, on Linux) threads. -- David.Mentre@inria.fr Opinions expressed here are only mine. ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr