X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fwebsock.c;h=f79feb5ec36d733de4a03bedececa275b0fe9a2c;hb=e285cfb2219eb5a1034208efaf6d1a2d875c721f;hp=1b886c1bdfa1fc49c572205103379158e241a567;hpb=8112056eecede587bf884f56629858c8b21bdbec;p=src%2Fapp-framework-binder.git diff --git a/src/websock.c b/src/websock.c index 1b886c1b..f79feb5e 100644 --- a/src/websock.c +++ b/src/websock.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 "IoT.bzh" + * Copyright (C) 2016, 2017 "IoT.bzh" * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -303,7 +303,7 @@ static int check_control_header(struct websock *ws) return 1; } -int websock_dispatch(struct websock *ws) +int websock_dispatch(struct websock *ws, int loop) { uint16_t code; loop: @@ -418,16 +418,22 @@ loop: ws->itf->on_continue(ws->closure, FRAME_GET_FIN(ws->header[0]), (size_t) ws->length); + if (!loop) + return 0; break; case OPCODE_TEXT: ws->itf->on_text(ws->closure, FRAME_GET_FIN(ws->header[0]), (size_t) ws->length); + if (!loop) + return 0; break; case OPCODE_BINARY: ws->itf->on_binary(ws->closure, FRAME_GET_FIN(ws->header[0]), (size_t) ws->length); + if (!loop) + return 0; break; case OPCODE_CLOSE: if (ws->length == 0) @@ -447,6 +453,8 @@ loop: websock_pong(ws, NULL, 0); } ws->state = STATE_INIT; + if (!loop) + return 0; break; case OPCODE_PONG: if (ws->itf->on_pong) @@ -454,6 +462,8 @@ loop: else websock_drop(ws); ws->state = STATE_INIT; + if (!loop) + return 0; break; default: goto protocol_error; @@ -537,7 +547,7 @@ int websock_drop(struct websock *ws) char buffer[8000]; while (ws->length) - if (ws_read(ws, buffer, sizeof buffer) < 0) + if (websock_read(ws, buffer, sizeof buffer) < 0) return -1; return 0; }