Fixes to MQ open logic

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1348 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2008-11-29 16:04:20 +00:00
parent 83f73e5b5f
commit f48db4efac
2 changed files with 6 additions and 8 deletions

View File

@ -152,7 +152,7 @@ NXHANDLE nx_connectionstance(FAR const char *svrmqname)
#else #else
conn->crdmq = mq_open(climqname, O_RDONLY|O_CREAT|O_NONBLOCK, 0666, &attr); conn->crdmq = mq_open(climqname, O_RDONLY|O_CREAT|O_NONBLOCK, 0666, &attr);
#endif #endif
if (conn->crdmq) if (conn->crdmq == (mqd_t)-1)
{ {
gdbg("mq_open(%s) failed: %d\n", climqname, errno); gdbg("mq_open(%s) failed: %d\n", climqname, errno);
goto errout_with_conn; goto errout_with_conn;
@ -165,7 +165,7 @@ NXHANDLE nx_connectionstance(FAR const char *svrmqname)
attr.mq_flags = 0; attr.mq_flags = 0;
conn->cwrmq = mq_open(svrmqname, O_WRONLY|O_CREAT, 0666, &attr); conn->cwrmq = mq_open(svrmqname, O_WRONLY|O_CREAT, 0666, &attr);
if (conn->cwrmq) if (conn->cwrmq == (mqd_t)-1)
{ {
gdbg("mq_open(%s) failed: %d\n", svrmqname, errno); gdbg("mq_open(%s) failed: %d\n", svrmqname, errno);
goto errout_with_rmq; goto errout_with_rmq;

View File

@ -116,7 +116,7 @@ static inline void nxmu_connect(FAR struct nxfe_conn_s *conn)
outmsg.msgid = NX_CLIMSG_CONNECTED; outmsg.msgid = NX_CLIMSG_CONNECTED;
conn->swrmq = mq_open(mqname, O_WRONLY); conn->swrmq = mq_open(mqname, O_WRONLY);
if (conn->swrmq) if (conn->swrmq == (mqd_t)-1)
{ {
gdbg("mq_open(%s) failed: %d\n", mqname, errno); gdbg("mq_open(%s) failed: %d\n", mqname, errno);
outmsg.msgid = NX_CLIMSG_DISCONNECTED; outmsg.msgid = NX_CLIMSG_DISCONNECTED;
@ -224,7 +224,7 @@ static inline int nxmu_setup(FAR const char *mqname,
attr.mq_flags = 0; attr.mq_flags = 0;
fe->conn.crdmq = mq_open(mqname, O_RDONLY|O_CREAT, 0666, &attr); fe->conn.crdmq = mq_open(mqname, O_RDONLY|O_CREAT, 0666, &attr);
if (fe->conn.crdmq) if (fe->conn.crdmq == (mqd_t)-1)
{ {
gdbg("mq_open(%s) failed: %d\n", mqname, errno); gdbg("mq_open(%s) failed: %d\n", mqname, errno);
return ERROR; /* mq_open sets errno */ return ERROR; /* mq_open sets errno */
@ -239,10 +239,8 @@ static inline int nxmu_setup(FAR const char *mqname,
* the server message loop. * the server message loop.
*/ */
/* Open the server MQ for writing (same attributes) */ fe->conn.swrmq = mq_open(mqname, O_WRONLY);
if (fe->conn.swrmq == (mqd_t)-1)
fe->conn.cwrmq = mq_open(mqname, O_WRONLY);
if (fe->conn.cwrmq)
{ {
gdbg("mq_open(%s) failed: %d\n", mqname, errno); gdbg("mq_open(%s) failed: %d\n", mqname, errno);
mq_close(fe->conn.crdmq); mq_close(fe->conn.crdmq);