New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

websockets caused segfaults on linux64. #169

Closed
sunzhaoping opened this Issue Jan 24, 2013 · 1 comment

Comments

Projects
None yet
2 participants
@sunzhaoping

sunzhaoping commented Jan 24, 2013

I run a websockets service .
the code:
auto msg = sock.receive();
caused a segfault error.

[7F515A294051:00000000 INF] Listening for HTTP requests on 0.0.0.0:8080
[7F515A294051:00000000 WRN] Failed to listen on :::8080
[7F515A294051:00000000 INF] Running event loop...
Segmentation fault (core dumped)
import vibe.d;
void index(HttpServerRequest req, HttpServerResponse res)
{
    res.redirect("/index.html");
}
shared static this()
{
   void handleConn(WebSocket sock)
   {
        while( sock.connected ){
             auto msg = sock.receive();
             sock.send(msg);
        }
    }
    auto router = new UrlRouter;
    router.get("/", &index);
    router.get("/connect", handleWebSockets(&handleConn));
    router.get("*", serveStaticFiles("./public/"));
    auto settings = new HttpServerSettings;
    settings.port = 8080;
    listenHttp(settings, router);
}

s-ludwig added a commit that referenced this issue Feb 9, 2013

Adjusted the code style, added documentation and fixed WebSocket.conn…
…ected. Fixes issue #169.

WebSocket.close was using dataAvailableForRead instead of !empty to check if there is any more data to read.
@s-ludwig

This comment has been minimized.

Show comment
Hide comment
@s-ludwig

s-ludwig Feb 9, 2013

Member

I tested with the following simple index.html page and it seems to work fine now. I wonder how this bug could be overlooked...

<html>
<body>
    <script language="javascript">
        socket = new WebSocket("ws://127.0.0.1:8080/connect");
        socket.onopen = function() { console.log("socket opened"); socket.send("Hello, World!"); }
        socket.onmessage = function(message) { console.log("message: " + message.data); }
        socket.onclose = function() { console.log("socket closed"); }
        socket.onerror = function() { console.log("error"); }
    </script>
</body>
</html>
Member

s-ludwig commented Feb 9, 2013

I tested with the following simple index.html page and it seems to work fine now. I wonder how this bug could be overlooked...

<html>
<body>
    <script language="javascript">
        socket = new WebSocket("ws://127.0.0.1:8080/connect");
        socket.onopen = function() { console.log("socket opened"); socket.send("Hello, World!"); }
        socket.onmessage = function(message) { console.log("message: " + message.data); }
        socket.onclose = function() { console.log("socket closed"); }
        socket.onerror = function() { console.log("error"); }
    </script>
</body>
</html>

@s-ludwig s-ludwig closed this Feb 17, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment