From owner-freebsd-hackers Sat Nov 27 15:49:14 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from mail.pernet.net (mail.pernet.net [205.229.0.40]) by hub.freebsd.org (Postfix) with ESMTP id 62A1314BE0 for ; Sat, 27 Nov 1999 15:49:10 -0800 (PST) (envelope-from jking@pernet.net) Received: from deadpixi.pernet.net (deadpixi.pernet.net [205.229.0.243]) by mail.pernet.net (8.9.1a/8.9.1) with ESMTP id RAA19257; Sat, 27 Nov 1999 17:48:59 -0600 (CST) Date: Sat, 27 Nov 1999 17:48:58 -0600 (CST) From: Rob King To: FengYue Cc: hackers@FreeBSD.ORG Subject: Re: PThreads and Sockets In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > There is a race condition. You're passing sd2's address to serverstart() > and inside serverstart() you def' the pointer. What if > "sd2=accept(sd, (struct sockaddr*)&cad, &alen)" gets > executed before your previous serverstart() finishs "sd2 = *((int*)ptr)"? > > btw, IMHO, creating threads per connection is a very bad design. > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message > How would you recommend I do it? Please remember, I have no experience with pthreads, and any advice you give would be greatly appreciated. I tried doing a pool of threads created at startup, and I think that may be a better approach...That would allow tighter control of resource limits - do something like Apache, have a "maximum number" of processes running. Anyway, thanks for the help. Rob -- Rob King Network Administrator - PERnet Communications, Inc. jking@pernet.net - http://www.pernet.net/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message