about summary refs log tree commit diff
path: root/src/libnsss/nsss_switch_end.c
blob: 6895dd63dcf4e1f22cc54e6e0e2a68e5a20ea18c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/* ISC license. */

#include <skalibs/buffer.h>
#include <skalibs/djbunix.h>
#include <nsss/nsss-switch.h>

static inline void nsss_switch_disconnect (nsss_switch_t *a)
{
  fd_close(buffer_fd(&a->b)) ;
  a->b.fd = -1 ;
  a->path = 0 ;
}

void nsss_switch_end (nsss_switch_t *a, unsigned int what)
{
  a->held &= ~(what & 0x7u) ;
  if (!a->held) nsss_switch_disconnect(a) ;
}