[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] cleanup the neon socket when closing the ra_session

From: Daniel Rall <dlr_at_collab.net>
Date: 2007-07-06 02:34:21 CEST

On Thu, 05 Jul 2007, Stefan Küng wrote:

> Garrett Rooney wrote:
> >On 7/5/07, Stefan Küng <tortoisesvn@gmail.com> wrote:
> >>in ra_open(), the ne_sock_init() is called. But the ne_sock_exit() isn't
> >>called when the session is closed. The attached patch fixes this.
> >
> >Is this safe from a thread-safety perspective?
>
> According to the comments in the neon source, yes.

I looked over the Neon sources and this patch certainly looks
process-safe. Code in socket initialization and shutdown routines
certainly seems to adhere to the comments:

/* Perform process-global initialization of any libraries in use.
 * Returns non-zero on error. */
int ne_sock_init(void);

/* Perform process-global shutdown of any libraries in use. This
 * function only has effect when it has been called an equal number of
 * times to ne_sock_init() for the process. */
void ne_sock_exit(void);

Here's an example of Neon's OpenSSL shutdown code, called from
ne_sock_exit():

void ne__ssl_exit(void)
{
    /* Cannot call ERR_free_strings() etc here in case any other code
     * in the process using OpenSSL. */

#ifdef NE_HAVE_TS_SSL
    /* Only unregister the callbacks if some *other* library has not
     * come along in the mean-time and trampled over the callbacks
     * installed by neon. */
    if (CRYPTO_get_locking_callback() == thread_lock_neon
        && CRYPTO_get_id_callback() == thread_id_neon) {
        size_t n;

        CRYPTO_set_id_callback(NULL);
        CRYPTO_set_locking_callback(NULL);

        for (n = 0; n < num_locks; n++) {
            pthread_mutex_destroy(&locks[n]);
        }

        free(locks);
    }

Was there something in particular which made it also look thread-safe,
Stefan? I didn't think it was safe to equate process with thread on
all platforms.

Thanks, Dan

  • application/pgp-signature attachment: stored
Received on Fri Jul 6 02:34:19 2007

This is an archived mail posted to the Subversion Dev mailing list.