X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-websock.c;h=e062cf773e734168a65cfe6a634047d3d8cdef45;hb=ca820c65c2b03a24e8936218171c6c1d138fd1f7;hp=799b2bd0ba53945a52436b66d4d5ea482bf72db1;hpb=f15ea770dd9b13a20331853a026091316984f9ca;p=src%2Fapp-framework-binder.git diff --git a/src/afb-websock.c b/src/afb-websock.c index 799b2bd0..e062cf77 100644 --- a/src/afb-websock.c +++ b/src/afb-websock.c @@ -30,6 +30,7 @@ #include "afb-hreq.h" #include "afb-websock.h" #include "afb-ws-json1.h" +#include "afb-fdev.h" /**************** WebSocket connection upgrade ****************************/ @@ -94,7 +95,7 @@ static int headerhas(const char *header, const char *needle) 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) @@ -142,11 +143,18 @@ static void upgrade_to_websocket( { 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); + } else { + ws = memo->proto->create(fdev, memo->apiset, &memo->hreq->xreq.context, close_websocket, urh); + if (ws == NULL) { + /* TODO */ + close_websocket(urh); + } } afb_hreq_unref(memo->hreq); free(memo);