#include <json-c/json.h>
-#include <afb/afb-req-itf.h>
+#include <afb/afb-event-itf.h>
#include "afb-wsj1.h"
#include "afb-ws-json1.h"
#include "afb-xreq.h"
#include "afb-context.h"
#include "afb-evt.h"
-#include "afb-subcall.h"
#include "verbose.h"
/* predeclaration of structures */
goto error4;
result->cred = afb_cred_create_for_socket(fd);
- if (!result->cred)
- result->cred = afb_cred_current();
result->apiset = afb_apiset_addref(apiset);
return result;
static struct afb_ws_json1 *aws_addref(struct afb_ws_json1 *ws)
{
- ws->refcount++;
+ __atomic_add_fetch(&ws->refcount, 1, __ATOMIC_RELAXED);
return ws;
}
static void aws_unref(struct afb_ws_json1 *ws)
{
- if (--ws->refcount == 0) {
+ if (!__atomic_sub_fetch(&ws->refcount, 1, __ATOMIC_RELAXED)) {
afb_evt_listener_unref(ws->listener);
afb_wsj1_unref(ws->wsj1);
if (ws->cleanup != NULL)