summaryrefslogtreecommitdiff
path: root/src/libnsss/nsss_switch_send.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libnsss/nsss_switch_send.c')
-rw-r--r--src/libnsss/nsss_switch_send.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/libnsss/nsss_switch_send.c b/src/libnsss/nsss_switch_send.c
new file mode 100644
index 0000000..ecef1f4
--- /dev/null
+++ b/src/libnsss/nsss_switch_send.c
@@ -0,0 +1,25 @@
+/* ISC license. */
+
+#include <errno.h>
+
+#include <skalibs/buffer.h>
+#include <skalibs/unix-timed.h>
+
+#include <nsss/nsss-switch.h>
+#include "nsss-switch-internal.h"
+
+int nsss_switch_send (nsss_switch_t *a, char const *s, size_t len, tain const *deadline, tain *stamp)
+{
+ if (!ipc_timed_send(buffer_fd(&a->b), s, len, deadline, stamp))
+ {
+ unsigned int what ;
+ char const *path ;
+ if (errno != ECONNRESET || !a->path) return 0 ;
+ what = a->held ;
+ path = a->path ;
+ nsss_switch_end(a, what) ;
+ if (!nsss_switch_start(a, what, path, deadline, stamp)) return 0 ;
+ if (!ipc_timed_send(buffer_fd(&a->b), s, len, deadline, stamp)) return 0 ;
+ }
+ return 1 ;
+}