diff options
-rw-r--r-- | doc/index.html | 2 | ||||
-rw-r--r-- | doc/license.html | 2 | ||||
-rw-r--r-- | doc/upgrade.html | 6 | ||||
-rw-r--r-- | package/deps.mak | 3 | ||||
-rw-r--r-- | package/info | 2 | ||||
-rw-r--r-- | src/include/skalibs/unixconnection.h | 1 | ||||
-rw-r--r-- | src/libdatastruct/genset_iter_nocancel.c (renamed from src/libdatastruct/genset_iter.c) | 0 | ||||
-rw-r--r-- | src/libunixonacid/unixconnection_init.c | 3 | ||||
-rw-r--r-- | src/libunixonacid/unixconnection_init_withclosecb.c | 10 | ||||
-rw-r--r-- | src/libunixonacid/unixmessage_put.c | 7 | ||||
-rw-r--r-- | src/libunixonacid/unixmessage_sender_flush.c | 2 | ||||
-rw-r--r-- | src/libunixonacid/unixmessage_sender_free.c | 4 | ||||
-rw-r--r-- | src/libunixonacid/unixmessage_unput.c | 13 |
13 files changed, 36 insertions, 19 deletions
diff --git a/doc/index.html b/doc/index.html index f88ad30..967e066 100644 --- 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.3.10.0.tar.gz">2.3.10.0</a>. </li> + <li> The current released version of skalibs is <a href="skalibs-2.3.11.0.tar.gz">2.3.11.0</a>. </li> <li> Alternatively, you can checkout a copy of the <a href="http://git.skarnet.org/cgi-bin/cgit.cgi/skalibs/">skalibs "git repository</a>: diff --git a/doc/license.html b/doc/license.html index 149b0c3..68d8add 100644 --- 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.3.10.0, I'm not going to enforce those restrictions, but if you're +As of 2.3.11.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 index e51e247..143983b 100644 --- a/doc/upgrade.html +++ b/doc/upgrade.html @@ -18,6 +18,12 @@ <h1> What has changed in skalibs </h1> +<h2> in 2.3.11.0 </h2> + +<ul> + <li> More support for advanced fd callbacks in <tt>unixmessage_sender</tt> and <tt>unixconnection</tt>. </li> +</ul> + <h2> in 2.3.10.0 </h2> <ul> diff --git a/package/deps.mak b/package/deps.mak index 46225b1..0a85989 100644 --- a/package/deps.mak +++ b/package/deps.mak @@ -123,7 +123,7 @@ src/libdatastruct/avltreen_init.o src/libdatastruct/avltreen_init.lo: src/libdat src/libdatastruct/avltreen_insert.o src/libdatastruct/avltreen_insert.lo: src/libdatastruct/avltreen_insert.c src/include/skalibs/avltreen.h src/libdatastruct/avltreen_newnode.o src/libdatastruct/avltreen_newnode.lo: src/libdatastruct/avltreen_newnode.c src/include/skalibs/avlnode.h src/include/skalibs/avltreen.h src/include/skalibs/genset.h src/libdatastruct/genset.o src/libdatastruct/genset.lo: src/libdatastruct/genset.c src/include/skalibs/genset.h -src/libdatastruct/genset_iter.o src/libdatastruct/genset_iter.lo: src/libdatastruct/genset_iter.c src/include/skalibs/bitarray.h src/include/skalibs/functypes.h src/include/skalibs/genset.h +src/libdatastruct/genset_iter_nocancel.o src/libdatastruct/genset_iter_nocancel.lo: src/libdatastruct/genset_iter_nocancel.c src/include/skalibs/bitarray.h src/include/skalibs/functypes.h src/include/skalibs/genset.h src/libdatastruct/genset_iter_withcancel.o src/libdatastruct/genset_iter_withcancel.lo: src/libdatastruct/genset_iter_withcancel.c src/include/skalibs/functypes.h src/include/skalibs/genset.h src/libdatastruct/gensetdyn_delete.o src/libdatastruct/gensetdyn_delete.lo: src/libdatastruct/gensetdyn_delete.c src/include/skalibs/genalloc.h src/include/skalibs/gensetdyn.h src/libdatastruct/gensetdyn_free.o src/libdatastruct/gensetdyn_free.lo: src/libdatastruct/gensetdyn_free.c src/include/skalibs/genalloc.h src/include/skalibs/gensetdyn.h src/include/skalibs/stralloc.h @@ -781,6 +781,7 @@ src/libunixonacid/timed_getln.o src/libunixonacid/timed_getln.lo: src/libunixona src/libunixonacid/timed_getlnmax.o src/libunixonacid/timed_getlnmax.lo: src/libunixonacid/timed_getlnmax.c src/include/skalibs/allreadwrite.h src/include/skalibs/buffer.h src/include/skalibs/functypes.h src/include/skalibs/skamisc.h src/include/skalibs/tai.h src/include/skalibs/unix-timed.h src/libunixonacid/unixconnection_free.o src/libunixonacid/unixconnection_free.lo: src/libunixonacid/unixconnection_free.c src/include/skalibs/unixconnection.h src/include/skalibs/unixmessage.h src/libunixonacid/unixconnection_init.o src/libunixonacid/unixconnection_init.lo: src/libunixonacid/unixconnection_init.c src/include/skalibs/unixconnection.h src/include/skalibs/unixmessage.h +src/libunixonacid/unixconnection_init_withclosecb.o src/libunixonacid/unixconnection_init_withclosecb.lo: src/libunixonacid/unixconnection_init_withclosecb.c src/include/skalibs/unixconnection.h src/include/skalibs/unixmessage.h src/libunixonacid/unixconnection_zero.o src/libunixonacid/unixconnection_zero.lo: src/libunixonacid/unixconnection_zero.c src/include/skalibs/unixconnection.h src/libunixonacid/unixmessage_bits_closeall.o src/libunixonacid/unixmessage_bits_closeall.lo: src/libunixonacid/unixmessage_bits_closeall.c src/include/skalibs/bitarray.h src/include/skalibs/unixmessage.h src/libunixonacid/unixmessage_bits_closenone.o src/libunixonacid/unixmessage_bits_closenone.lo: src/libunixonacid/unixmessage_bits_closenone.c src/include/skalibs/bitarray.h src/include/skalibs/unixmessage.h diff --git a/package/info b/package/info index 3165fcf..6a886b9 100644 --- a/package/info +++ b/package/info @@ -1,4 +1,4 @@ package=skalibs -version=2.3.10.0 +version=2.3.11.0 category=prog package_macro_name=SKALIBS diff --git a/src/include/skalibs/unixconnection.h b/src/include/skalibs/unixconnection.h index c54a311..093d7c0 100644 --- a/src/include/skalibs/unixconnection.h +++ b/src/include/skalibs/unixconnection.h @@ -17,6 +17,7 @@ struct unixconnection_s extern unixconnection_t const unixconnection_zero ; extern void unixconnection_init (unixconnection_t *, int, int) ; +extern void unixconnection_init_withclosecb (unixconnection_t *, int, int, unixmessage_sender_closecb_func_t_ref, void *) ; extern void unixconnection_free (unixconnection_t *) ; #define unixconnection_flush(io) unixmessage_sender_flush(&(io)->out) diff --git a/src/libdatastruct/genset_iter.c b/src/libdatastruct/genset_iter_nocancel.c index f78945d..f78945d 100644 --- a/src/libdatastruct/genset_iter.c +++ b/src/libdatastruct/genset_iter_nocancel.c diff --git a/src/libunixonacid/unixconnection_init.c b/src/libunixonacid/unixconnection_init.c index 7831d6a..52ecd44 100644 --- a/src/libunixonacid/unixconnection_init.c +++ b/src/libunixonacid/unixconnection_init.c @@ -5,6 +5,5 @@ void unixconnection_init (unixconnection_t *io, int fdin, int fdout) { - unixmessage_receiver_init(&io->in, fdin, io->mainbuf, UNIXMESSAGE_BUFSIZE, io->auxbuf, UNIXMESSAGE_AUXBUFSIZE) ; - unixmessage_sender_init(&io->out, fdout) ; + unixconnection_init_withclosecb(io, fdin, fdout, &unixmessage_sender_closecb, 0) ; } diff --git a/src/libunixonacid/unixconnection_init_withclosecb.c b/src/libunixonacid/unixconnection_init_withclosecb.c new file mode 100644 index 0000000..b89b3ee --- /dev/null +++ b/src/libunixonacid/unixconnection_init_withclosecb.c @@ -0,0 +1,10 @@ + /* ISC license. */ + +#include <skalibs/unixmessage.h> +#include <skalibs/unixconnection.h> + +void unixconnection_init_withclosecb (unixconnection_t *io, int fdin, int fdout, unixmessage_sender_closecb_func_t_ref f, void *p) +{ + unixmessage_receiver_init(&io->in, fdin, io->mainbuf, UNIXMESSAGE_BUFSIZE, io->auxbuf, UNIXMESSAGE_AUXBUFSIZE) ; + unixmessage_sender_init_withclosecb(&io->out, fdout, f, p) ; +} diff --git a/src/libunixonacid/unixmessage_put.c b/src/libunixonacid/unixmessage_put.c index 015264a..43091c9 100644 --- a/src/libunixonacid/unixmessage_put.c +++ b/src/libunixonacid/unixmessage_put.c @@ -14,7 +14,7 @@ #include <skalibs/siovec.h> #include <skalibs/unixmessage.h> -static inline int copyfds (char *s, int const *fds, unsigned int n, unsigned char const *bits) +static inline int copyfds (char *s, int const *fds, unsigned int n, unsigned char const *bits, unixmessage_sender_closecb_func_t_ref closecb, void *closecbdata) { register unsigned int i = 0 ; for (; i < n ; i++) @@ -33,13 +33,12 @@ static inline int copyfds (char *s, int const *fds, unsigned int n, unsigned cha { s -= sizeof(int) ; byte_copy((char *)fd, sizeof(int), s) ; - if (fd >= 0) fd_close(fd) ; + if (fd >= 0) (*closecb)(fd, closecbdata) ; } errno = e ; return 0 ; } } -#else #endif byte_copy(s, sizeof(int), (char const *)&fd) ; s += sizeof(int) ; @@ -56,7 +55,7 @@ static int reserve_and_copy (unixmessage_sender_t *b, unsigned int len, int cons || !genalloc_readyplus(int, &b->fds, nfds) || !stralloc_readyplus(&b->data, len)) return 0 ; - if (!copyfds(b->fds.s + b->fds.len, fds, nfds, bits)) return 0 ; + if (!copyfds(b->fds.s + b->fds.len, fds, nfds, bits, b->closecb, b->closecbdata)) return 0 ; genalloc_setlen(int, &b->fds, cur.right + nfds) ; byte_copy(b->offsets.s + b->offsets.len, sizeof(diuint), (char const *)&cur) ; b->offsets.len += sizeof(diuint) ; diff --git a/src/libunixonacid/unixmessage_sender_flush.c b/src/libunixonacid/unixmessage_sender_flush.c index 6559083..57c5d6e 100644 --- a/src/libunixonacid/unixmessage_sender_flush.c +++ b/src/libunixonacid/unixmessage_sender_flush.c @@ -97,7 +97,7 @@ int unixmessage_sender_flush (unixmessage_sender_t *b) while (r < 0 && errno == EINTR) ; if (r <= 0) return 0 ; #ifndef SKALIBS_HASANCILAUTOCLOSE - if (nfds && b->closecb) + if (nfds) { register unsigned int i = 0 ; for (; i < nfds ; i++) diff --git a/src/libunixonacid/unixmessage_sender_free.c b/src/libunixonacid/unixmessage_sender_free.c index 6ef0f42..a976827 100644 --- a/src/libunixonacid/unixmessage_sender_free.c +++ b/src/libunixonacid/unixmessage_sender_free.c @@ -16,9 +16,9 @@ void unixmessage_sender_free (unixmessage_sender_t *b) for (; i < n ; i++) { register int fd = genalloc_s(int, &b->fds)[i] ; - if (fd < 0) fd_close(-(fd+1)) ; + if (fd < 0) (*b->closecb)(-(fd+1), b->closecbdata) ; #ifdef SKALIBS_HASANCILAUTOCLOSE - else fd_close(fd) ; + else (*b->closecb)(fd, b->closecbdata) ; #endif } } diff --git a/src/libunixonacid/unixmessage_unput.c b/src/libunixonacid/unixmessage_unput.c index 63e94b8..e869110 100644 --- a/src/libunixonacid/unixmessage_unput.c +++ b/src/libunixonacid/unixmessage_unput.c @@ -9,14 +9,15 @@ int unixmessage_unput_and_maybe_drop (unixmessage_sender_t *b, int drop) { diuint *start ; unsigned int n = genalloc_len(diuint, &b->offsets) ; + register int *fds ; + register unsigned int i ; if (!n) return 0 ; start = genalloc_s(diuint, &b->offsets) + n - 1 ; - if (drop) - { - register int *fds = genalloc_s(int, &b->fds) + start->right ; - register unsigned int i = genalloc_len(int, &b->fds) - start->right ; - while (i--) fd_close(fds[i] < 0 ? -(fds[i]+1) : fds[i]) ; - } + fds = genalloc_s(int, &b->fds) + start->right ; + i = genalloc_len(int, &b->fds) - start->right ; + while (i--) + if (fds[i] < 0) (*b->closecb)(-(fds[i]+1), b->closecbdata) ; + else if (drop) fd_close(fds[i]) ; b->data.len = start->left ; genalloc_setlen(int, &b->fds, start->right) ; genalloc_setlen(diuint, &b->offsets, n-1) ; |