Opened 2 years ago

Closed 2 years ago

#2440 closed enhancement (fixed)

NTCP write should be in a loop

Reported by: Zlatin Balevsky Owned by: zzz
Priority: minor Milestone: 0.9.39
Component: router/transport Version: 0.9.38
Keywords: ntcp nio Cc:
Parent Tickets: Sensitive: no


This is symmetric to #2243 except for writing. There is no guarantee that a single write call will write the entire buffer, so the write should be in a loop until it returns 0 or there is nothing more to write.

One possible way of doing this is:

# old_revision [5175d0f5f52c62ecc0e2e76c53e445d47181ec9e]
# patch "router/java/src/net/i2p/router/transport/ntcp/"
#  from [f284aa0bf8e6a8fe2b465e349d98e677a5939021]
#    to [94a79661753d0228e6ec34d8cf909ca6f71c876b]
--- router/java/src/net/i2p/router/transport/ntcp/      f284aa0bf8e6a8fe2b465e349d98e677a5939021
+++ router/java/src/net/i2p/router/transport/ntcp/      94a79661753d0228e6ec34d8cf909ca6f71c876b
@@ -753,7 +749,7 @@ class EventPumper implements Runnable {
                     } else if (buf.remaining() > 0) {
                         // stay interested
                         //key.interestOps(key.interestOps() | SelectionKey.OP_WRITE);
-                        break;
+                        continue;
                     } else {
                         //if (buffer time is too much, add OP_WRITe to the interest ops and break?)


Change History (2)

comment:1 Changed 2 years ago by zzz

Milestone: undecided0.9.39


comment:2 Changed 2 years ago by zzz

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.