fix mimetype by using libmagic
[src/app-framework-binder.git] / src / afb-api-ws.c
index e81306a..4d1f08c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015, 2016 "IoT.bzh"
+ * Copyright (C) 2015, 2016, 2017 "IoT.bzh"
  * Author José Bollo <jose.bollo@iot.bzh>
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -37,7 +37,7 @@
 
 #include "afb-common.h"
 
-#include "session.h"
+#include "afb-session.h"
 #include "afb-ws.h"
 #include "afb-msg-json.h"
 #include "afb-apis.h"
@@ -827,7 +827,7 @@ static void api_ws_client_call_cb(void * closure, struct afb_req req, struct afb
        if (!api_ws_write_uint32(&wb, memo->msgid)
         || !api_ws_write_uint32(&wb, (uint32_t)context->flags)
         || !api_ws_write_string_nz(&wb, verb, lenverb)
-        || !api_ws_write_string(&wb, ctxClientGetUuid(context->session))
+        || !api_ws_write_string(&wb, afb_session_uuid(context->session))
         || !api_ws_write_string_length(&wb, raw, szraw))
                goto overflow;
 
@@ -1023,6 +1023,8 @@ static void api_ws_server_accept(struct api_ws *api)
                        lenaddr = (socklen_t)sizeof addr;
                        client->fd = accept(api->fd, &addr, &lenaddr);
                        if (client->fd >= 0) {
+                               fcntl(client->fd, F_SETFD, FD_CLOEXEC);
+                               fcntl(client->fd, F_SETFL, O_NONBLOCK);
                                client->ws = afb_ws_create(afb_common_get_event_loop(), client->fd, &api_ws_server_ws_itf, client);
                                if (client->ws != NULL) {
                                        client->api = api->api;