[interfacekit] Re: deadlock with BApplication/BWindow

On 2005-03-12 at 18:39:52 [+0100], Adi Oanca wrote:
> 
> Then again I fail to see the use of these lines in _Lock():
> -------------------------
>         BObjectLocker<BLooperList> ListLock(gLooperList);
>         if (!ListLock.IsLocked())
>         {
>             // If we can't lock, the semaphore is probably
>             // gone, which leaves us in no-man's land
> PRINT(("BLooper::_Lock() done 2\n"));
>             return B_BAD_VALUE;
>         }
>     
>         //    Look up looper by port_id, if necessary
>         if (!loop)
>         {
>             loop = LooperForPort(port);
>             if (!loop)
>             {
> PRINT(("BLooper::_Lock() done 3\n"));
>                 return B_BAD_VALUE;
>             }
>         }
>         else
>         {
>             //    Check looper validity
>             if (!IsLooperValid(loop))
>             {
> PRINT(("BLooper::_Lock() done 4\n"));
>                 return B_BAD_VALUE;
>             }
>         }
> ---------------------------
> 
>     _Lock(BLooper* loop, port_id port, bigtime_t timeout)
> is always called with 'this' and '-1'
> so 'loop' will always be valid. IsLooperValid() checks for 'loop' in the 
> global
> list and if not, return error. But this will always return true, unless the 
> looper
> has been deleted and this is an illegal call, in which case it's right to 
> fail with
> a segmentation fault.
> 
>     Maybe I am missing something, and if that's the case, please tell me 
>     what.
>     If not, can we please remove the above lines? They are useless and 
>     introduce
> lots of CPU cycles.

Your assumption that invoking BLooper::Lock() on an invalid looper is not 
allowed is not correct. It is completely OK to do that. Just like calling 
PostMessage().

CU, Ingo

Other related posts: