Return-Path: william@bourbon.usc.edu Delivery-Date: Sat Sep 6 18:48:50 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on merlot.usc.edu X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3 Received: from bourbon.usc.edu (bourbon.usc.edu [128.125.9.75]) by merlot.usc.edu (8.14.1/8.14.1) with ESMTP id m871moP4028139 for ; Sat, 6 Sep 2008 18:48:50 -0700 Received: from bourbon.usc.edu (localhost.localdomain [127.0.0.1]) by bourbon.usc.edu (8.14.2/8.14.1) with ESMTP id m871lROk030011 for ; Sat, 6 Sep 2008 18:47:27 -0700 Message-Id: <200809070147.m871lROk030011@bourbon.usc.edu> To: cs551@merlot.usc.edu Subject: Re: cs 551 Date: Sat, 06 Sep 2008 18:47:27 -0700 From: Bill Cheng Someone wrote: > I have a question or rather a clarification regarding the threads > > I use pthreads and this is how it currently works > > 1. server creates a thread for each new client. suppose there are 2 threads > remaining > 2. if the server receives an autoshutdown signal, it waits for these 2 > threads to finish (i use a pthread_join rather than a global var) The child threads must terminate as soon as possible. So, I would use a global variable to indicate that it's time to quit. Since the child thread is writing one byte as a time, as soon as it writes one byte, it should check this global variable. If it's time to quit, the child thread should close the socket, clean itself up and terminate. -- Bill Cheng // bill.cheng@usc.edu