|
9 | 9 | //! use nix::sys::stat::Mode; |
10 | 10 | //! |
11 | 11 | //! const MSG_SIZE: mq_attr_member_t = 32; |
12 | | -//! let mq_name= "/a_nix_test_queue"; |
| 12 | +//! let attr = MqAttr::new(0, 10, MSG_SIZE, 0); |
| 13 | +//! let mq_name= "/a_nix_doc_test_queue"; |
13 | 14 | //! |
14 | 15 | //! let oflag0 = MQ_OFlag::O_CREAT | MQ_OFlag::O_WRONLY; |
15 | 16 | //! let mode = Mode::S_IWUSR | Mode::S_IRUSR | Mode::S_IRGRP | Mode::S_IROTH; |
16 | | -//! let mqd0 = mq_open(mq_name, oflag0, mode, None).unwrap(); |
| 17 | +//! let mqd0 = mq_open(mq_name, oflag0, mode, Some(&attr)).unwrap(); |
17 | 18 | //! let msg_to_send = b"msg_1"; |
18 | 19 | //! mq_send(&mqd0, msg_to_send, 1).unwrap(); |
19 | 20 | //! |
20 | 21 | //! let oflag1 = MQ_OFlag::O_CREAT | MQ_OFlag::O_RDONLY; |
21 | | -//! let mqd1 = mq_open(mq_name, oflag1, mode, None).unwrap(); |
22 | | -//! let mut buf = [0u8; 32]; |
| 22 | +//! let mqd1 = mq_open(mq_name, oflag1, mode, Some(&attr)).unwrap(); |
| 23 | +//! let mut buf = [0u8; MSG_SIZE as usize]; |
23 | 24 | //! let mut prio = 0u32; |
24 | 25 | //! let len = mq_receive(&mqd1, &mut buf, &mut prio).unwrap(); |
25 | 26 | //! assert_eq!(prio, 1); |
@@ -100,7 +101,9 @@ impl MqAttr { |
100 | 101 | /// |
101 | 102 | /// - `mq_flags`: Either `0` or `O_NONBLOCK`. |
102 | 103 | /// - `mq_maxmsg`: Maximum number of messages on the queue. |
| 104 | + /// The maximum value allowed by the system can be obtained from `/proc/sys/fs/mqueue/msg_max`. |
103 | 105 | /// - `mq_msgsize`: Maximum message size in bytes. |
| 106 | + /// The maximum value allowed by the system can be obtained from `/proc/sys/fs/mqueue/msgsize_max`. |
104 | 107 | /// - `mq_curmsgs`: Number of messages currently in the queue. |
105 | 108 | pub fn new( |
106 | 109 | mq_flags: mq_attr_member_t, |
|
0 commit comments