From 4dcc78b9952d3e1f7f80d9b8613a3e78e2409494 Mon Sep 17 00:00:00 2001 From: Bo Date: Mon, 12 Sep 2022 15:25:37 +0300 Subject: [PATCH] possibly related to issue #100 + bump --- examples/config.ru | 3 +++ ext/iodine/fio.c | 6 ++++-- lib/iodine/version.rb | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/examples/config.ru b/examples/config.ru index 0da54737..3ae15480 100644 --- a/examples/config.ru +++ b/examples/config.ru @@ -12,6 +12,9 @@ # # ab -c 2000 -t 5 -n 1000000 -k http://127.0.0.1:3000/ # wrk -c2000 -d5 -t12 http://localhost:3000/ +# +# Test websocket echo using the browser. For example: +# ws = new WebSocket("ws://localhost:3000"); ws.onmessage = function(e) {console.log("Got message!"); console.log(e.data);}; ws.onclose = function(e) {console.log("closed")}; ws.onopen = function(e) {ws.send("hi");}; # A simple router - Checks for Websocket Upgrade and answers HTTP. diff --git a/ext/iodine/fio.c b/ext/iodine/fio.c index 59784a83..afa78801 100644 --- a/ext/iodine/fio.c +++ b/ext/iodine/fio.c @@ -3689,7 +3689,8 @@ ssize_t fio_flush(intptr_t uuid) { return -1; flush_rw_hook: - flushed = uuid_data(uuid).rw_hooks->flush(uuid, uuid_data(uuid).rw_udata); + if(uuid_data(uuid).rw_hooks) + flushed = uuid_data(uuid).rw_hooks->flush(uuid, uuid_data(uuid).rw_udata); fio_unlock(&uuid_data(uuid).sock_lock); if (!flushed) return 0; @@ -3749,7 +3750,8 @@ size_t fio_flush_all(void) { return 0; size_t count = 0; for (uintptr_t i = 0; i <= fio_data->max_protocol_fd; ++i) { - if ((fd_data(i).open || fd_data(i).packet) && fio_flush(fd2uuid(i)) > 0) + if ((fd_data(i).open || fd_data(i).packet) && + fd_data(i).rw_hooks && fio_flush(fd2uuid(i)) > 0) ++count; } return count; diff --git a/lib/iodine/version.rb b/lib/iodine/version.rb index bab9c80a..af516f6c 100644 --- a/lib/iodine/version.rb +++ b/lib/iodine/version.rb @@ -1,3 +1,3 @@ module Iodine - VERSION = '0.7.48'.freeze + VERSION = '0.7.49'.freeze end