From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 2/2] POSIX: Allow pthread_cond_destroy to block
Date: Thu, 12 Oct 2017 16:01:11 +0200 [thread overview]
Message-ID: <20171012140111.GC21253@rei> (raw)
In-Reply-To: <20171009101824.17251-3-rpalethorpe@suse.com>
Hi!
Do I understand this correctly that this is a preemptive fix? Since this
test seems to work fine for me, while the barrier one blocks.
Can we have this kind of information included in the commit message as
well?
> int main(void)
> {
> - pthread_t low_id;
> + pthread_t low_id, watchdog_thread;
> int rc = 0;
>
> - /* Create a new thread with default attributes */
> rc = pthread_create(&low_id, NULL, thread, NULL);
> if (rc != 0) {
> - printf(ERROR_PREFIX "pthread_create\n");
> + perror("main: pthread_create");
> exit(PTS_UNRESOLVED);
> }
>
> - /* Let the other thread run */
> - sleep(2);
> + sleep(1);
> +
> + rc = pthread_create(&watchdog_thread, NULL, watchdog, NULL);
> + if (rc != 0) {
> + perror("main: pthread_create");
> + exit(PTS_UNRESOLVED);
> + }
>
> - /* Try to destroy the cond var. This should return an error */
> rc = pthread_cond_destroy(&cond);
> if (rc != EBUSY) {
> - printf(ERROR_PREFIX "Test PASS: Expected %d(EBUSY) got %d, "
> - "though the standard states 'may' fail\n", EBUSY, rc);
> -
> - exit(PTS_PASS);
> + printf("The standard recommends returning %d, EBUSY, but got %d, %s\n",
> + EBUSY, rc, strerror(rc));
> }
Here as well, I would consider checking either for succes or for EBUSY,
it does not make any sense to return any other error than the one
specified in the standard in a case that we do not return 0.
> + pthread_cancel(watchdog_thread);
> + pthread_cancel(low_id);
> +
> printf("Test PASSED\n");
> exit(PTS_PASS);
> }
> --
> 2.14.2
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2017-10-12 14:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-09 10:18 [LTP] [PATCH 0/2] Updates to pthread_{barrier,cond}_destroy() Richard Palethorpe
2017-10-09 10:18 ` [LTP] [PATCH 1/2] POSIX: Allow pthread_barrier_destroy() to block Richard Palethorpe
2017-10-12 13:34 ` Cyril Hrubis
2017-10-13 8:58 ` Richard Palethorpe
2017-10-13 9:37 ` Cyril Hrubis
2017-10-13 12:57 ` Richard Palethorpe
2017-10-09 10:18 ` [LTP] [PATCH 2/2] POSIX: Allow pthread_cond_destroy " Richard Palethorpe
2017-10-12 14:01 ` Cyril Hrubis [this message]
2017-10-13 9:06 ` Richard Palethorpe
2017-10-13 9:20 ` Cyril Hrubis
2017-10-12 13:14 ` [LTP] [PATCH 0/2] Updates to pthread_{barrier,cond}_destroy() Cyril Hrubis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171012140111.GC21253@rei \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox