[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Re: (ITS#3567) slapd terminates unexpectedly
Dagobert Michelsen wrote:
>
> First thanks for the in-depth analysis. However, for me it looks like
> fd #14 is opened straight before the select you mentioned and closed
> without errors right after the poll:
>
>
>
> However there is one more thing I don't understand: if my Perl code
> runs in thread #5 and the fd is duped onto fd #14 in this thread, why
> should openldap bother about issueing select on it? Additionally, the
> perl code never closes a fd explicitly, only perl filehandles and
> Net::LDAP are used.
>
You are completely missing the point. The point is that the slapd
listener issued an accept() call which returned fd#14, so slapd expects
fd#14 to be an incoming LDAP session socket. Your code causes fd#14 to
be closed and replaced with some other thing, which in particular
probably does not support being select'd or poll'd. slapd performs the
select because the listener thread has no knowledge that your code has
closed the LDAP socket and replaced it with something else, it still
thinks there is an incoming LDAP session on that descriptor. Regardless
of the fact that fd#14 is open at the time of the next select()/poll()
it is no longer a socket descriptor, and so the call fails with ENOSYS.
If your code doesn't explicitly close fd's then the underlying perl
runtime and/or Net::LDAP modules are broken. The nature of the error is
outside the scope of this OpenLDAP Issue Tracking System, but I'll make
one further observation - it is poor programming practice to close an fd
and then explicitly dup another fd onto it. Since the dup operation
always atomically closes any previous file on the target descriptor, it
is best to just perform the dup without calling close. Any decent Unix
programmer knows this, as doing it with an explicit close in advance
introduces a race condition, as your truss so clearly demonstrates.
Whatever code is issuing the dup request is broken.
--
-- Howard Chu
Chief Architect, Symas Corp. Director, Highland Sun
http://www.symas.com http://highlandsun.com/hyc
Symas: Premier OpenSource Development and Support