Changeset acf5c31


Ignore:
Timestamp:
May 2, 2019 11:55:04 AM (13 months ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
8cdeff7
Parents:
20413f0
Message:

NTCP: Rare EventPumper? 100% CPU fix (ticket #2476)

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • history.txt

    r20413f0 racf5c31  
     12019-05-02 zzz
     2 * NTCP: Rare EventPumper 100% CPU fix (ticket #2476)
     3
    142019-04-25 zzz
     5 * Build: Drop unmaintained sample apparmor script (ticket #2319)
     6 * i2ptunnel: Force connect delay and bulk profile for most
     7   client tunnel types, and hide from UI
    28 * Transport: Disable NTCP 1 by default
    39
  • router/java/src/net/i2p/router/RouterVersion.java

    r20413f0 racf5c31  
    1919    public final static String ID = "Monotone";
    2020    public final static String VERSION = CoreVersion.VERSION;
    21     public final static long BUILD = 8;
     21    public final static long BUILD = 9;
    2222
    2323    /** for example "-test" */
    24     public final static String EXTRA = "";
     24    public final static String EXTRA = "-rc";
    2525    public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA;
    2626    public static void main(String args[]) {
  • router/java/src/net/i2p/router/transport/ntcp/EventPumper.java

    r20413f0 racf5c31  
    269269                                    // this will cancel the key, and it will then be removed from the keyset
    270270                                    con.close();
     271                                    key.cancel();
    271272                                    failsafeInvalid++;
    272273                                    continue;
     
    299300                                    // we haven't sent or received anything in a really long time, so lets just close 'er up
    300301                                    con.sendTerminationAndClose();
     302                                    key.cancel();
    301303                                    if (_log.shouldInfo())
    302304                                        _log.info("Failsafe or expire close for " + con);
     
    537539   
    538540    private void processConnect(SelectionKey key) {
    539         NTCPConnection con = (NTCPConnection)key.attachment();
     541        final NTCPConnection con = (NTCPConnection)key.attachment();
     542        final SocketChannel chan = con.getChannel();
    540543        try {
    541             SocketChannel chan = con.getChannel();
    542544            boolean connected = chan.finishConnect();
    543545            if (_log.shouldLog(Log.DEBUG))
     
    588590     */
    589591    private void processRead(SelectionKey key) {
    590         NTCPConnection con = (NTCPConnection)key.attachment();
     592        final NTCPConnection con = (NTCPConnection)key.attachment();
     593        final SocketChannel chan = con.getChannel();
    591594        ByteBuffer buf = null;
    592595        try {
     
    596599                int readThisTime;
    597600                int readCount = 0;
    598                 while ((readThisTime = con.getChannel().read(buf)) > 0)  {
     601                while ((readThisTime = chan.read(buf)) > 0)  {
    599602                    read += readThisTime;
    600603                    readCount++;
     
    606609                if (read < 0) {
    607610                    if (con.isInbound() && con.getMessagesReceived() <= 0) {
    608                         InetAddress addr = con.getChannel().socket().getInetAddress();
     611                        InetAddress addr = chan.socket().getInetAddress();
    609612                        int count;
    610613                        if (addr != null) {
     
    686689                releaseBuf(buf);
    687690            if (con.isInbound() && con.getMessagesReceived() <= 0) {
    688                 InetAddress addr = con.getChannel().socket().getInetAddress();
     691                InetAddress addr = chan.socket().getInetAddress();
    689692                int count;
    690693                if (addr != null) {
     
    732735     */
    733736    private void processWrite(SelectionKey key) {
    734         NTCPConnection con = (NTCPConnection)key.attachment();
     737        final NTCPConnection con = (NTCPConnection)key.attachment();
     738        final SocketChannel chan = con.getChannel();
    735739        try {
    736740            while (true) {
     
    741745                        continue;                   
    742746                    }
    743                     int written = con.getChannel().write(buf);
     747                    int written = chan.write(buf);
    744748                    //totalWritten += written;
    745749                    if (written == 0) {
     
    846850       
    847851        while ((con = _wantsConRegister.poll()) != null) {
     852            final SocketChannel schan = con.getChannel();
    848853            try {
    849                 SelectionKey key = con.getChannel().register(_selector, SelectionKey.OP_CONNECT);
     854                SelectionKey key = schan.register(_selector, SelectionKey.OP_CONNECT);
    850855                key.attach(con);
    851856                con.setKey(key);
     
    858863                        throw new IOException("Invalid NTCP address: " + naddr);
    859864                    InetSocketAddress saddr = new InetSocketAddress(InetAddress.getByAddress(ip), port);
    860                     boolean connected = con.getChannel().connect(saddr);
     865                    boolean connected = schan.connect(saddr);
    861866                    if (connected) {
    862867                        // Never happens, we use nonblocking
  • router/java/src/net/i2p/router/transport/ntcp/NTCPConnection.java

    r20413f0 racf5c31  
    289289     *  Valid for inbound; valid for outbound shortly after creation
    290290     */
    291     public SocketChannel getChannel() { return _chan; }
     291    public synchronized SocketChannel getChannel() { return _chan; }
    292292
    293293    /**
    294294     *  Valid for inbound; valid for outbound shortly after creation
    295295     */
    296     public SelectionKey getKey() { return _conKey; }
    297     public void setChannel(SocketChannel chan) { _chan = chan; }
    298     public void setKey(SelectionKey key) { _conKey = key; }
     296    public synchronized SelectionKey getKey() { return _conKey; }
     297    public synchronized void setChannel(SocketChannel chan) { _chan = chan; }
     298    public synchronized void setKey(SelectionKey key) { _conKey = key; }
    299299
    300300    public boolean isInbound() { return _isInbound; }
     
    11261126     * as it occurs in the selector thread)
    11271127     */
    1128     void outboundConnected() {
     1128    synchronized void outboundConnected() {
     1129        if (_establishState == EstablishBase.FAILED) {
     1130            _conKey.cancel();
     1131            return;
     1132        }
    11291133        _conKey.interestOps(_conKey.interestOps() | SelectionKey.OP_READ);
    11301134        // schedule up the beginning of our handshaking by calling prepareNextWrite on the
Note: See TracChangeset for help on using the changeset viewer.