Subject: Re: fixing send(2) semantics (kern/29750)
To: Matthew Mondor <mm_lists@pulsar-zone.net>
From: Jason Thorpe <thorpej@shagadelic.org>
List: tech-kern
Date: 03/26/2005 17:12:24
On Mar 26, 2005, at 4:23 PM, Matthew Mondor wrote:

> On Sun, 27 Mar 2005 00:28:34 +0100
> manu@netbsd.org (Emmanuel Dreyfus) wrote:
>
> I still consider myself a NetBSD kernel newbie (studying it  
> though), so
> if my comments are wrong I would appreciate explanation details for my
> own sake, thanks in advance :)
>
>
>> Here is a first attempt at dealing with the problem:
>> http://ftp.espci.fr/shadow/manu/send.diff
>>
> [...]
>
>
>> +        if (sleep) {                        \
>> +            splx((s));                    \
>> +            tsleep((ifq), PCATCH|PRIBIO,             \
>> +                "ifq_enqueue", 0);                \
>> +            (s) = splnet();                    \
>>
> [...]
>
> I am not sure of this, but is it possible that splx() is not necessary
> here (two instances of this in the code), since most code I saw using
> tsleep() appears to assume that it automically uses normal priority  
> when
> sleeping, restoring previous one upon return/wakeup?

You are correct.  IPL is part of the process context that is switched  
by tsleep(), so the splx()/splnet() pair around it is not necessary.

-- thorpej