pthreads bug?

2000-09-29 Thread Roman Shterenzon

Hello,
I noticed some strange behavior in pthreads applications,
close on socket which is in accept() will be blocked untill there's a connection
to port and accept returns.
It's observed on 4.0 - 4.1-STABLE, perhaps 4.1.1-STABLE as well, but I didn't 
try it. I don't have 3.5.1-STABLE system to test it there.
It affects, for example, openldap - start it , then kill -15 it.
It won't die (and it should). Now, try to telnet localhost 389 ; now it died.
The same behavior is a program we're writing right now, it's very annoying, in
fact we don't know how to deal with it. It works on solaris and linux.
btw, linux doesn't dump core on threaded application, how one's supposed to
debug it?
I attach example program, which, when receives SIGUSR1 should close the socket,
but, in fact gets blocked in the close() function.
Obviously it's waiting to acquire some lock.
Does anyone have an idea?

--Roman Shterenzon, UNIX System Administrator and Consultant
[ Xpert UNIX Systems Ltd., Herzlia, Israel. Tel: +972-9-9522361 ]

 pthreadtest.c


Re: pthreads bug?

2000-09-29 Thread Alfred Perlstein

* Roman Shterenzon [EMAIL PROTECTED] [000929 01:23] wrote:
 Hello,
 I noticed some strange behavior in pthreads applications,
 close on socket which is in accept() will be blocked untill there's a connection
 to port and accept returns.
 It's observed on 4.0 - 4.1-STABLE, perhaps 4.1.1-STABLE as well, but I didn't 
 try it. I don't have 3.5.1-STABLE system to test it there.
 It affects, for example, openldap - start it , then kill -15 it.
 It won't die (and it should). Now, try to telnet localhost 389 ; now it died.
 The same behavior is a program we're writing right now, it's very annoying, in
 fact we don't know how to deal with it. It works on solaris and linux.
 btw, linux doesn't dump core on threaded application, how one's supposed to
 debug it?

No clue on that one. :(

 I attach example program, which, when receives SIGUSR1 should close the socket,
 but, in fact gets blocked in the close() function.
 Obviously it's waiting to acquire some lock.
 Does anyone have an idea?

Yes, I have an idea and an idea how to fix it, I'm wondering what
the thread in accept() sees after this happens?

what is the errno from accept?

-- 
-Alfred Perlstein - [[EMAIL PROTECTED]|[EMAIL PROTECTED]]
"I have the heart of a child; I keep it in a jar on my desk."


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-stable" in the body of the message



Re: pthreads bug?

2000-09-29 Thread Roman Shterenzon

Quoting Alfred Perlstein [EMAIL PROTECTED]:
  I attach example program, which, when receives SIGUSR1 should close
 the socket,
  but, in fact gets blocked in the close() function.
  Obviously it's waiting to acquire some lock.
  Does anyone have an idea?
 
 Yes, I have an idea and an idea how to fix it, I'm wondering what
 the thread in accept() sees after this happens?
 
 what is the errno from accept?
The point is, that when close() is called, accept doesn't break out.

from close(2)
IMPLEMENTATION NOTES
 In the non-threaded library close() is implemented as the close syscall.

 In the threaded library, the close syscall is assembled to
 _thread_sys_close() and close() is implemented as a function which locks
 d for read and write, then calls _thread_sys_close().  Before returning,
 close() unlocks d.


So from my point of view the close tries to acquire a lock.


--Roman Shterenzon, UNIX System Administrator and Consultant
[ Xpert UNIX Systems Ltd., Herzlia, Israel. Tel: +972-9-9522361 ]


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-stable" in the body of the message



Re: pthreads bug?

2000-09-29 Thread Alfred Perlstein

* Roman Shterenzon [EMAIL PROTECTED] [000929 01:52] wrote:
 Quoting Alfred Perlstein [EMAIL PROTECTED]:
   I attach example program, which, when receives SIGUSR1 should close
  the socket,
   but, in fact gets blocked in the close() function.
   Obviously it's waiting to acquire some lock.
   Does anyone have an idea?
  
  Yes, I have an idea and an idea how to fix it, I'm wondering what
  the thread in accept() sees after this happens?
  
  what is the errno from accept?
 The point is, that when close() is called, accept doesn't break out.
 
 from close(2)
 IMPLEMENTATION NOTES
  In the non-threaded library close() is implemented as the close syscall.
 
  In the threaded library, the close syscall is assembled to
  _thread_sys_close() and close() is implemented as a function which locks
  d for read and write, then calls _thread_sys_close().  Before returning,
  close() unlocks d.
 
 
 So from my point of view the close tries to acquire a lock.

I know that, I should have been more clear, what is in errno on
Linux and Solaris so that I can emulate that?

-- 
-Alfred Perlstein - [[EMAIL PROTECTED]|[EMAIL PROTECTED]]
"I have the heart of a child; I keep it in a jar on my desk."


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-stable" in the body of the message