hxcpp icon indicating copy to clipboard operation
hxcpp copied to clipboard

Wrong code for C:\HaxeToolkit\haxe\lib\hxcpp\4,2,1\src\hx\libs\std\Socket.cpp

Open hypergeome opened this issue 3 years ago • 0 comments

I found out the code of _hx_std_socket_send method is wrong. It has no HANDLE_EINTR like _hx_std_socket_send_char for ex. The result is that when I dump a big message, says about 200kb into socket, it keeps throwing Blocked while it should not. If I added label and HANDLE_EINTR like below, it works.

int _hx_std_socket_send( Dynamic o, Array<unsigned char> buf, int p, int l )
{
   SOCKET sock = val_sock(o);
   int dlen = buf->length;
   if( p < 0 || l < 0 || p > dlen || p + l > dlen )
      return 0;

   const char *base = (const char *)&buf[0];
   hx::EnterGCFreeZone();
   POSIX_LABEL(send_data_again);
   dlen = send(sock, base + p , l, MSG_NOSIGNAL);
   if( dlen == SOCKET_ERROR ){
	  HANDLE_EINTR(send_data_again);
      block_error();
   }
   hx::ExitGCFreeZone();
   return dlen;
}

hypergeome avatar Oct 25 '22 08:10 hypergeome