aboutsummaryrefslogtreecommitdiffstats
path: root/src/libskabus/skabus_rpc_release.c
blob: d0a6875f38ea318dfca20650c153da4e9e8ded46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* ISC license. */

#include <stdint.h>
#include <errno.h>
#include <skalibs/uint64.h>
#include <skalibs/alloc.h>
#include <skalibs/gensetdyn.h>
#include <skalibs/avltree.h>
#include <skabus/rpc.h>

int skabus_rpc_release (skabus_rpc_t *a, uint64_t serial)
{
  uint32_t id ;
  skabus_rpc_qinfo_t *p ;
  if (!avltree_search(&a->qmap, &serial, &id)) return 0 ;
  p = GENSETDYN_P(skabus_rpc_qinfo_t, &a->q, id) ;
  if (p->status) return (errno = p->status, 0) ;
  alloc_free(p->message.s) ;
  alloc_free(p->message.fds) ;
 /* fds are purposefully left open for the client. */
  p->status = EINVAL ;
  avltree_delete(&a->qmap, &serial) ;
  gensetdyn_delete(&a->q, id) ;
  return 1 ;
}