* [PATCH] Don't exit() from library
@ 2014-03-11 6:10 Ritesh Raj Sarraf
2014-03-11 8:45 ` Bart Van Assche
0 siblings, 1 reply; 3+ messages in thread
From: Ritesh Raj Sarraf @ 2014-03-11 6:10 UTC (permalink / raw)
To: christophe.varoqui; +Cc: Ritesh Raj Sarraf, dm-devel
Also call pthread_attr_destroy() on thread creation failure
Signed-off-by: Ritesh Raj Sarraf <rrs@debian.org>
---
libmpathpersist/mpath_persist.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persist.c
index bd30125..b74ce4e 100644
--- a/libmpathpersist/mpath_persist.c
+++ b/libmpathpersist/mpath_persist.c
@@ -585,11 +585,14 @@ int send_prout_activepath(char * dev, int rq_servact, int rq_scope,
rc = pthread_create(&thread, &attr, mpath_prout_pthread_fn, (void *)(¶m));
if (rc){
condlog (3, "%s: failed to create thread %d", dev, rc);
- exit(-1);
+ /* Destroy the thread attribute since we failed to create */
+ pthread_attr_destroy(&attr);
+ }
+ else {
+ /* Free attribute and wait for the other threads */
+ pthread_attr_destroy(&attr);
+ rc = pthread_join(thread, NULL);
}
- /* Free attribute and wait for the other threads */
- pthread_attr_destroy(&attr);
- rc = pthread_join(thread, NULL);
return (param.status);
}
--
1.9.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Don't exit() from library
2014-03-11 6:10 [PATCH] Don't exit() from library Ritesh Raj Sarraf
@ 2014-03-11 8:45 ` Bart Van Assche
2014-03-11 14:52 ` Ritesh Raj Sarraf
0 siblings, 1 reply; 3+ messages in thread
From: Bart Van Assche @ 2014-03-11 8:45 UTC (permalink / raw)
To: device-mapper development, christophe.varoqui; +Cc: Ritesh Raj Sarraf
On 03/11/14 07:10, Ritesh Raj Sarraf wrote:
> Also call pthread_attr_destroy() on thread creation failure
>
> Signed-off-by: Ritesh Raj Sarraf <rrs@debian.org>
> ---
> libmpathpersist/mpath_persist.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persist.c
> index bd30125..b74ce4e 100644
> --- a/libmpathpersist/mpath_persist.c
> +++ b/libmpathpersist/mpath_persist.c
> @@ -585,11 +585,14 @@ int send_prout_activepath(char * dev, int rq_servact, int rq_scope,
> rc = pthread_create(&thread, &attr, mpath_prout_pthread_fn, (void *)(¶m));
> if (rc){
> condlog (3, "%s: failed to create thread %d", dev, rc);
> - exit(-1);
> + /* Destroy the thread attribute since we failed to create */
> + pthread_attr_destroy(&attr);
> + }
> + else {
> + /* Free attribute and wait for the other threads */
> + pthread_attr_destroy(&attr);
> + rc = pthread_join(thread, NULL);
> }
> - /* Free attribute and wait for the other threads */
> - pthread_attr_destroy(&attr);
> - rc = pthread_join(thread, NULL);
>
> return (param.status);
> }
Hello Ritesh,
Maybe there is something I'm not aware of, but is there any reason why
the pthread_attr_destroy() call occurs twice in this patch instead of
invoking it before the "if (rc) {" statement ? From the
pthread_attr_destroy() man page: "Destroying a thread attributes object
has no effect on threads that were created using that object".
Thanks,
Bart.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Don't exit() from library
2014-03-11 8:45 ` Bart Van Assche
@ 2014-03-11 14:52 ` Ritesh Raj Sarraf
0 siblings, 0 replies; 3+ messages in thread
From: Ritesh Raj Sarraf @ 2014-03-11 14:52 UTC (permalink / raw)
To: Bart Van Assche, device-mapper development, christophe.varoqui
[-- Attachment #1.1: Type: text/plain, Size: 613 bytes --]
On 03/11/2014 02:15 PM, Bart Van Assche wrote:
> Hello Ritesh,
>
> Maybe there is something I'm not aware of, but is there any reason why
> the pthread_attr_destroy() call occurs twice in this patch instead of
> invoking it before the "if (rc) {" statement ? From the
> pthread_attr_destroy() man page: "Destroying a thread attributes object
> has no effect on threads that were created using that object".
Yup!! You're right. I won't have access to the dev box today. Can you
please follow it up ?
--
Ritesh Raj Sarraf | http://people.debian.org/~rrs
Debian - The Universal Operating System
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-03-11 14:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-11 6:10 [PATCH] Don't exit() from library Ritesh Raj Sarraf
2014-03-11 8:45 ` Bart Van Assche
2014-03-11 14:52 ` Ritesh Raj Sarraf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).