From dawes@landfill.physics.usyd.edu.au  Thu Dec 12 21:53:10 1996
Received: from landfill.physics.usyd.edu.au (landfill.physics.usyd.edu.au [129.78.129.18])
          by freefall.freebsd.org (8.8.4/8.8.4) with ESMTP id VAA20992
          for <FreeBSD-gnats-submit@freebsd.org>; Thu, 12 Dec 1996 21:53:09 -0800 (PST)
Received: (from dawes@localhost) by landfill.physics.usyd.edu.au (8.8.2/8.8.2) id QAA10241; Fri, 13 Dec 1996 16:52:58 +1100 (EST)
Message-Id: <199612130552.QAA10241@landfill.physics.usyd.edu.au>
Date: Fri, 13 Dec 1996 16:52:58 +1100 (EST)
From: dawes@physics.usyd.edu.au
Reply-To: dawes@physics.usyd.edu.au
To: FreeBSD-gnats-submit@freebsd.org
Cc: dawes@physics.usyd.edu.au
Subject: Team can hang when stderr is a file
X-Send-Pr-Version: 3.2

>Number:         2204
>Category:       ports
>Synopsis:       Team can hang when stderr is a file.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    joerg
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Dec 12 22:00:01 PST 1996
>Closed-Date:    Sat Dec 14 14:25:56 MET 1996
>Last-Modified:  Sat Dec 14 05:30:00 PST 1996
>Originator:     David Dawes
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
University of Sydney, Australia
>Environment:
>Description:

I've seen team hang when stderr is a file.  'top' reports that it is
stuck in lockf.

>How-To-Repeat:

Run team with stderr set to a file.  Sometimes it hangs.

>Fix:
	
I haven't looked into this very deeply, but #undef'ing F_SETLKW seems to
avoid the problem.  This is already done for SunOS (maybe for the same
reason?).


*** team.c.ORIG	Fri Dec 13 16:26:50 1996
--- team.c	Fri Dec 13 16:28:14 1996
***************
*** 94,99 ****
--- 94,103 ----
  # undef F_SETLKW
  #endif
  
+ #ifdef __FreeBSD__
+ # undef F_SETLKW
+ #endif
+ 
  #if (PCG)
  # include "Extend.h"
  # include "Here.h"
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports->joerg 
Responsible-Changed-By: joerg 
Responsible-Changed-When: Fri Dec 13 14:32:25 MET 1996 
Responsible-Changed-Why:  
I'm the maintainer. 
State-Changed-From-To: open->closed 
State-Changed-By: joerg 
State-Changed-When: Sat Dec 14 14:25:56 MET 1996 
State-Changed-Why:  
Suggested fix dropped into the `patches' directory. 

Thanks! 


From: J Wunsch <j@uriah.heep.sax.de>
To: dawes@physics.usyd.edu.au
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: ports/2204: Team can hang when stderr is a file
Date: Sat, 14 Dec 1996 14:16:09 +0100 (MET)

 As dawes@physics.usyd.edu.au wrote:
 
 > I've seen team hang when stderr is a file.  'top' reports that it is
 > stuck in lockf.
 
 > I haven't looked into this very deeply, but #undef'ing F_SETLKW seems to
 > avoid the problem.  This is already done for SunOS (maybe for the same
 > reason?).
 
 I think team's error is it that it does both locking methods, fcntl()
 and flock(), if either F_SETLKW as LOCK_EX are available.  Since they
 finally go into the same common code path in the kernel, this might
 cause the deadlock.  I believe the code would be correctly written as:
 
 {
 # if (defined F_SETLKW)
     struct flock l;
     l.l_whence = 0; l.l_start = 0L; l.l_len = 0L;
     l.l_type = F_WRLCK; fcntl(fileno(stderr),F_SETLKW,&l);
 # elif (defined LOCK_EX)
     flock(fileno(stderr),LOCK_EX);
 # endif
   fprintf(stderr,a,b,c,d,e,f,g,h,i);
 # if (defined LOCK_EX)
     flock(fileno(stderr),LOCK_UN);
 # elif (defined F_SETLKW)
     l.l_type = F_UNLCK; fcntl(fileno(stderr),F_SETLKW,&l);
 # endif
 }
 
 Since flock() doesn't suffer from the braindeadness mentioned in the
 fcntl(2) man page, i'll add your suggested patch however.
 
 -- 
 cheers, J"org
 
 joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE
 Never trust an operating system you don't have sources for. ;-)
>Unformatted:

