From mark@tgsoft.com Fri Aug  6 22:11:52 1999
Return-Path: <mark@tgsoft.com>
Received: from moose.tgsoft.com (cx20270-a.pwy1.sdca.home.com [24.0.169.3])
	by hub.freebsd.org (Postfix) with SMTP id 3029814CE5
	for <FreeBSD-gnats-submit@freebsd.org>; Fri,  6 Aug 1999 22:11:51 -0700 (PDT)
	(envelope-from mark@tgsoft.com)
Received: (qmail 91864 invoked by uid 128); 7 Aug 1999 05:10:42 -0000
Message-Id: <19990807051041.91863.qmail@moose.tgsoft.com>
Date: 7 Aug 1999 05:10:41 -0000
From: mark@tgsoft.com
Reply-To: mark@tgsoft.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: kill fails in libc_r
X-Send-Pr-Version: 3.2

>Number:         13008
>Category:       bin
>Synopsis:       pthread_kill does not always work
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Aug  6 22:20:01 PDT 1999
>Closed-Date:    Wed Dec 15 22:42:42 PST 1999
>Last-Modified:  Wed Dec 15 22:45:09 PST 1999
>Originator:     mark thompson
>Release:        FreeBSD 3.2-STABLE i386
>Organization:
tgsoft
>Environment:

3.2 stable pthread library

>Description:

I wrote an application that worked basically like this:

main:
   create a socket
   create 10 threads
   run for a while, then:

       send each thread a signal with pthread_kill and wait for it in
	   pthread_join.
       when one thread has been waited for, go back and kill the next one
   exit

Each thread (in a loop):
	does an accept on the socket
	copies some data
	closes the data socket
	repeats

The problem:

   Waiting in pthread_join was not fruitful. Examination shows that
   *most* of the threads that are in 'accept' were waiting for 
   the a lock on the socket (state: PS_FDLR_WAIT) and pthread_kill 
   does not do anything to them. One lucky thread would be in PS_FDR_WAIT, 
   and it could be killed... but it is hard for my application to know
   which thread that is.

>How-To-Repeat:

   Sorry, no sample code. I have hacked up the application to the
   point that it is no longer recognizeable.

>Fix:
	
   pthread_kill probably needs to know how to kill processes that
   are waiting for file locks.



>Release-Note:
>Audit-Trail:

From: jin@george.lbl.gov
To: FreeBSD-gnats-submit@FreeBSD.ORG, mark@tgsoft.com
Cc:  
Subject: Re: bin/13008: kill fails in libc_r
Date: Tue, 10 Aug 1999 08:12:59 -0700 (PDT)

 } >How-To-Repeat:
 } 
 }    Sorry, no sample code. I have hacked up the application to the
 }    point that it is no longer recognizeable.
 
 This duplicated kern/11984. This simple code is in there.
 
 } >Fix:
 }         
 }    pthread_kill probably needs to know how to kill processes that
 }    are waiting for file locks.
 
 The problem is that libc_r does not provide a flag to tell thread
 kernel if any thread is being killing, so that if the killed thread
 is in dead loop status or some locked status, then program will hang
 or wait forever.
 
 	-Jin
 
 
State-Changed-From-To: open->closed 
State-Changed-By: jasone 
State-Changed-When: Wed Dec 15 22:42:42 PST 1999 
State-Changed-Why:  
The problem has been fixed on both -current and -stable.
>Unformatted:
