diff mbox

[3/3] Library with an exit()

Message ID 1394366195-3053-3-git-send-email-rrs@debian.org (mailing list archive)
State Changes Requested, archived
Delegated to: christophe varoqui
Headers show

Commit Message

Ritesh Raj Sarraf March 9, 2014, 11:56 a.m. UTC
Signed-off-by: Ritesh Raj Sarraf <rrs@debian.org>
---
 libmpathpersist/mpath_persist.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Bart Van Assche March 9, 2014, 12:27 p.m. UTC | #1
On 03/09/14 12:56, Ritesh Raj Sarraf wrote:
> Signed-off-by: Ritesh Raj Sarraf <rrs@debian.org>
> ---
>  libmpathpersist/mpath_persist.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persist.c
> index bd30125..6b6901e 100644
> --- a/libmpathpersist/mpath_persist.c
> +++ b/libmpathpersist/mpath_persist.c
> @@ -585,11 +585,12 @@ int send_prout_activepath(char * dev, int rq_servact, int rq_scope,
>  	rc = pthread_create(&thread, &attr, mpath_prout_pthread_fn, (void *)(&param));
>  	if (rc){
>  		condlog (3, "%s: failed to create thread %d", dev, rc);
> -		exit(-1);
>  	}
> -	/* Free attribute and wait for the other threads */
> -	pthread_attr_destroy(&attr);
> -	rc = pthread_join(thread, NULL);
> +	else {
> +		/* Free attribute and wait for the other threads */
> +		pthread_attr_destroy(&attr);
> +		rc = pthread_join(thread, NULL);
> +	}
>  
>  	return (param.status);
>  }

pthread_attr_destroy() should also be called if pthread_create() fails.

Bart.


--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
Christophe Varoqui March 10, 2014, 10:22 p.m. UTC | #2
Ritesh,

do you want to send an updated patch addressing Bart's comment ?
Patch 1/3 and 2/3 of your set are applied.

Thanks,
Christophe Varoqui

On Sun, Mar 9, 2014 at 1:27 PM, Bart Van Assche <bvanassche@acm.org> wrote:
> On 03/09/14 12:56, Ritesh Raj Sarraf wrote:
>> Signed-off-by: Ritesh Raj Sarraf <rrs@debian.org>
>> ---
>>  libmpathpersist/mpath_persist.c | 9 +++++----
>>  1 file changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persist.c
>> index bd30125..6b6901e 100644
>> --- a/libmpathpersist/mpath_persist.c
>> +++ b/libmpathpersist/mpath_persist.c
>> @@ -585,11 +585,12 @@ int send_prout_activepath(char * dev, int rq_servact, int rq_scope,
>>       rc = pthread_create(&thread, &attr, mpath_prout_pthread_fn, (void *)(&param));
>>       if (rc){
>>               condlog (3, "%s: failed to create thread %d", dev, rc);
>> -             exit(-1);
>>       }
>> -     /* Free attribute and wait for the other threads */
>> -     pthread_attr_destroy(&attr);
>> -     rc = pthread_join(thread, NULL);
>> +     else {
>> +             /* Free attribute and wait for the other threads */
>> +             pthread_attr_destroy(&attr);
>> +             rc = pthread_join(thread, NULL);
>> +     }
>>
>>       return (param.status);
>>  }
>
> pthread_attr_destroy() should also be called if pthread_create() fails.
>
> Bart.
>
>

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
diff mbox

Patch

diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persist.c
index bd30125..6b6901e 100644
--- a/libmpathpersist/mpath_persist.c
+++ b/libmpathpersist/mpath_persist.c
@@ -585,11 +585,12 @@  int send_prout_activepath(char * dev, int rq_servact, int rq_scope,
 	rc = pthread_create(&thread, &attr, mpath_prout_pthread_fn, (void *)(&param));
 	if (rc){
 		condlog (3, "%s: failed to create thread %d", dev, rc);
-		exit(-1);
 	}
-	/* Free attribute and wait for the other threads */
-	pthread_attr_destroy(&attr);
-	rc = pthread_join(thread, NULL);
+	else {
+		/* Free attribute and wait for the other threads */
+		pthread_attr_destroy(&attr);
+		rc = pthread_join(thread, NULL);
+	}
 
 	return (param.status);
 }