summaryrefslogtreecommitdiff
path: root/src/libs6/s6_fdholder_retrieve.c
blob: 9bdb8adb466bddaac2bebf3125e6cefa94a1fac9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* ISC license. */

#include <errno.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/tai.h>
#include <skalibs/unixmessage.h>
#include <s6/s6-fdholder.h>

int s6_fdholder_retrieve_maybe_delete (s6_fdholder_t *a, char const *id, int dodelete, tain_t const *deadline, tain_t *stamp)
{
  unixmessage_t m ;
  s6_fdholder_retrieve_result_t res ;
  if (!s6_fdholder_retrieve_maybe_delete_async(a, id, dodelete)) return -1 ;
  if (!unixmessage_sender_timed_flush(&a->connection.out, deadline, stamp)) return -1 ;
  if (sanitize_read(unixmessage_timed_receive(&a->connection.in, &m, deadline, stamp)) < 0) return -1 ;
  if (!s6_fdholder_retrieve_cb(&m, &res)) return -1 ;
  if (res.err) return (errno = res.err, -1) ;
  return res.fd ;
}