[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Bugfix: wait4msg() hangs when using SSL/TLS (ITS#446)

Howard Chu wrote:

> I have a question about this patch - you call ldap_free_connection when
> try_read1msg returns something meaningful. This doesn't make sense to me, it
> appears that you only expect to use 1 request/response per connection. ??

try_read1msg() calls ldap_free_connection() under some circumstances. I want to
ensure that the lc is not actually free'd until after the while
(try_read1msg()) loop in order to avoid fireworks.  I believe this is achieved
by incrementing the connection ref_cnt before calling try_read1msg() and then
calling ldap_free_connection() to even up the balance.

Perhaps it needs some comments....

    /* stop lc from being free'd within the while loop */

   /* read messages until the desired message is found or no more data on
connection */
   while ( (rc = try_read1msg( ld, msgid, all, lc->lconn_sb, lc, result )) ==
-2)    /* lc could go away */
        ;       /* nothing */

    /* decrement lc->lconn_refcnt above. Note: lc may get free'd */
    ldap_free_connection(ld, lc, 0, 1);