struct msqid_ds {
struct ipc_perm msg_perm; /* Ownership and permissions */
time_t msg_stime; /* Time of last msgsnd(2) */
time_t msg_rtime; /* Time of last msgrcv(2) */
time_t msg_ctime; /* Time of last change */
unsigned long __msg_cbytes; /* Current number of bytes in
queue (nonstandard) */
msgqnum_t msg_qnum; /* Current number of messages
in queue */
msglen_t msg_qbytes; /* Maximum number of bytes
allowed in queue */
pid_t msg_lspid; /* PID of last msgsnd(2) */
pid_t msg_lrpid; /* PID of last msgrcv(2) */
};

msg_qbytes -> 큐 최대 크기

이 값을 변경 하더라도 커널의 msgmnb(커널의 기본 큐 최대사이즈) 값을 넘을 수 없다.

기본적으로 설정된 msgmnb값보다 큰 값을 설정하기 위해선 아래 두 가지 방법을 사용해야한다.

1. kenel.msgmnb 값 변경

- root 계정으로 해당 계정의 최대값을 수정

2. Capabilites 설정

- Capabilites를 이용하여 해당파일 또는 계정의 CAP_SYS_RESOURCE 권한을 활성화 시키면된다.

IPC_SET
Write the values of some members of the msqid_ds structure pointed to by buf to the kernel data structure associated with this message queue, updating also its msg_ctime member.
The following members of the structure are updated: msg_qbytes, msg_perm.uid, msg_perm.gid, and (the least significant 9 bits of) msg_perm.mode.
The effective UID of the calling process must match the owner (msg_perm.uid) or creator (msg_perm.cuid) of the message queue, or the caller must be privileged. Appropriate privilege (Linux: the CAP_SYS_RESOURCE capability) is required to raise the msg_qbytes value beyond the system parameter MSGMNB.

CAP_SYS_RESOURCE 는 메세지큐의 최대크기 제한을 무시할 수 있는 권한이 있다.

'통신 > 메세지큐' 카테고리의 다른 글

메세지큐 버퍼 사이즈 변경  (0) 2022.11.08
메세지큐  (0) 2022.07.27

+ Recent posts