/*
- * Copyright (C) 2015-2018 "IoT.bzh"
+ * Copyright (C) 2015-2019 "IoT.bzh"
* Author José Bollo <jose.bollo@iot.bzh>
*
* Licensed under the Apache License, Version 2.0 (the "License");
uint8_t is_client;
/* the api name */
- char apiname[1];
+ char apiname[];
};
static struct afb_proto_ws *afb_stub_ws_create_proto(struct afb_stub_ws *stubws, struct fdev *fdev, uint8_t server);
return;
}
+ afb_xreq_unhooked_addref(xreq);
rc = afb_proto_ws_client_call(
proto,
xreq->request.called_verb,
afb_session_uuid(xreq->context.session),
xreq,
xreq_on_behalf_cred_export(xreq));
- if (rc >= 0)
- afb_xreq_unhooked_addref(xreq);
- else
+ if (rc < 0) {
afb_xreq_reply(xreq, NULL, "internal", "can't send message");
+ afb_xreq_unhooked_unref(xreq);
+ }
}
static void client_on_description_cb(void *closure, struct json_object *data)
static int enqueue_processing(struct afb_proto_ws *proto, void (*callback)(int signum, void* arg), void *arg)
{
- return jobs_queue(proto, 0, callback, arg);
+ return jobs_queue(NULL /* proto */, 0, callback, arg);
}
/*****************************************************/
{
struct afb_stub_ws *stubws;
- stubws = calloc(1, sizeof *stubws + strlen(apiname));
+ stubws = calloc(1, sizeof *stubws + 1 + strlen(apiname));
if (stubws == NULL)
errno = ENOMEM;
else {