Add support for L4Re Virtio Sockets
[src/app-framework-binder.git] / src / afb-websock.c
index e062cf7..9e121c1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016, 2017 "IoT.bzh"
+ * Copyright (C) 2016-2019 "IoT.bzh"
  * Author: José Bollo <jose.bollo@iot.bzh>
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,6 +15,8 @@
  * limitations under the License.
  */
 
+#if WITH_LIBMICROHTTPD
+
 #define _GNU_SOURCE
 
 #include <stdlib.h>
@@ -31,6 +33,7 @@
 #include "afb-websock.h"
 #include "afb-ws-json1.h"
 #include "afb-fdev.h"
+#include "fdev.h"
 
 /**************** WebSocket connection upgrade ****************************/
 
@@ -150,13 +153,16 @@ static void upgrade_to_websocket(
                /* TODO */
                close_websocket(urh);
        } else {
+               fdev_set_autoclose(fdev, 0);
                ws = memo->proto->create(fdev, memo->apiset, &memo->hreq->xreq.context, close_websocket, urh);
                if (ws == NULL) {
                        /* TODO */
                        close_websocket(urh);
                }
        }
+#if MHD_VERSION <= 0x00095900
        afb_hreq_unref(memo->hreq);
+#endif
        free(memo);
 }
 
@@ -251,3 +257,4 @@ int afb_websock_check_upgrade(struct afb_hreq *hreq, struct afb_apiset *apiset)
        return rc;
 }
 
+#endif