Lines Matching refs:msgque

35 int restore_queue(struct msgque_data *msgque)  in restore_queue()  argument
45 sprintf(buf, "%d", msgque->msq_id); in restore_queue()
53 id = msgget(msgque->key, msgque->mode | IPC_CREAT | IPC_EXCL); in restore_queue()
59 if (id != msgque->msq_id) { in restore_queue()
61 id, msgque->msq_id); in restore_queue()
66 for (i = 0; i < msgque->qnum; i++) { in restore_queue()
67 if (msgsnd(msgque->msq_id, &msgque->messages[i].mtype, in restore_queue()
68 msgque->messages[i].msize, IPC_NOWAIT) != 0) { in restore_queue()
82 int check_and_destroy_queue(struct msgque_data *msgque) in check_and_destroy_queue() argument
88 ret = msgrcv(msgque->msq_id, &message.mtype, MAX_MSG_SIZE, in check_and_destroy_queue()
97 if (ret != msgque->messages[cnt].msize) { in check_and_destroy_queue()
99 msgque->messages[cnt].msize); in check_and_destroy_queue()
103 if (message.mtype != msgque->messages[cnt].mtype) { in check_and_destroy_queue()
108 if (memcmp(message.mtext, msgque->messages[cnt].mtext, ret)) { in check_and_destroy_queue()
116 if (cnt != msgque->qnum) { in check_and_destroy_queue()
124 if (msgctl(msgque->msq_id, IPC_RMID, NULL)) { in check_and_destroy_queue()
131 int dump_queue(struct msgque_data *msgque) in dump_queue() argument
147 if (ret == msgque->msq_id) in dump_queue()
151 msgque->messages = malloc(sizeof(struct msg1) * ds.msg_qnum); in dump_queue()
152 if (msgque->messages == NULL) { in dump_queue()
157 msgque->qnum = ds.msg_qnum; in dump_queue()
158 msgque->mode = ds.msg_perm.mode; in dump_queue()
159 msgque->qbytes = ds.msg_qbytes; in dump_queue()
161 for (i = 0; i < msgque->qnum; i++) { in dump_queue()
162 ret = msgrcv(msgque->msq_id, &msgque->messages[i].mtype, in dump_queue()
168 msgque->messages[i].msize = ret; in dump_queue()
173 int fill_msgque(struct msgque_data *msgque) in fill_msgque() argument
179 if (msgsnd(msgque->msq_id, &msgbuf.mtype, sizeof(TEST_STRING), in fill_msgque()
187 if (msgsnd(msgque->msq_id, &msgbuf.mtype, sizeof(ANOTHER_TEST_STRING), in fill_msgque()
198 struct msgque_data msgque; in main() local
203 msgque.key = ftok(argv[0], 822155650); in main()
204 if (msgque.key == -1) { in main()
209 msgque.msq_id = msgget(msgque.key, IPC_CREAT | IPC_EXCL | 0666); in main()
210 if (msgque.msq_id == -1) { in main()
216 err = fill_msgque(&msgque); in main()
222 err = dump_queue(&msgque); in main()
228 err = check_and_destroy_queue(&msgque); in main()
234 err = restore_queue(&msgque); in main()
240 err = check_and_destroy_queue(&msgque); in main()
248 if (msgctl(msgque.msq_id, IPC_RMID, NULL)) { in main()