aboutsummaryrefslogtreecommitdiff
path: root/lib/librt
diff options
context:
space:
mode:
authorAlan Somers <asomers@FreeBSD.org>2017-07-21 15:09:24 +0000
committerAlan Somers <asomers@FreeBSD.org>2017-07-21 15:09:24 +0000
commit18ddf67c64167ae2af2a77df3c2587547acc51ff (patch)
tree7bb1d404bae77b8a30c332fa7c032c150f4515ab /lib/librt
parent1ec31f2c6fa2c12bc7e8ee1de157abf0e74c95de (diff)
downloadsrc-18ddf67c64167ae2af2a77df3c2587547acc51ff.tar.gz
src-18ddf67c64167ae2af2a77df3c2587547acc51ff.zip
Implement SIGEV_THREAD notifications for lio_listio(2)
Our man pages have always indicated that this was supported, but in fact the feature was never implemented for lio_listio(2). Reviewed by: jhb, kib (earlier version) MFC after: 20 days Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D11680
Notes
Notes: svn path=/head/; revision=321332
Diffstat (limited to 'lib/librt')
-rw-r--r--lib/librt/Symbol.map1
-rw-r--r--lib/librt/aio.c47
2 files changed, 40 insertions, 8 deletions
diff --git a/lib/librt/Symbol.map b/lib/librt/Symbol.map
index a4a88b947070..c11b88397afd 100644
--- a/lib/librt/Symbol.map
+++ b/lib/librt/Symbol.map
@@ -26,6 +26,7 @@ FBSD_1.0 {
};
FBSD_1.5 {
+ lio_listio;
mq_getfd_np;
timer_oshandle_np;
};
diff --git a/lib/librt/aio.c b/lib/librt/aio.c
index af88cf3affdd..fd26a9f68e53 100644
--- a/lib/librt/aio.c
+++ b/lib/librt/aio.c
@@ -44,6 +44,7 @@ __weak_reference(__aio_write, aio_write);
__weak_reference(__aio_return, aio_return);
__weak_reference(__aio_waitcomplete, aio_waitcomplete);
__weak_reference(__aio_fsync, aio_fsync);
+__weak_reference(__lio_listio, lio_listio);
typedef void (*aio_func)(union sigval val, struct aiocb *iocb);
@@ -53,6 +54,8 @@ extern ssize_t __sys_aio_waitcomplete(struct aiocb **iocbp, struct timespec *tim
extern ssize_t __sys_aio_return(struct aiocb *iocb);
extern int __sys_aio_error(struct aiocb *iocb);
extern int __sys_aio_fsync(int op, struct aiocb *iocb);
+extern int __sys_lio_listio(int mode, struct aiocb * const list[], int nent,
+ struct sigevent *sig);
static void
aio_dispatch(struct sigev_node *sn)
@@ -63,8 +66,8 @@ aio_dispatch(struct sigev_node *sn)
}
static int
-aio_sigev_alloc(struct aiocb *iocb, struct sigev_node **sn,
- struct sigevent *saved_ev)
+aio_sigev_alloc(sigev_id_t id, struct sigevent *sigevent,
+ struct sigev_node **sn, struct sigevent *saved_ev)
{
if (__sigev_check_init()) {
/* This might be that thread library is not enabled. */
@@ -72,15 +75,15 @@ aio_sigev_alloc(struct aiocb *iocb, struct sigev_node **sn,
return (-1);
}
- *sn = __sigev_alloc(SI_ASYNCIO, &iocb->aio_sigevent, NULL, 1);
+ *sn = __sigev_alloc(SI_ASYNCIO, sigevent, NULL, 1);
if (*sn == NULL) {
errno = EAGAIN;
return (-1);
}
- *saved_ev = iocb->aio_sigevent;
- (*sn)->sn_id = (sigev_id_t)iocb;
- __sigev_get_sigevent(*sn, &iocb->aio_sigevent, (*sn)->sn_id);
+ *saved_ev = *sigevent;
+ (*sn)->sn_id = id;
+ __sigev_get_sigevent(*sn, sigevent, (*sn)->sn_id);
(*sn)->sn_dispatch = aio_dispatch;
__sigev_list_lock();
@@ -102,7 +105,8 @@ aio_io(struct aiocb *iocb, int (*sysfunc)(struct aiocb *iocb))
return (ret);
}
- ret = aio_sigev_alloc(iocb, &sn, &saved_ev);
+ ret = aio_sigev_alloc((sigev_id_t)iocb, &iocb->aio_sigevent, &sn,
+ &saved_ev);
if (ret)
return (ret);
ret = sysfunc(iocb);
@@ -183,7 +187,8 @@ __aio_fsync(int op, struct aiocb *iocb)
if (iocb->aio_sigevent.sigev_notify != SIGEV_THREAD)
return __sys_aio_fsync(op, iocb);
- ret = aio_sigev_alloc(iocb, &sn, &saved_ev);
+ ret = aio_sigev_alloc((sigev_id_t)iocb, &iocb->aio_sigevent, &sn,
+ &saved_ev);
if (ret)
return (ret);
ret = __sys_aio_fsync(op, iocb);
@@ -197,3 +202,29 @@ __aio_fsync(int op, struct aiocb *iocb)
}
return (ret);
}
+
+int
+__lio_listio(int mode, struct aiocb * const list[], int nent,
+ struct sigevent *sig)
+{
+ struct sigev_node *sn;
+ struct sigevent saved_ev;
+ int ret, err;
+
+ if (sig == NULL || sig->sigev_notify != SIGEV_THREAD)
+ return (__sys_lio_listio(mode, list, nent, sig));
+
+ ret = aio_sigev_alloc((sigev_id_t)list, sig, &sn, &saved_ev);
+ if (ret)
+ return (ret);
+ ret = __sys_lio_listio(mode, list, nent, sig);
+ *sig = saved_ev;
+ if (ret != 0) {
+ err = errno;
+ __sigev_list_lock();
+ __sigev_delete_node(sn);
+ __sigev_list_unlock();
+ errno = err;
+ }
+ return (ret);
+}