summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-11-27 12:44:40 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-11-27 12:44:40 +0000
commitc3150e36d6e3d8392c5801a19b7f63daa5551f37 (patch)
tree6fa1e3579c275898c964dace54184116d7d256e5 /src
parentb40d48d8fe2b7ff838d8e57482cd02f83987b7fd (diff)
downloads6-c3150e36d6e3d8392c5801a19b7f63daa5551f37.tar.xz
Add s6_fdholder_start/end, prepare for 2.6.2.0
Diffstat (limited to 'src')
-rw-r--r--src/include/s6/s6-fdholder.h9
-rw-r--r--src/libs6/deps-lib/s62
-rw-r--r--src/libs6/s6_fdholder_end.c11
-rw-r--r--src/libs6/s6_fdholder_start.c19
4 files changed, 40 insertions, 1 deletions
diff --git a/src/include/s6/s6-fdholder.h b/src/include/s6/s6-fdholder.h
index 10332b1..840c167 100644
--- a/src/include/s6/s6-fdholder.h
+++ b/src/include/s6/s6-fdholder.h
@@ -1,4 +1,4 @@
- /* ISC license. */
+/* ISC license. */
#ifndef S6_FDHOLDER_H
#define S6_FDHOLDER_H
@@ -19,9 +19,16 @@ struct s6_fdholder_s
} ;
#define S6_FDHOLDER_ZERO { .connection = UNIXCONNECTION_ZERO } ;
+
+ /* Starting and ending */
+
#define s6_fdholder_init(a, fd) unixconnection_init(&(a)->connection, fd, fd)
#define s6_fdholder_free(a) unixconnection_free(&(a)->connection)
+extern int s6_fdholder_start (s6_fdholder_t *, char const *, tain_t const *, tain_t *) ;
+#define s6_fdholder_start_g(a, path, deadline) s6_fdholder_start(a, path, (deadline), &STAMP)
+extern void s6_fdholder_end (s6_fdholder_t *) ;
+
/* Individual fds */
diff --git a/src/libs6/deps-lib/s6 b/src/libs6/deps-lib/s6
index a0da2c5..47a3335 100644
--- a/src/libs6/deps-lib/s6
+++ b/src/libs6/deps-lib/s6
@@ -49,6 +49,7 @@ s6lock_wait_or.o
s6lock_zero.o
s6_fdholder_delete.o
s6_fdholder_delete_async.o
+s6_fdholder_end.o
s6_fdholder_getdump.o
s6_fdholder_list.o
s6_fdholder_list_async.o
@@ -57,6 +58,7 @@ s6_fdholder_retrieve.o
s6_fdholder_retrieve_async.o
s6_fdholder_retrieve_cb.o
s6_fdholder_setdump.o
+s6_fdholder_start.o
s6_fdholder_store.o
s6_fdholder_store_async.o
-lskarnet
diff --git a/src/libs6/s6_fdholder_end.c b/src/libs6/s6_fdholder_end.c
new file mode 100644
index 0000000..7b2cb2d
--- /dev/null
+++ b/src/libs6/s6_fdholder_end.c
@@ -0,0 +1,11 @@
+/* ISC license. */
+
+#include <skalibs/djbunix.h>
+#include <skalibs/unixmessage.h>
+#include <s6/s6-fdholder.h>
+
+void s6_fdholder_end (s6_fdholder_t *a)
+{
+ fd_close(unixmessage_sender_fd(&a->connection.out)) ;
+ s6_fdholder_free(a) ;
+}
diff --git a/src/libs6/s6_fdholder_start.c b/src/libs6/s6_fdholder_start.c
new file mode 100644
index 0000000..d887247
--- /dev/null
+++ b/src/libs6/s6_fdholder_start.c
@@ -0,0 +1,19 @@
+/* ISC license. */
+
+#include <skalibs/djbunix.h>
+#include <skalibs/webipc.h>
+#include <skalibs/unixconnection.h>
+#include <s6/s6-fdholder.h>
+
+int s6_fdholder_start (s6_fdholder_t *a, char const *path, tain_t const *deadline, tain_t *stamp)
+{
+ int fd = ipc_stream_nb() ;
+ if (fd < 0) return 0 ;
+ if (!ipc_timed_connect(fd, path, deadline, stamp))
+ {
+ fd_close(fd) ;
+ return 0 ;
+ }
+ unixconnection_init(&a->connection, fd, fd) ;
+ return 1 ;
+}