[Libvirt-cim] [PATCH 2/3] CSI: Cleanup code

Chip Vincent cvincent at linux.vnet.ibm.com
Wed Feb 22 15:34:10 UTC 2012


+1

On 02/20/2012 02:36 PM, Eduardo Lima (Etrunko) wrote:
> From: "Eduardo Lima (Etrunko)"<eblima at br.ibm.com>
>
> Signed-off-by: Eduardo Lima (Etrunko)<eblima at br.ibm.com>
> ---
>   src/Virt_ComputerSystemIndication.c |   51 +++++++++++++++++------------------
>   1 files changed, 25 insertions(+), 26 deletions(-)
>
> diff --git a/src/Virt_ComputerSystemIndication.c b/src/Virt_ComputerSystemIndication.c
> index ab6ffe4..b60138a 100644
> --- a/src/Virt_ComputerSystemIndication.c
> +++ b/src/Virt_ComputerSystemIndication.c
> @@ -692,36 +692,35 @@ static CMPIStatus ActivateFilter(CMPIIndicationMI* mi,
>           thread =&csi_thread_data[platform];
>           thread->active_filters += 1;
>
> -        if (thread->id == 0) {
> -                args = malloc(sizeof(*args));
> -                if (args == NULL) {
> -                        CU_DEBUG("Failed to allocate ind_args");
> -                        cu_statusf(_BROKER,&s,
> -                                   CMPI_RC_ERR_FAILED,
> -                                   "Unable to allocate ind_args");
> -                        error = true;
> -                        goto out;
> -                }
> -
> -                args->context = CBPrepareAttachThread(_BROKER, ctx);
> -                if (args->context == NULL) {
> -                        CU_DEBUG("Failed to create thread context");
> -                        cu_statusf(_BROKER,&s,
> -                                   CMPI_RC_ERR_FAILED,
> -                                   "Unable to create thread context");
> -                        error = true;
> -                        goto out;
> -                }
> +        /* Check if thread is already running */
> +        if (thread->id>  0)
> +                goto out;
>
> -                args->ns = strdup(NAMESPACE(op));
> -                args->classname = strdup(CLASSNAME(op));
> -                args->_ctx = _ctx;
> +        args = malloc(sizeof(*args));
> +        if (args == NULL) {
> +                CU_DEBUG("Failed to allocate ind_args");
> +                cu_statusf(_BROKER,&s, CMPI_RC_ERR_FAILED,
> +                           "Unable to allocate ind_args");
> +                error = true;
> +                goto out;
> +        }
>
> -                thread->args = args;
> -                thread->id = _BROKER->xft->newThread(lifecycle_thread,
> -                                                     thread, 0);
> +        args->context = CBPrepareAttachThread(_BROKER, ctx);
> +        if (args->context == NULL) {
> +                CU_DEBUG("Failed to create thread context");
> +                cu_statusf(_BROKER,&s, CMPI_RC_ERR_FAILED,
> +                           "Unable to create thread context");
> +                error = true;
> +                goto out;
>           }
>
> +        args->ns = strdup(NAMESPACE(op));
> +        args->classname = strdup(CLASSNAME(op));
> +        args->_ctx = _ctx;
> +
> +        thread->args = args;
> +        thread->id = _BROKER->xft->newThread(lifecycle_thread, thread, 0);
> +
>    out:
>           if (error == true) {
>                   thread->active_filters -= 1;


-- 
Chip Vincent
Open Virtualization
IBM Linux Technology Center
cvincent at linux.vnet.ibm.com




More information about the Libvirt-cim mailing list