bitshares / bitshares-core

BitShares Blockchain node and command-line wallet
https://bitshares.github.io/
Other
1.17k stars 647 forks source link

[FC] Writing to a tcp_socket which has EOF'd may hang forever #207

Open vikramrajkumar opened 7 years ago

vikramrajkumar commented 7 years ago

From @nathanhourt on April 5, 2016 21:48

Reporting here, as cryptonomex/fc does not track issues and I assume no one cares about bytemaster/fc anymore.

Calling write on a fc::tcp_socket which has reached EOF on a previous read may work, or it may hang forever (I find that it will always hang forever if enough bytes are written or write is called multiple times). Writing to a TCP socket when the remote end has shutdown writes is explicitly legal under TCP semantics, so this should either work or throw.

Note that it is apparently impossible to handle this gracefully as FC's normal timeout mechanisms fail in this instance as well. I attempted something similar to the following:

if (haveReadEof) {
    fc::async(socket.write(...)).wait(fc::milliseconds(100));
} else {
    socket.write(...);
}

This also did not work, as the call to wait(fc::milliseconds(100)) hangs forever when socket.write hangs forever, instead of throwing fc::timeout_exception as it should. My workaround is simply to throw if an EOF has been read, without trying to write.

Copied from original issue: cryptonomex/graphene#646

oxarbitrage commented 7 years ago

guys, we need to allow issues in https://github.com/bitshares/bitshares-fc and move this one there so we can deal with this and other FC issues separated. someone with enough rights pls allow issues and move.

vikramrajkumar commented 7 years ago

I originally intentionally disabled issues there to help consolidate issues into one place -- since bitshares-fc is only used for bitshares-core and the same backend developers basically develop and compile them as a whole (EOS in fact merged its fc directly into its core repository), and since historically there were issues that required changes across both fc and core.

oxarbitrage commented 7 years ago

ok, cool, thanks for the the clarification. we can keep it this way then i guess .