Open
Description
If the _uv_tcp_t
connection has multiple messages to be read or a single message with a \n
, the call UV_TCP_ReadLine
fails with the following message:
<ceu-libuv path>/include/uv/stream.ceu:101] runtime error: bug found
For the name of the call (ReadLine) I assume this code should return a single line in each call. The following code illustrates the bug:
server:
#include "uv/uv.ceu"
#include "uv/tcp.ceu"
code/await UV_TCP_Server_Handler (var& _uv_tcp_t client) -> int
do
loop do
vector[] byte buffer;
await UV_TCP_ReadLine(&client, &buffer);
_printf ("[server] received: %s\n", &&buffer[0]);
buffer = [] .. "PONG\n";
await UV_TCP_Write (&client, &buffer);
#if 0 //Changing to 1 causes the client to fail
await UV_TCP_Write (&client, &buffer);
#endif
end
end
#include "uv/tcp-server.ceu"
await UV_TCP_Server ("0.0.0.0", 8888, 128);
client:
#include "uv/uv.ceu"
#include "uv/tcp.ceu"
event& (void) connected;
var& _uv_tcp_t tcp_;
watching UV_TCP_Connect("0.0.0.0", 8888) -> (&tcp_, &connected)
do
await connected;
vector []byte buffer = [] .. "PING\n";
await UV_TCP_Write(&tcp_, &buffer);
await 1s;
await UV_TCP_ReadLine(&tcp_, &buffer); //If the server sends two consecutive messages, the client fails here
_printf ("%s\n", &&buffer[0]);
end
escape 0;