On May 8, 2009, at 3:39 PM, Patrick Schlangen wrote:
Hi,
How did your test turn out?
the code seems to run flawlessly with the modifications and did not
raise the error messages a single time.
I think disabling the read <-> peek optimization and enabling the
__FreeBSD__ code parts on a Mac would be a good idea.
Maybe we should forward this to the developers?
I have done some more testing. If I change TSocket line 347 to this:
#if defined __FreeBSD__ || defined __MACH__
then the ECONNRESET is just treated as a close. If I just make this
change, but don't change TBufferTransports.h, I see this message once
in a while from the server:
Thrift: Fri May 8 16:13:41 2009 TSocket::read() recv() <Host: Port:
0>Connection reset by peer
but I never see the "cleint died" message.
The message that I do see is generated at line 343 in TSocket, and
it's generated even if the ECONNRESET is just a close, not a reset.
If you agree with this, then I think the change would be ONLY to
TSocket.cpp. Replace current lines 342 through 356 with this:
#if defined __FreeBSD__ || defined __MACH__
if (errno_copy == ECONNRESET) {
/* shigin: freebsd doesn't follow POSIX semantic of recv and
fails with
* ECONNRESET if peer performed shutdown
*/
close();
return 0;
}
#endif
// Now it's not a try again case, but a real probblez
GlobalOutput.perror("TSocket::read() recv() " + getSocketInfo(),
errno_copy);
// If we disconnect with no linger time
if (errno_copy == ECONNRESET) {
throw TTransportException(TTransportException::NOT_OPEN,
"ECONNRESET");
}
It leaves in the check for ECONNRESET after the output, and we'll
never get to it in OS X, but it makes the logic nice and clean.
What do you think?
- Rush