Lines Matching refs:qp

283 static int msgq_check_err(kmsqid_t *qp, int cvres);
351 kmsqid_t *qp = (kmsqid_t *)perm; in msg_dtor() local
355 ASSERT(list_is_empty(&qp->msg_wait_snd[ii])); in msg_dtor()
356 ASSERT(list_is_empty(&qp->msg_wait_snd_ngt[ii])); in msg_dtor()
357 list_destroy(&qp->msg_wait_snd[ii]); in msg_dtor()
358 list_destroy(&qp->msg_wait_snd_ngt[ii]); in msg_dtor()
360 ASSERT(list_is_empty(&qp->msg_cpy_block)); in msg_dtor()
361 ASSERT(list_is_empty(&qp->msg_wait_rcv)); in msg_dtor()
362 list_destroy(&qp->msg_cpy_block); in msg_dtor()
363 ASSERT(qp->msg_snd_cnt == 0); in msg_dtor()
364 ASSERT(qp->msg_cbytes == 0); in msg_dtor()
365 list_destroy(&qp->msg_list); in msg_dtor()
366 list_destroy(&qp->msg_wait_rcv); in msg_dtor()
394 msgunlink(kmsqid_t *qp, struct msg *mp) in msgunlink() argument
396 list_remove(&qp->msg_list, mp); in msgunlink()
397 qp->msg_qnum--; in msgunlink()
398 qp->msg_cbytes -= mp->msg_size; in msgunlink()
402 msg_wakeup_senders(qp); in msgunlink()
408 kmsqid_t *qp = (kmsqid_t *)perm; in msg_rmid() local
413 while ((mp = list_head(&qp->msg_list)) != NULL) in msg_rmid()
414 msgunlink(qp, mp); in msg_rmid()
415 ASSERT(qp->msg_cbytes == 0); in msg_rmid()
422 msg_rcvq_wakeup_all(&qp->msg_wait_snd[ii]); in msg_rmid()
423 msg_rcvq_wakeup_all(&qp->msg_wait_snd_ngt[ii]); in msg_rmid()
425 msg_rcvq_wakeup_all(&qp->msg_cpy_block); in msg_rmid()
426 msg_rcvq_wakeup_all(&qp->msg_wait_rcv); in msg_rmid()
439 kmsqid_t *qp; /* ptr to associated q */ in msgctl() local
473 if ((lock = ipc_lookup(msq_svc, msgid, (kipc_perm_t **)&qp)) == NULL) in msgctl()
478 if (STRUCT_FGET(ds, msg_qbytes) > qp->msg_qbytes && in msgctl()
483 if (error = ipcperm_set(msq_svc, cr, &qp->msg_perm, in msgctl()
488 qp->msg_qbytes = STRUCT_FGET(ds, msg_qbytes); in msgctl()
489 qp->msg_ctime = gethrestime_sec(); in msgctl()
493 if (error = ipcperm_access(&qp->msg_perm, MSG_R, cr)) { in msgctl()
498 if (qp->msg_rcv_cnt) in msgctl()
499 qp->msg_perm.ipc_mode |= MSG_RWAIT; in msgctl()
500 if (qp->msg_snd_cnt) in msgctl()
501 qp->msg_perm.ipc_mode |= MSG_WWAIT; in msgctl()
502 ipcperm_stat(&STRUCT_BUF(ds)->msg_perm, &qp->msg_perm, mdl); in msgctl()
503 qp->msg_perm.ipc_mode &= ~(MSG_RWAIT|MSG_WWAIT); in msgctl()
506 STRUCT_FSET(ds, msg_cbytes, qp->msg_cbytes); in msgctl()
507 STRUCT_FSET(ds, msg_qnum, qp->msg_qnum); in msgctl()
508 STRUCT_FSET(ds, msg_qbytes, qp->msg_qbytes); in msgctl()
509 STRUCT_FSET(ds, msg_lspid, qp->msg_lspid); in msgctl()
510 STRUCT_FSET(ds, msg_lrpid, qp->msg_lrpid); in msgctl()
511 STRUCT_FSET(ds, msg_stime, qp->msg_stime); in msgctl()
512 STRUCT_FSET(ds, msg_rtime, qp->msg_rtime); in msgctl()
513 STRUCT_FSET(ds, msg_ctime, qp->msg_ctime); in msgctl()
518 if ((ds64.msgx_qbytes > qp->msg_qbytes) && in msgctl()
527 if (error = ipcperm_set64(msq_svc, cr, &qp->msg_perm, in msgctl()
532 qp->msg_qbytes = ds64.msgx_qbytes; in msgctl()
533 qp->msg_ctime = gethrestime_sec(); in msgctl()
537 if (qp->msg_rcv_cnt) in msgctl()
538 qp->msg_perm.ipc_mode |= MSG_RWAIT; in msgctl()
539 if (qp->msg_snd_cnt) in msgctl()
540 qp->msg_perm.ipc_mode |= MSG_WWAIT; in msgctl()
541 ipcperm_stat64(&ds64.msgx_perm, &qp->msg_perm); in msgctl()
542 qp->msg_perm.ipc_mode &= ~(MSG_RWAIT|MSG_WWAIT); in msgctl()
543 ds64.msgx_cbytes = qp->msg_cbytes; in msgctl()
544 ds64.msgx_qnum = qp->msg_qnum; in msgctl()
545 ds64.msgx_qbytes = qp->msg_qbytes; in msgctl()
546 ds64.msgx_lspid = qp->msg_lspid; in msgctl()
547 ds64.msgx_lrpid = qp->msg_lrpid; in msgctl()
548 ds64.msgx_stime = qp->msg_stime; in msgctl()
549 ds64.msgx_rtime = qp->msg_rtime; in msgctl()
550 ds64.msgx_ctime = qp->msg_ctime; in msgctl()
595 kmsqid_t *qp; in msgget() local
602 if (error = ipc_get(msq_svc, key, msgflg, (kipc_perm_t **)&qp, &lock)) in msgget()
605 if (IPC_FREE(&qp->msg_perm)) { in msgget()
609 list_create(&qp->msg_list, sizeof (struct msg), in msgget()
611 qp->msg_qnum = 0; in msgget()
612 qp->msg_lspid = qp->msg_lrpid = 0; in msgget()
613 qp->msg_stime = qp->msg_rtime = 0; in msgget()
614 qp->msg_ctime = gethrestime_sec(); in msgget()
615 qp->msg_ngt_cnt = 0; in msgget()
616 qp->msg_neg_copy = 0; in msgget()
618 list_create(&qp->msg_wait_snd[ii], in msgget()
621 list_create(&qp->msg_wait_snd_ngt[ii], in msgget()
631 qp->msg_lowest_type = MSG_SMALL_INIT; in msgget()
632 list_create(&qp->msg_cpy_block, in msgget()
635 list_create(&qp->msg_wait_rcv, in msgget()
638 qp->msg_fnd_sndr = &msg_fnd_sndr[0]; in msgget()
639 qp->msg_fnd_rdr = &msg_fnd_rdr[0]; in msgget()
640 qp->msg_rcv_cnt = 0; in msgget()
641 qp->msg_snd_cnt = 0; in msgget()
642 qp->msg_snd_smallest = MSG_SMALL_INIT; in msgget()
645 (kipc_perm_t *)qp)) { in msgget()
650 qp->msg_qbytes = rctl_enforced_value(rc_process_msgmnb, in msgget()
652 qp->msg_qmax = rctl_enforced_value(rc_process_msgtql, in msgget()
654 lock = ipc_commit_end(msq_svc, &qp->msg_perm); in msgget()
658 audit_ipcget(AT_IPC_MSG, (void *)qp); in msgget()
660 id = qp->msg_perm.ipc_id; in msgget()
669 kmsqid_t *qp; /* ptr to associated q */ in msgrcv() local
680 if ((lock = ipc_lookup(msq_svc, msqid, (kipc_perm_t **)&qp)) == NULL) { in msgrcv()
683 ipc_hold(msq_svc, (kipc_perm_t *)qp); in msgrcv()
685 if (error = ipcperm_access(&qp->msg_perm, MSG_R, CRED())) { in msgrcv()
697 smp = msgrcv_lookup(qp, msgtyp); in msgrcv()
710 error = msg_copyout(qp, msgtyp, &lock, &xtsz, msgsz, in msgrcv()
723 msg_wakeup_rdr(qp, &qp->msg_fnd_sndr, t); in msgrcv()
729 msg_wakeup_rdr(qp, &qp->msg_fnd_rdr, 0); in msgrcv()
738 cvres = msg_rcvq_sleep(&qp->msg_cpy_block, in msgrcv()
739 &msg_entry, &lock, qp); in msgrcv()
740 error = msgq_check_err(qp, cvres); in msgrcv()
754 msg_wakeup_rdr(qp, &qp->msg_fnd_rdr, 0); in msgrcv()
762 cvres = msg_rcvq_sleep(&qp->msg_wait_snd[msg_hash], in msgrcv()
763 &msg_entry, &lock, qp); in msgrcv()
765 qp->msg_ngt_cnt++; in msgrcv()
766 cvres = msg_rcvq_sleep(&qp->msg_wait_snd_ngt[msg_hash], in msgrcv()
767 &msg_entry, &lock, qp); in msgrcv()
768 qp->msg_ngt_cnt--; in msgrcv()
771 if (!(error = msgq_check_err(qp, cvres))) { in msgrcv()
777 msg_wakeup_rdr(qp, &qp->msg_fnd_rdr, 0); in msgrcv()
779 msg_wakeup_rdr(qp, &qp->msg_fnd_sndr, in msgrcv()
782 ipc_rele(msq_svc, (kipc_perm_t *)qp); in msgrcv()
785 ipc_rele(msq_svc, (kipc_perm_t *)qp); in msgrcv()
790 msgq_check_err(kmsqid_t *qp, int cvres) in msgq_check_err() argument
792 if (IPC_FREE(&qp->msg_perm)) { in msgq_check_err()
804 msg_copyout(kmsqid_t *qp, long msgtyp, kmutex_t **lock, size_t *xtsz_ret, in msg_copyout() argument
833 ASSERT(qp->msg_neg_copy == 0); in msg_copyout()
834 qp->msg_neg_copy = 1; in msg_copyout()
860 *lock = ipc_lock(msq_svc, qp->msg_perm.ipc_id); in msg_copyout()
862 qp->msg_neg_copy = 0; in msg_copyout()
867 if (IPC_FREE(&qp->msg_perm)) { in msg_copyout()
873 qp->msg_lrpid = ttoproc(curthread)->p_pid; in msg_copyout()
874 qp->msg_rtime = gethrestime_sec(); in msg_copyout()
875 msgunlink(qp, smp); in msg_copyout()
880 msgrcv_lookup(kmsqid_t *qp, long msgtyp) in msgrcv_lookup() argument
888 mp = list_head(&qp->msg_list); in msgrcv_lookup()
892 qp_low = qp->msg_lowest_type; in msgrcv_lookup()
903 for (; mp; mp = list_next(&qp->msg_list, mp)) { in msgrcv_lookup()
922 if (qp->msg_neg_copy) { in msgrcv_lookup()
926 for (; mp; mp = list_next(&qp->msg_list, mp)) { in msgrcv_lookup()
940 qp->msg_lowest_type = smp->msg_type; in msgrcv_lookup()
971 kmsqid_t *qp; /* ptr to associated q */ in msgsnap() local
987 if ((lock = ipc_lookup(msq_svc, msqid, (kipc_perm_t **)&qp)) == NULL) in msgsnap()
990 if (error = ipcperm_access(&qp->msg_perm, MSG_R, CRED())) { in msgsnap()
994 ipc_hold(msq_svc, (kipc_perm_t *)qp); in msgsnap()
1001 for (mp = list_head(&qp->msg_list); mp; in msgsnap()
1002 mp = list_next(&qp->msg_list, mp)) { in msgsnap()
1025 for (mp = list_head(&qp->msg_list); mp; in msgsnap()
1026 mp = list_next(&qp->msg_list, mp)) { in msgsnap()
1069 lock = ipc_lock(msq_svc, qp->msg_perm.ipc_id); in msgsnap()
1072 if (IPC_FREE(&qp->msg_perm)) in msgsnap()
1077 (void) ipc_lock(msq_svc, qp->msg_perm.ipc_id); in msgsnap()
1078 ipc_rele(msq_svc, (kipc_perm_t *)qp); in msgsnap()
1096 kmsqid_t *qp; in msgsnd() local
1147 if ((lock = ipc_lookup(msq_svc, msqid, (kipc_perm_t **)&qp)) == NULL) { in msgsnd()
1152 ipc_hold(msq_svc, (kipc_perm_t *)qp); in msgsnd()
1154 if (msgsz > qp->msg_qbytes) { in msgsnd()
1159 if (error = ipcperm_access(&qp->msg_perm, MSG_W, CRED())) in msgsnd()
1166 ASSERT(qp->msg_qnum <= qp->msg_qmax); in msgsnd()
1167 while ((msgsz > qp->msg_qbytes - qp->msg_cbytes) || in msgsnd()
1168 (qp->msg_qnum == qp->msg_qmax)) { in msgsnd()
1177 qp->msg_snd_cnt++; in msgsnd()
1182 list_insert_tail(&qp->msg_wait_rcv, &msg_entry); in msgsnd()
1183 if (qp->msg_snd_smallest > msgsz) in msgsnd()
1184 qp->msg_snd_smallest = msgsz; in msgsnd()
1186 lock = ipc_relock(msq_svc, qp->msg_perm.ipc_id, lock); in msgsnd()
1187 qp->msg_snd_cnt--; in msgsnd()
1189 list_remove(&qp->msg_wait_rcv, &msg_entry); in msgsnd()
1190 if (error = msgq_check_err(qp, cvres)) { in msgsnd()
1208 lock = ipc_lock(msq_svc, qp->msg_perm.ipc_id); in msgsnd()
1209 if (IPC_FREE(&qp->msg_perm)) { in msgsnd()
1223 qp->msg_qnum++; in msgsnd()
1224 qp->msg_cbytes += msgsz; in msgsnd()
1225 qp->msg_lspid = curproc->p_pid; in msgsnd()
1226 qp->msg_stime = gethrestime_sec(); in msgsnd()
1228 if (qp->msg_lowest_type > type) in msgsnd()
1229 qp->msg_lowest_type = type; in msgsnd()
1230 list_insert_tail(&qp->msg_list, mp); in msgsnd()
1234 msg_wakeup_rdr(qp, &qp->msg_fnd_sndr, type); in msgsnd()
1245 msg_wakeup_senders(qp); in msgsnd()
1248 ipc_rele(msq_svc, (kipc_perm_t *)qp); /* drops lock */ in msgsnd()
1260 msg_wakeup_rdr(kmsqid_t *qp, msg_select_t **flist, long type) in msg_wakeup_rdr() argument
1269 wakeup = walker->selection(qp, msg_hash, type); in msg_wakeup_rdr()
1314 msg_fnd_any_snd(kmsqid_t *qp, int msg_hash, long type) in msg_fnd_any_snd() argument
1318 walker = list_head(&qp->msg_wait_snd[0]); in msg_fnd_any_snd()
1321 list_remove(&qp->msg_wait_snd[0], walker); in msg_fnd_any_snd()
1327 msg_fnd_any_rdr(kmsqid_t *qp, int msg_hash, long type) in msg_fnd_any_rdr() argument
1331 walker = list_head(&qp->msg_cpy_block); in msg_fnd_any_rdr()
1333 list_remove(&qp->msg_cpy_block, walker); in msg_fnd_any_rdr()
1338 msg_fnd_spc_snd(kmsqid_t *qp, int msg_hash, long type) in msg_fnd_spc_snd() argument
1342 walker = list_head(&qp->msg_wait_snd[msg_hash]); in msg_fnd_spc_snd()
1345 walker = list_next(&qp->msg_wait_snd[msg_hash], walker); in msg_fnd_spc_snd()
1347 list_remove(&qp->msg_wait_snd[msg_hash], walker); in msg_fnd_spc_snd()
1353 msg_fnd_neg_snd(kmsqid_t *qp, int msg_hash, long type) in msg_fnd_neg_snd() argument
1361 if (!qp->msg_ngt_cnt) { in msg_fnd_neg_snd()
1376 check_index = neg_index + (qp->msg_stime % nbuckets); in msg_fnd_neg_snd()
1379 qptr = list_head(&qp->msg_wait_snd_ngt[check_index]); in msg_fnd_neg_snd()
1389 list_remove(&qp->msg_wait_snd_ngt[check_index], in msg_fnd_neg_snd()
1393 qptr = list_next(&qp->msg_wait_snd_ngt[check_index], in msg_fnd_neg_snd()
1405 kmsqid_t *qp) in msg_rcvq_sleep() argument
1413 qp->msg_rcv_cnt++; in msg_rcvq_sleep()
1415 *lock = ipc_relock(msq_svc, qp->msg_perm.ipc_id, *lock); in msg_rcvq_sleep()
1416 qp->msg_rcv_cnt--; in msg_rcvq_sleep()
1483 msg_wakeup_senders(kmsqid_t *qp) in msg_wakeup_senders() argument
1494 if (IPC_FREE(&qp->msg_perm) || qp->msg_qnum >= qp->msg_qmax) in msg_wakeup_senders()
1497 avail = qp->msg_qbytes - qp->msg_cbytes; in msg_wakeup_senders()
1498 if (avail < qp->msg_snd_smallest) in msg_wakeup_senders()
1501 ptr = list_head(&qp->msg_wait_rcv); in msg_wakeup_senders()
1503 qp->msg_snd_smallest = MSG_SMALL_INIT; in msg_wakeup_senders()
1519 msgs_out = qp->msg_qnum; in msg_wakeup_senders()
1521 ptr = list_next(&qp->msg_wait_rcv, ptr); in msg_wakeup_senders()
1523 list_remove(&qp->msg_wait_rcv, optr); in msg_wakeup_senders()
1527 if (msgs_out == qp->msg_qmax || in msg_wakeup_senders()
1528 avail < qp->msg_snd_smallest) in msg_wakeup_senders()
1541 qp->msg_snd_smallest = smallest; in msg_wakeup_senders()