佚名通过本文主要向大家介绍了线程信号,linux 线程 信号,qt多线程信号,linux线程信号量,线程信号量等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: 一个quick-cocos2dx 226里遇到的一个线程信号锁的问题
描述:
CCHttpClient类里的send方法可以将请求发送出去。
void CCHttpClient::send(CCHttpRequest* request)
{
if (false == lazyInitThreadSemphore())
{
return;
}
if (!request)
{
return;
}
++s_asyncRequestCount;
request->retain();
pthread_mutex_lock(&s_requestQueueMutex);
s_requestQueue->addObject(request);
pthread_mutex_unlock(&s_requestQueueMutex);
// Notify thread start to work
sem_post(s_pSem);
}
但是,在发送之前会有一个切线程的准备工作,lazyInitThreadSemphore()
在这里面会有一个新建?信号灯的步骤
s_pSem = sem_open(CC_ASYNC_HTTPREQUEST_SEMAPHORE, O_CREAT, 0644, 0);
但是在某些时候,这个结果会是SEM_FAILED,然后查看errno,结果是EPERM
#define EPERM 1 /* Operation not permitted */
因为这个问题并非必现,所以想问一下,什么情况会导致"Operation not permitted"
描述:
本帖最后由 u013962723 于 2016-08-23 18:30:40 编辑
quick-cocos2dHttpRequestsem_open
quick的网络调用是通过在文件HttpClient.cpp里实现的CCHttpClient类里的send方法可以将请求发送出去。
void CCHttpClient::send(CCHttpRequest* request)
{
if (false == lazyInitThreadSemphore())
{
return;
}
if (!request)
{
return;
}
++s_asyncRequestCount;
request->retain();
pthread_mutex_lock(&s_requestQueueMutex);
s_requestQueue->addObject(request);
pthread_mutex_unlock(&s_requestQueueMutex);
// Notify thread start to work
sem_post(s_pSem);
}
但是,在发送之前会有一个切线程的准备工作,lazyInitThreadSemphore()
在这里面会有一个新建?信号灯的步骤
s_pSem = sem_open(CC_ASYNC_HTTPREQUEST_SEMAPHORE, O_CREAT, 0644, 0);
但是在某些时候,这个结果会是SEM_FAILED,然后查看errno,结果是EPERM
#define EPERM 1 /* Operation not permitted */
因为这个问题并非必现,所以想问一下,什么情况会导致"Operation not permitted"