From nobody Thu May 23 19:42:14 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VldqB5Trlz5L9Ww; Thu, 23 May 2024 19:42:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VldqB4Nyqz55FD; Thu, 23 May 2024 19:42:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716493334; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=XjOcFcyzPaPEQgMvKqgfX0eZwOfDd6OW6oYEMe5fYZA=; b=ulDUYAzzdMy21JggiFsLovBNROeMuRkErkoO2HnpdbwyjaWy5MuDZh2zbI8q5GxH+9d+LR G26r/WbSebl/YUbXwC0HBo2AGR5j04tlp768O/paBYHE0sB9PCwHrKKhpMrg9IrbHW6PNE 6SlKWIh1HMJedDeZA/R1lyRjTN96q5rNjsFDqyhtbs+c4CRKCl4AaiBg/3mZs6z/0xNIaX vB4TTGY1lfeumAypcYMDjA5OgccWTdz14cSR6qDwLeS2jsoC052ZVZU0VJmQ0bRDQ7YYeI DthhlxhZfzlcLCxAy3OGnbP6lrByuCe1Yxo0t4O+wuHgrsboAAlqqAiT7Srb3w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1716493334; a=rsa-sha256; cv=none; b=rOKaYGLshaHTQ0xOsLCCeQm98q+Woi04K/WnpcB42+fih2vxUAjnKFJyVQVHMH5QKH6dmr 58sUEp3MeRcoaJKIy6bjGubRnp3YiSeN1+U6t7gKSaR0UM6iVHyx/8fP7ZQWytmQ+wqOSc QWLDiK/v/R8Eibuffl27jm1ayVIGGdpoM0UEEGNwfON6eddafFuScxYpzYxu60ibLR1wEP 1wTkoxU9ltjjcjD6jJKhUaSSkagO8nJdEGiZS1E0YZwrPAAeVYSrkNy7hmHw3AWl2YSx1Y EfPHG1S4I927qG1Ps+VCt6a/91jJIPF1CXahied6f3uopUdmxeu16nTImML6gw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716493334; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=XjOcFcyzPaPEQgMvKqgfX0eZwOfDd6OW6oYEMe5fYZA=; b=czCCluWScahBnUzXPzG5R10Yx/VslAwEcZOpilaPUECD/sN2zkUZtDScbXi6bFQqcVEglr l/CaUP7po3aOpNrweCw2EZI2lc/W8bXt7U3/HUr96Abqu1Fp18WYo9JFUqYkz74L0Mv1gG Mj+PPbXq1qt7Ja0bzmK+kbcr2BqOvzIzyNgWfoCtbhyA+sGeXWLduMkqZrBVEcBuUIrbyK eMiO/SSnDRGc92gRNmUcikmstYggDHyP9rUaUCBJi8xm3OcVu/wZ/9amzCSu7JZd88C+oo kYv4LTESt2B0qSWugGNksMQd5COw/oNJMn0DykcpHV7SfBN0LdoOF+GeUDXTEg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VldqB41KRz12qG; Thu, 23 May 2024 19:42:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 44NJgEx6082774; Thu, 23 May 2024 19:42:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44NJgEQC082771; Thu, 23 May 2024 19:42:14 GMT (envelope-from git) Date: Thu, 23 May 2024 19:42:14 GMT Message-Id: <202405231942.44NJgEQC082771@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: e30621d58fa1 - main - mqueue: Introduce kern_kmq_timedreceive & kern_kmq_timedsend List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e30621d58fa10d82f3d4a89bb6b5572e2517b024 Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=e30621d58fa10d82f3d4a89bb6b5572e2517b024 commit e30621d58fa10d82f3d4a89bb6b5572e2517b024 Author: Ricardo Branco AuthorDate: 2024-05-18 15:19:39 +0000 Commit: Warner Losh CommitDate: 2024-05-23 19:40:46 +0000 mqueue: Introduce kern_kmq_timedreceive & kern_kmq_timedsend Reviewed by: imp, kib Pull Request: https://github.com/freebsd/freebsd-src/pull/1248 --- sys/kern/uipc_mqueue.c | 106 ++++++++++++++++++++++++------------------------- sys/sys/mqueue.h | 6 --- sys/sys/syscallsubr.h | 10 +++++ 3 files changed, 63 insertions(+), 59 deletions(-) diff --git a/sys/kern/uipc_mqueue.c b/sys/kern/uipc_mqueue.c index b48abf8788f6..c0948d40c47b 100644 --- a/sys/kern/uipc_mqueue.c +++ b/sys/kern/uipc_mqueue.c @@ -2275,58 +2275,77 @@ sys_kmq_setattr(struct thread *td, struct kmq_setattr_args *uap) } int -sys_kmq_timedreceive(struct thread *td, struct kmq_timedreceive_args *uap) +kern_kmq_timedreceive(struct thread *td, int mqd, char *msg_ptr, + size_t msg_len, unsigned int *msg_prio, const struct timespec *abs_timeout) { struct mqueue *mq; struct file *fp; + int error, waitok; + + AUDIT_ARG_FD(mqd); + error = getmq_read(td, mqd, &fp, NULL, &mq); + if (error != 0) + return (error); + waitok = (fp->f_flag & O_NONBLOCK) == 0; + error = mqueue_receive(mq, msg_ptr, msg_len, msg_prio, waitok, + abs_timeout); + fdrop(fp, td); + return (error); +} + +int +sys_kmq_timedreceive(struct thread *td, struct kmq_timedreceive_args *uap) +{ struct timespec *abs_timeout, ets; int error; - int waitok; - AUDIT_ARG_FD(uap->mqd); - error = getmq_read(td, uap->mqd, &fp, NULL, &mq); - if (error) - return (error); if (uap->abs_timeout != NULL) { error = copyin(uap->abs_timeout, &ets, sizeof(ets)); if (error != 0) - goto out; + return (error); abs_timeout = &ets; } else abs_timeout = NULL; - waitok = !(fp->f_flag & O_NONBLOCK); - error = mqueue_receive(mq, uap->msg_ptr, uap->msg_len, - uap->msg_prio, waitok, abs_timeout); -out: - fdrop(fp, td); - return (error); + + return (kern_kmq_timedreceive(td, uap->mqd, uap->msg_ptr, uap->msg_len, + uap->msg_prio, abs_timeout)); } int -sys_kmq_timedsend(struct thread *td, struct kmq_timedsend_args *uap) +kern_kmq_timedsend(struct thread *td, int mqd, const char *msg_ptr, + size_t msg_len, unsigned int msg_prio, const struct timespec *abs_timeout) { struct mqueue *mq; struct file *fp; - struct timespec *abs_timeout, ets; int error, waitok; - AUDIT_ARG_FD(uap->mqd); - error = getmq_write(td, uap->mqd, &fp, NULL, &mq); - if (error) + AUDIT_ARG_FD(mqd); + error = getmq_write(td, mqd, &fp, NULL, &mq); + if (error != 0) return (error); + waitok = (fp->f_flag & O_NONBLOCK) == 0; + error = mqueue_send(mq, msg_ptr, msg_len, msg_prio, waitok, + abs_timeout); + fdrop(fp, td); + return (error); +} + +int +sys_kmq_timedsend(struct thread *td, struct kmq_timedsend_args *uap) +{ + struct timespec *abs_timeout, ets; + int error; + if (uap->abs_timeout != NULL) { error = copyin(uap->abs_timeout, &ets, sizeof(ets)); if (error != 0) - goto out; + return (error); abs_timeout = &ets; } else abs_timeout = NULL; - waitok = !(fp->f_flag & O_NONBLOCK); - error = mqueue_send(mq, uap->msg_ptr, uap->msg_len, - uap->msg_prio, waitok, abs_timeout); -out: - fdrop(fp, td); - return (error); + + return (kern_kmq_timedsend(td, uap->mqd, uap->msg_ptr, uap->msg_len, + uap->msg_prio, abs_timeout)); } int @@ -2801,63 +2820,44 @@ int freebsd32_kmq_timedsend(struct thread *td, struct freebsd32_kmq_timedsend_args *uap) { - struct mqueue *mq; - struct file *fp; struct timespec32 ets32; struct timespec *abs_timeout, ets; int error; - int waitok; - AUDIT_ARG_FD(uap->mqd); - error = getmq_write(td, uap->mqd, &fp, NULL, &mq); - if (error) - return (error); if (uap->abs_timeout != NULL) { error = copyin(uap->abs_timeout, &ets32, sizeof(ets32)); if (error != 0) - goto out; + return (error); CP(ets32, ets, tv_sec); CP(ets32, ets, tv_nsec); abs_timeout = &ets; } else abs_timeout = NULL; - waitok = !(fp->f_flag & O_NONBLOCK); - error = mqueue_send(mq, uap->msg_ptr, uap->msg_len, - uap->msg_prio, waitok, abs_timeout); -out: - fdrop(fp, td); - return (error); + + return (kern_kmq_timedsend(td, uap->mqd, uap->msg_ptr, uap->msg_len, + uap->msg_prio, abs_timeout)); } int freebsd32_kmq_timedreceive(struct thread *td, struct freebsd32_kmq_timedreceive_args *uap) { - struct mqueue *mq; - struct file *fp; struct timespec32 ets32; struct timespec *abs_timeout, ets; - int error, waitok; + int error; - AUDIT_ARG_FD(uap->mqd); - error = getmq_read(td, uap->mqd, &fp, NULL, &mq); - if (error) - return (error); if (uap->abs_timeout != NULL) { error = copyin(uap->abs_timeout, &ets32, sizeof(ets32)); if (error != 0) - goto out; + return (error); CP(ets32, ets, tv_sec); CP(ets32, ets, tv_nsec); abs_timeout = &ets; } else abs_timeout = NULL; - waitok = !(fp->f_flag & O_NONBLOCK); - error = mqueue_receive(mq, uap->msg_ptr, uap->msg_len, - uap->msg_prio, waitok, abs_timeout); -out: - fdrop(fp, td); - return (error); + + return (kern_kmq_timedreceive(td, uap->mqd, uap->msg_ptr, uap->msg_len, + uap->msg_prio, abs_timeout)); } int diff --git a/sys/sys/mqueue.h b/sys/sys/mqueue.h index 78f34c197c7e..50f6681ce218 100644 --- a/sys/sys/mqueue.h +++ b/sys/sys/mqueue.h @@ -38,14 +38,8 @@ struct mq_attr { }; #ifdef _KERNEL -struct sigevent; struct thread; struct file; extern void (*mq_fdclose)(struct thread *td, int fd, struct file *fp); -int kern_kmq_notify(struct thread *, int, struct sigevent *); -int kern_kmq_open(struct thread *, const char *, int, mode_t, - const struct mq_attr *); -int kern_kmq_setattr(struct thread *, int, const struct mq_attr *, - struct mq_attr *); #endif #endif diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h index 6652619287ad..8ac3f55596e6 100644 --- a/sys/sys/syscallsubr.h +++ b/sys/sys/syscallsubr.h @@ -49,6 +49,7 @@ struct kevent_copyops; struct kld_file_stat; struct ksiginfo; struct mbuf; +struct mq_attr; struct msghdr; struct msqid_ds; struct pollfd; @@ -385,6 +386,15 @@ int kern_writev(struct thread *td, int fd, struct uio *auio); int kern_socketpair(struct thread *td, int domain, int type, int protocol, int *rsv); int kern_unmount(struct thread *td, const char *path, int flags); +int kern_kmq_notify(struct thread *, int, struct sigevent *); +int kern_kmq_open(struct thread *, const char *, int, mode_t, + const struct mq_attr *); +int kern_kmq_setattr(struct thread *, int, const struct mq_attr *, + struct mq_attr *); +int kern_kmq_timedreceive(struct thread *, int, char *, + size_t, unsigned int *, const struct timespec *); +int kern_kmq_timedsend(struct thread *td, int, const char *, + size_t, unsigned int, const struct timespec *); /* flags for kern_sigaction */ #define KSA_OSIGSET 0x0001 /* uses osigact_t */