Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pthread_cond_destroy问题 #3870

Open
zmj64351508 opened this issue Sep 2, 2020 · 3 comments
Open

pthread_cond_destroy问题 #3870

zmj64351508 opened this issue Sep 2, 2020 · 3 comments
Labels
bug

Comments

@zmj64351508
Copy link

@zmj64351508 zmj64351508 commented Sep 2, 2020

int ret;
pthread_cond_t hdl;
pthread_cond_init(&hdl, NULL);
ret = pthread_cond_destroy(&hdl);

问题:运行以上代码ret最终是EBUSY。看了下代码,rt_sem_trytake在计数为0的情况下会返回-RT_ETIMEOUT,pthread_cond_destroy会判断rt_sem_trytake的返回值,一旦不是RT_OK就返回EBUSY。

希望的结果:上述代码运行后ret应该是0。

@BernardXiong
Copy link
Member

@BernardXiong BernardXiong commented Sep 4, 2020

多谢反馈,后面修正下

@KyleChenjh
Copy link
Contributor

@KyleChenjh KyleChenjh commented Nov 24, 2020

@zmj64351508 rt_sem_trytake在计数为0,并且time为0条件下,返回应该就是-RT_ETIMEOUT,然后pthread_cond_destroy去判断这个返回值时候,就应该是EBUSY状态的。因为它没成功获取到信号量,所以也不能clean condition。

@Guozhanxin
Copy link
Member

@Guozhanxin Guozhanxin commented Nov 25, 2020

楼主确认下问题吧,如果没问题,这个issue就关闭吧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.