阅读背景:

创建消息队列 msg_id

来源:互联网 
const int BaseMsgq::proj_id_ = static_cast<int>('a');
const char *BaseMsgq::pathname_ = "/root";

BaseMsgq::BaseMsgq()
{
    msgq_key_ = ftok(pathname_, proj_id_);
    if (msgq_key_ < 0)
    {
        LOG_ERROR("fail to ftok('%s', %d).\n", pathname_, proj_id_);
        throw -1;
    }
    
    msgq_id_ = msgget(msgq_key_, IPC_EXCL);
    if (msgq_id_ < 0)
    {
        msgq_id_ = msgget(msgq_key_, IPC_CREAT | 0666);
        if (msgq_id_ < 0)
        {
            LOG_ERROR("fail to msgget.\n");
            throw -1;
        }
    }   
        
    clear();
}      const int BaseMsgq::proj_id_ = static_cas



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: