On Wed, Apr 28, 2010 at 03:26:29PM -0400, Stephen Gallagher wrote:
> On 04/28/2010 02:57 PM, Stephen Gallagher wrote:
> >Simo made some excellent suggestions on IRC, so I have incorporated them:
> >
> >First, I changed the interface for be_add_online_cb() so that it will
> >now take a mem_ctx and pass back (if requested) the online_cb object.
> >(This object is now opaque). This way, the callback will be
> >automatically freed if the parent context goes away for any reason.
> >
> >I removed the be_remove_online_cb() function, so the interface to remove
> >a callback will simply be to call talloc_free() on the opaque object
> >returned from be_add_online_cb. This will allow us to potentially set
> >the same callback function multiple times, with different private data.
> >
> >New patch attached.
> >
> 
> Fix some style issues with the previous patch.
> 
> -- 
> Stephen Gallagher
> RHCE 804006346421761
> 
> Delivering value year after year.
> Red Hat ranks #1 in value among software vendors.
> http://www.redhat.com/promo/vendor/

> +
> +static int online_cb_destructor(TALLOC_CTX *ptr);
> +int be_add_online_cb(TALLOC_CTX *mem_ctx,
> +                     struct be_ctx *ctx,
> +                     be_conn_online_callback_t cb,
> +                     void *pvt,
> +                     struct be_conn_online_cb **online_cb)
> +{
> +    struct be_conn_online_cb *on_cb;
> +
> +    if (!ctx || !cb) {
> +        return EINVAL;
> +    }
> +
> +    on_cb = talloc(mem_ctx, struct be_conn_online_cb);
> +    if (!online_cb) {

if (!on_cb) ??

bye,
Sumit

> +        return ENOMEM;
> +    }
> +
> +    on_cb->cb = cb;
> +    on_cb->pvt = pvt;
> +    on_cb->be = ctx;
> +
> +    DLIST_ADD(ctx->online_cb_list, on_cb);
> +
> +    talloc_set_destructor((TALLOC_CTX *)on_cb, online_cb_destructor);
> +
> +    /* Make sure we run the callback for the first
> +     * connection after startup.
> +     */
> +    ctx->run_online_cb = true;
> +
> +    if (online_cb) {
> +        *online_cb = on_cb;
> +    }
> +
> +    return EOK;
> +}
> +
_______________________________________________
sssd-devel mailing list
sssd-devel@lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/sssd-devel

Reply via email to