commit e235eac7e00a3f52299273f734723dbc9fbaee70
parent 191d21f2acde7c2fa3003972a8b04bc080d64e2d
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date: Sun, 24 Jun 2018 15:05:12 +0000
Add skagetln_loose, skagetlnsep_loose, ipc_timed_sendv
Diffstat:
12 files changed, 99 insertions(+), 4 deletions(-)
diff --git a/NEWS b/NEWS
@@ -1,5 +1,12 @@
Changelog for skalibs.
+In 2.6.5.0
+----------
+
+ - Bugfixes.
+ - New function: ipc_timed_sendv()
+
+
In 2.6.4.0
----------
diff --git a/doc/index.html b/doc/index.html
@@ -60,7 +60,7 @@ with a standard C development environment </li>
<h3> Download </h3>
<ul>
- <li> The current released version of skalibs is <a href="skalibs-2.6.4.0.tar.gz">2.6.4.0</a>. </li>
+ <li> The current released version of skalibs is <a href="skalibs-2.6.5.0.tar.gz">2.6.5.0</a>. </li>
<li> Alternatively, you can checkout a copy of the
<a href="//git.skarnet.org/cgi-bin/cgit.cgi/skalibs/">skalibs
git repository</a>:
diff --git a/doc/license.html b/doc/license.html
@@ -74,7 +74,7 @@ color, or different text font. </li>
<p>
<em>I am aware that the previous restrictions sound completely
ridiculous while the official skalibs documentation is incomplete.
-As of 2.6.4.0, I'm not going to enforce those restrictions, but if you're
+As of 2.6.5.0, I'm not going to enforce those restrictions, but if you're
going to provide documentation for skalibs, don't keep it to yourself,
please send it to me instead. :-) </em>
</p>
diff --git a/doc/upgrade.html b/doc/upgrade.html
@@ -16,6 +16,12 @@
<a href="//skarnet.org/">skarnet.org</a>
</p>
+<h2> in 2.6.5.0 </h2>
+
+<ul>
+ <li> New function: <tt>ipc_timed_sendv()</tt> </li>
+</ul>
+
<h2> in 2.6.4.0 </h2>
<ul>
diff --git a/package/deps.mak b/package/deps.mak
@@ -509,9 +509,11 @@ src/libstddjb/siovec_search.o src/libstddjb/siovec_search.lo: src/libstddjb/siov
src/libstddjb/siovec_seek.o src/libstddjb/siovec_seek.lo: src/libstddjb/siovec_seek.c src/include/skalibs/bytestr.h src/include/skalibs/siovec.h
src/libstddjb/siovec_trunc.o src/libstddjb/siovec_trunc.lo: src/libstddjb/siovec_trunc.c src/include/skalibs/siovec.h
src/libstddjb/skagetln.o src/libstddjb/skagetln.lo: src/libstddjb/skagetln.c src/include/skalibs/buffer.h src/include/skalibs/skamisc.h src/include/skalibs/stralloc.h
+src/libstddjb/skagetln_loose.o src/libstddjb/skagetln_loose.lo: src/libstddjb/skagetln_loose.c src/include/skalibs/skamisc.h src/include/skalibs/stralloc.h
src/libstddjb/skagetln_nofill.o src/libstddjb/skagetln_nofill.lo: src/libstddjb/skagetln_nofill.c src/include/skalibs/buffer.h src/include/skalibs/siovec.h src/include/skalibs/skamisc.h src/include/skalibs/stralloc.h
src/libstddjb/skagetlnmaxsep.o src/libstddjb/skagetlnmaxsep.lo: src/libstddjb/skagetlnmaxsep.c src/include/skalibs/buffer.h src/include/skalibs/siovec.h src/include/skalibs/skamisc.h src/include/skalibs/stralloc.h
src/libstddjb/skagetlnsep.o src/libstddjb/skagetlnsep.lo: src/libstddjb/skagetlnsep.c src/include/skalibs/buffer.h src/include/skalibs/siovec.h src/include/skalibs/skamisc.h src/include/skalibs/stralloc.h
+src/libstddjb/skagetlnsep_loose.o src/libstddjb/skagetlnsep_loose.lo: src/libstddjb/skagetlnsep_loose.c src/include/skalibs/skamisc.h src/include/skalibs/stralloc.h
src/libstddjb/skalibs_tzisright.o src/libstddjb/skalibs_tzisright.lo: src/libstddjb/skalibs_tzisright.c src/libstddjb/djbtime-internal.h
src/libstddjb/skasig_dfl.o src/libstddjb/skasig_dfl.lo: src/libstddjb/skasig_dfl.c src/include/skalibs/sig.h
src/libstddjb/skasigaction.o src/libstddjb/skasigaction.lo: src/libstddjb/skasigaction.c src/include/skalibs/config.h src/include/skalibs/sig.h
@@ -730,7 +732,8 @@ src/libunixonacid/dd_commit_devino.o src/libunixonacid/dd_commit_devino.lo: src/
src/libunixonacid/dd_open_read.o src/libunixonacid/dd_open_read.lo: src/libunixonacid/dd_open_read.c src/include/skalibs/djbunix.h src/include/skalibs/unix-transactional.h
src/libunixonacid/dd_open_write.o src/libunixonacid/dd_open_write.lo: src/libunixonacid/dd_open_write.c src/include/skalibs/djbunix.h src/include/skalibs/random.h src/include/skalibs/stralloc.h src/include/skalibs/unix-transactional.h
src/libunixonacid/ipc_timed_recv.o src/libunixonacid/ipc_timed_recv.lo: src/libunixonacid/ipc_timed_recv.c src/include/skalibs/allreadwrite.h src/include/skalibs/functypes.h src/include/skalibs/unix-timed.h src/include/skalibs/webipc.h
-src/libunixonacid/ipc_timed_send.o src/libunixonacid/ipc_timed_send.lo: src/libunixonacid/ipc_timed_send.c src/include/skalibs/error.h src/include/skalibs/iopause.h src/include/skalibs/unix-timed.h
+src/libunixonacid/ipc_timed_send.o src/libunixonacid/ipc_timed_send.lo: src/libunixonacid/ipc_timed_send.c src/include/skalibs/error.h src/include/skalibs/iopause.h src/include/skalibs/nonposix.h src/include/skalibs/unix-timed.h
+src/libunixonacid/ipc_timed_sendv.o src/libunixonacid/ipc_timed_sendv.lo: src/libunixonacid/ipc_timed_sendv.c src/include/skalibs/error.h src/include/skalibs/iopause.h src/include/skalibs/nonposix.h src/include/skalibs/siovec.h src/include/skalibs/unix-timed.h
src/libunixonacid/kolbak_call.o src/libunixonacid/kolbak_call.lo: src/libunixonacid/kolbak_call.c src/include/skalibs/kolbak.h src/include/skalibs/unixmessage.h
src/libunixonacid/kolbak_enqueue.o src/libunixonacid/kolbak_enqueue.lo: src/libunixonacid/kolbak_enqueue.c src/include/skalibs/kolbak.h src/include/skalibs/unixmessage.h
src/libunixonacid/kolbak_queue_init.o src/libunixonacid/kolbak_queue_init.lo: src/libunixonacid/kolbak_queue_init.c src/include/skalibs/kolbak.h
diff --git a/package/info b/package/info
@@ -1,4 +1,4 @@
package=skalibs
-version=2.6.4.0
+version=2.6.5.0
category=prog
package_macro_name=SKALIBS
diff --git a/src/include/skalibs/skamisc.h b/src/include/skalibs/skamisc.h
@@ -10,8 +10,10 @@
extern stralloc satmp ;
extern int skagetln (buffer *, stralloc *, char) ;
+extern int skagetln_loose (buffer *, stralloc *, char) ;
extern int skagetln_nofill (buffer *, stralloc *, char) ;
extern int skagetlnsep (buffer *, stralloc *, char const *, size_t) ;
+extern int skagetlnsep_loose (buffer *, stralloc *, char const *, size_t) ;
extern int skagetlnmaxsep (buffer *, stralloc *, size_t, char const *, size_t) ;
extern int getlnmax (buffer *, char *, size_t, size_t *, char) ;
extern int getlnmaxsep (buffer *, char *, size_t, size_t *, char const *, size_t) ;
diff --git a/src/include/skalibs/unix-timed.h b/src/include/skalibs/unix-timed.h
@@ -4,6 +4,7 @@
#define UNIX_TIMED_H
#include <sys/types.h>
+#include <sys/uio.h>
#include <skalibs/bufalloc.h>
#include <skalibs/buffer.h>
#include <skalibs/functypes.h>
@@ -36,6 +37,8 @@ extern int netstring_timed_get (buffer *, stralloc *, tain_t const *, tain_t *)
extern int ipc_timed_send (int, char const *, size_t, tain_t const *, tain_t *) ;
#define ipc_timed_send_g(fd, s, len, deadline) ipc_timed_send(fd, s, len, (deadline), &STAMP)
+extern int ipc_timed_sendv (int, struct iovec const *, unsigned int, tain_t const *, tain_t *) ;
+#define ipc_timed_sendv_g(fd, v, n, deadline) ipc_timed_sendv(fd, v, n, (deadline), &STAMP)
extern ssize_t ipc_timed_recv (int, char *, size_t, char *, tain_t const *, tain_t *) ;
#define ipc_timed_recv_g(fd, s, len, path, deadline) ipc_timed_recv(fd, s, len, path, (deadline), &STAMP)
diff --git a/src/libstddjb/skagetln_loose.c b/src/libstddjb/skagetln_loose.c
@@ -0,0 +1,15 @@
+/* ISC license. */
+
+#include <errno.h>
+#include <skalibs/stralloc.h>
+#include <skalibs/skamisc.h>
+
+int skagetln_loose (buffer *b, stralloc *sa, char sep)
+{
+ int e = errno ;
+ int r = skagetln(b, sa, sep) ;
+ if (r >= 0) return r ;
+ if (errno != EPIPE) return -1 ;
+ if (!stralloc_0(sa)) return -1 ;
+ return (errno = e, 3) ;
+}
diff --git a/src/libstddjb/skagetlnsep_loose.c b/src/libstddjb/skagetlnsep_loose.c
@@ -0,0 +1,15 @@
+/* ISC license. */
+
+#include <errno.h>
+#include <skalibs/stralloc.h>
+#include <skalibs/skamisc.h>
+
+int skagetlnsep_loose (buffer *b, stralloc *sa, char const *sep, size_t seplen)
+{
+ int e = errno ;
+ int r = skagetlnsep(b, sa, sep, seplen) ;
+ if (r >= 0) return r ;
+ if (errno != EPIPE) return -1 ;
+ if (!stralloc_0(sa)) return -1 ;
+ return (errno = e, 3) ;
+}
diff --git a/src/libunixonacid/ipc_timed_send.c b/src/libunixonacid/ipc_timed_send.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <skalibs/nonposix.h>
#include <sys/socket.h>
#include <errno.h>
#include <skalibs/error.h>
diff --git a/src/libunixonacid/ipc_timed_sendv.c b/src/libunixonacid/ipc_timed_sendv.c
@@ -0,0 +1,43 @@
+/* ISC license. */
+
+#include <skalibs/nonposix.h>
+#include <sys/socket.h>
+#include <errno.h>
+#include <skalibs/error.h>
+#include <skalibs/iopause.h>
+#include <skalibs/siovec.h>
+#include <skalibs/unix-timed.h>
+
+ /* For MacOS, that still doesn't know what POSIX says */
+#ifndef MSG_NOSIGNAL
+#define MSG_NOSIGNAL 0
+#endif
+
+int ipc_timed_sendv (int fd, struct iovec const *v, unsigned int n, tain_t const *deadline, tain_t *stamp)
+{
+ struct msghdr hdr =
+ {
+ .msg_name = 0,
+ .msg_namelen = 0,
+ .msg_iov = (struct iovec *)v,
+ .msg_iovlen = n,
+ .msg_control = 0,
+ .msg_controllen = 0,
+ .msg_flags = 0
+ } ;
+ size_t len = siovec_len(v, n) ;
+ iopause_fd x = { .fd = fd, .events = IOPAUSE_WRITE, .revents = 0 } ;
+ for (;;)
+ {
+ int r = iopause_stamp(&x, 1, deadline, stamp) ;
+ if (r < 0) return 0 ;
+ else if (!r) return (errno = ETIMEDOUT, 0) ;
+ else if (x.revents & IOPAUSE_WRITE)
+ {
+ if (sendmsg(fd, &hdr, MSG_NOSIGNAL) == (ssize_t)len) break ;
+ if (!error_isagain(errno)) return 0 ;
+ }
+ else if (x.revents & IOPAUSE_EXCEPT) return (sendmsg(fd, &hdr, MSG_NOSIGNAL) == (ssize_t)len) ;
+ }
+ return 1 ;
+}