mail kit: Improve debugging of internal mail kit network code

* Return the correct error code if there is a connection error
* Be more verbose if there is a problem
  network connection problem instead of showing "Login error: "
* IMAP inbound: Show a valid error message if there is a
* Show server name resolution, fishes out IPv6 bug #8293
This commit is contained in:
Alexander von Gluck IV 2012-01-22 00:12:07 -06:00
parent d3ff06683a
commit fd391ef3c2
2 changed files with 16 additions and 4 deletions

View File

@ -345,8 +345,15 @@ IMAPInboundProtocol::Connect(const char* server, const char* username,
status_t status = fIMAPMailbox.Connect(server, username, password, useSSL,
port);
if (status != B_OK) {
statusMessage = "Failed to login: ";
statusMessage += fIMAPMailbox.CommandError();
if (fIMAPMailbox.CommandError().CountChars() > 0) {
// This was a IMAP error
statusMessage = "Failed to login: ";
statusMessage += fIMAPMailbox.CommandError();
} else {
// Probably a connection error
statusMessage = "Connection error: ";
statusMessage += strerror(status);
}
ShowError(statusMessage);
ResetProgress();
return status;

View File

@ -224,14 +224,19 @@ SocketConnection::Connect(const char* server, uint32 port)
if (status != B_OK)
return status;
TRACE("Server resolves to %s\n", address.ToString().String());
fSocket = socket(address.Family(), SOCK_STREAM, 0);
if (fSocket < 0)
if (fSocket < 0) {
TRACE("%s: Socket Error: %s\n", __func__, strerror(status));
return errno;
}
int result = connect(fSocket, address, address.Length());
if (result < 0) {
TRACE("%s: Connect Error: %s\n", __func__, strerror(result));
close(fSocket);
return errno;
return result;
}
TRACE("SocketConnection: connected\n");