- 论坛徽章:
- 0
|
Sco UnixWare下消息队列通信,发送时系统错误为errno = 11,但发送之前检查消息队列消息个数为0,请问各位高手除了消息队列满以外还有其他什么原因引起系统返回11。这段代码如下:
int SendMessage(nMsgId, lMsgType, pszSendData)
int nMsgId;
long lMsgType;
char *pszSendData;
{
int nRet, nMaxQueueNum;
struct MessageSTRU MsgStru;
struct msqid_ds msInfo;
nMaxQueueNum = MAX_QUEUE_NUM;
/*检测消息队列是否已满*/
while(1){
nRet = msgctl(nMsgId, IPC_STAT, &msInfo);
if( nRet == FAIL)
return FAIL;
if( msInfo.msg_qnum < nMaxQueueNum )
break;
else
nap(30);
}
MsgStru.lMsgType = lMsgType;
memcpy(MsgStru.szMsgText, pszSendData, PUBSIZE);
nRet = msgsnd(nMsgId, &MsgStru, PUBSIZE, IPC_NOWAIT);
if( nRet != 0 ){
ErrorLog(ERROR, "send msg error[%d] MsgType[%ld]
qnum[%ld]", errno, MsgStru.lMsgType, sInfo.msg_qnum);
return( FAIL );
}
return( SUCC );
}
错误信息为send msg error[11] MsgType[10] qnum[0]。 |
|