Code Review
/
src
/
app-framework-binder.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
afb-export: Provide the real path of the binding
[src/app-framework-binder.git]
/
src
/
afb-websock.c
diff --git
a/src/afb-websock.c
b/src/afb-websock.c
index
799b2bd
..
5123437
100644
(file)
--- a/
src/afb-websock.c
+++ b/
src/afb-websock.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (C) 2016, 2017 "IoT.bzh"
+ * Copyright (C) 2016, 2017
, 2018
"IoT.bzh"
* Author: José Bollo <jose.bollo@iot.bzh>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Author: José Bollo <jose.bollo@iot.bzh>
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@
-30,6
+30,8
@@
#include "afb-hreq.h"
#include "afb-websock.h"
#include "afb-ws-json1.h"
#include "afb-hreq.h"
#include "afb-websock.h"
#include "afb-ws-json1.h"
+#include "afb-fdev.h"
+#include "fdev.h"
/**************** WebSocket connection upgrade ****************************/
/**************** WebSocket connection upgrade ****************************/
@@
-94,7
+96,7
@@
static int headerhas(const char *header, const char *needle)
struct protodef
{
const char *name;
struct protodef
{
const char *name;
- void *(*create)(
int fd
, struct afb_apiset *apiset, struct afb_context *context, void (*cleanup)(void*), void *cleanup_closure);
+ void *(*create)(
struct fdev *fdev
, struct afb_apiset *apiset, struct afb_context *context, void (*cleanup)(void*), void *cleanup_closure);
};
static const struct protodef *search_proto(const struct protodef *protodefs, const char *protocols)
};
static const struct protodef *search_proto(const struct protodef *protodefs, const char *protocols)
@@
-142,13
+144,23
@@
static void upgrade_to_websocket(
{
struct memo_websocket *memo = cls;
void *ws;
{
struct memo_websocket *memo = cls;
void *ws;
+ struct fdev *fdev;
-
ws = memo->proto->create(sock, memo->apiset, &memo->hreq->xreq.context, close_websocket, urh
);
- if (
ws == NULL
) {
+
fdev = afb_fdev_create(sock
);
+ if (
!fdev
) {
/* TODO */
close_websocket(urh);
/* 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);
afb_hreq_unref(memo->hreq);
+#endif
free(memo);
}
free(memo);
}