forked from I2P_Developers/i2p.i2p
SusiMail: Close POP3 socket on error
synch isConnected()
This commit is contained in:
@ -213,6 +213,11 @@ public class POP3MailBox implements NewMailListener {
|
|||||||
sendCmds(srs);
|
sendCmds(srs);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
Debug.debug( Debug.DEBUG, "Error fetching bodies: " + ioe);
|
Debug.debug( Debug.DEBUG, "Error fetching bodies: " + ioe);
|
||||||
|
if (socket != null) {
|
||||||
|
try { socket.close(); } catch (IOException e) {}
|
||||||
|
socket = null;
|
||||||
|
connected = false;
|
||||||
|
}
|
||||||
// todo maybe
|
// todo maybe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -336,9 +341,11 @@ public class POP3MailBox implements NewMailListener {
|
|||||||
try {
|
try {
|
||||||
sendCmds(srs);
|
sendCmds(srs);
|
||||||
// do NOT call close() here, we included QUIT above
|
// do NOT call close() here, we included QUIT above
|
||||||
try {
|
if (socket != null) {
|
||||||
socket.close();
|
try { socket.close(); } catch (IOException e) {}
|
||||||
} catch (IOException e) {}
|
socket = null;
|
||||||
|
connected = false;
|
||||||
|
}
|
||||||
clear();
|
clear();
|
||||||
// result of QUIT
|
// result of QUIT
|
||||||
boolean success = srs.get(srs.size() - 1).result;
|
boolean success = srs.get(srs.size() - 1).result;
|
||||||
@ -354,6 +361,11 @@ public class POP3MailBox implements NewMailListener {
|
|||||||
//connect();
|
//connect();
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
Debug.debug( Debug.DEBUG, "Error deleting: " + ioe);
|
Debug.debug( Debug.DEBUG, "Error deleting: " + ioe);
|
||||||
|
if (socket != null) {
|
||||||
|
try { socket.close(); } catch (IOException e) {}
|
||||||
|
socket = null;
|
||||||
|
connected = false;
|
||||||
|
}
|
||||||
// todo maybe
|
// todo maybe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -426,14 +438,18 @@ public class POP3MailBox implements NewMailListener {
|
|||||||
* @return true or false
|
* @return true or false
|
||||||
*/
|
*/
|
||||||
public boolean isConnected() {
|
public boolean isConnected() {
|
||||||
if (socket == null
|
synchronized(synchronizer) {
|
||||||
|| !socket.isConnected()
|
if (socket == null) {
|
||||||
|| socket.isInputShutdown()
|
connected = false;
|
||||||
|| socket.isOutputShutdown()
|
} else if (!socket.isConnected()
|
||||||
|| socket.isClosed()) {
|
|| socket.isInputShutdown()
|
||||||
connected = false;
|
|| socket.isOutputShutdown()
|
||||||
|
|| socket.isClosed()) {
|
||||||
|
socket = null;
|
||||||
|
connected = false;
|
||||||
|
}
|
||||||
|
return connected;
|
||||||
}
|
}
|
||||||
return connected;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -671,6 +687,11 @@ public class POP3MailBox implements NewMailListener {
|
|||||||
}
|
}
|
||||||
catch (IOException e1) {
|
catch (IOException e1) {
|
||||||
lastError = _t("Error opening mailbox") + ": " + e1.getLocalizedMessage();
|
lastError = _t("Error opening mailbox") + ": " + e1.getLocalizedMessage();
|
||||||
|
if (socket != null) {
|
||||||
|
try { socket.close(); } catch (IOException e) {}
|
||||||
|
socket = null;
|
||||||
|
connected = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -813,6 +834,11 @@ public class POP3MailBox implements NewMailListener {
|
|||||||
Debug.debug( Debug.DEBUG, "Error getting RB: " + ioe);
|
Debug.debug( Debug.DEBUG, "Error getting RB: " + ioe);
|
||||||
result = false;
|
result = false;
|
||||||
sr.result = false;
|
sr.result = false;
|
||||||
|
if (socket != null) {
|
||||||
|
try { socket.close(); } catch (IOException e) {}
|
||||||
|
socket = null;
|
||||||
|
connected = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -824,6 +850,11 @@ public class POP3MailBox implements NewMailListener {
|
|||||||
Debug.debug( Debug.DEBUG, "Error getting LS: " + ioe);
|
Debug.debug( Debug.DEBUG, "Error getting LS: " + ioe);
|
||||||
result = false;
|
result = false;
|
||||||
sr.result = false;
|
sr.result = false;
|
||||||
|
if (socket != null) {
|
||||||
|
try { socket.close(); } catch (IOException e) {}
|
||||||
|
socket = null;
|
||||||
|
connected = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -868,6 +899,11 @@ public class POP3MailBox implements NewMailListener {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
lastError = e.toString();
|
lastError = e.toString();
|
||||||
Debug.debug( Debug.DEBUG, "sendCmdNa throws: " + e);
|
Debug.debug( Debug.DEBUG, "sendCmdNa throws: " + e);
|
||||||
|
if (socket != null) {
|
||||||
|
try { socket.close(); } catch (IOException ioe) {}
|
||||||
|
socket = null;
|
||||||
|
connected = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
connect();
|
connect();
|
||||||
if (connected) {
|
if (connected) {
|
||||||
@ -876,6 +912,11 @@ public class POP3MailBox implements NewMailListener {
|
|||||||
} catch (IOException e2) {
|
} catch (IOException e2) {
|
||||||
lastError = e2.toString();
|
lastError = e2.toString();
|
||||||
Debug.debug( Debug.DEBUG, "2nd sendCmdNa throws: " + e2);
|
Debug.debug( Debug.DEBUG, "2nd sendCmdNa throws: " + e2);
|
||||||
|
if (socket != null) {
|
||||||
|
try { socket.close(); } catch (IOException e) {}
|
||||||
|
socket = null;
|
||||||
|
connected = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Debug.debug( Debug.DEBUG, "not connected after reconnect" );
|
Debug.debug( Debug.DEBUG, "not connected after reconnect" );
|
||||||
@ -1126,9 +1167,12 @@ public class POP3MailBox implements NewMailListener {
|
|||||||
}
|
}
|
||||||
sendCmd1aNoWait("QUIT");
|
sendCmd1aNoWait("QUIT");
|
||||||
}
|
}
|
||||||
socket.close();
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Debug.debug( Debug.DEBUG, "error closing: " + e);
|
Debug.debug( Debug.DEBUG, "error closing: " + e);
|
||||||
|
} finally {
|
||||||
|
if (socket != null) {
|
||||||
|
try { socket.close(); } catch (IOException e) {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
socket = null;
|
socket = null;
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
2018-01-25 zzz
|
||||||
|
* GeoIP 2018-01-05
|
||||||
|
* SusiMail: Close POP3 socket on error
|
||||||
|
|
||||||
2018-01-24 zzz
|
2018-01-24 zzz
|
||||||
* i2psnark: Prevent commenting without comment name (ticket #2138)
|
* i2psnark: Prevent commenting without comment name (ticket #2138)
|
||||||
* SusiMail: Fix header corruption (ticket #2139)
|
* SusiMail: Fix header corruption (ticket #2139)
|
||||||
|
@ -18,7 +18,7 @@ public class RouterVersion {
|
|||||||
/** deprecated */
|
/** deprecated */
|
||||||
public final static String ID = "Monotone";
|
public final static String ID = "Monotone";
|
||||||
public final static String VERSION = CoreVersion.VERSION;
|
public final static String VERSION = CoreVersion.VERSION;
|
||||||
public final static long BUILD = 25;
|
public final static long BUILD = 26;
|
||||||
|
|
||||||
/** for example "-test" */
|
/** for example "-test" */
|
||||||
public final static String EXTRA = "-rc";
|
public final static String EXTRA = "-rc";
|
||||||
|
Reference in New Issue
Block a user