# # patch "ChangeLog" # from [0ba88e6e4cfa027d8bd4849bd4953662325b93d0] # to [9497b500d2d4208e517b818dce716d44949abb08] # # patch "netcmd.cc" # from [570582d069ed089439cc7c46c4b1f90098d1045b] # to [613fd7d1f3e4a89a5dd2ce5d559000b4e2ce74ab] # # patch "netsync.cc" # from [a3221de09fd25684a0ce7b9259ddfcaffba3c3da] # to [fffa11246af3df2d1eec93b7b7927513ab63f2dc] # --- ChangeLog +++ ChangeLog @@ -1,3 +1,11 @@ +2005-05-28 Timothy Brownawell + + * netcmd.cc (read_netcmd): Reserve space in the buffer if needed, + swap buffers instead of copying (memory savings for sync + large files) + * netsync.cc (session::arm): Don't clear the buffer (now done + by read_netcmd). + 2005-05-27 Timothy Brownawell * netsync.cc: Allow REGEXes as well as collections. --- netcmd.cc +++ netcmd.cc @@ -124,12 +124,23 @@ // there might not be enough data yet in the input buffer if (inbuf.size() < pos + payload_len + sizeof(u32)) - return false; + { + inbuf.reserve(pos + payload_len + sizeof(u32) + constants::bufsz); + return false; + } - out.payload = extract_substring(inbuf, pos, payload_len, "netcmd payload"); +// out.payload = extract_substring(inbuf, pos, payload_len, "netcmd payload"); + // Do this ourselves, so we can swap the strings instead of copying. + require_bytes(inbuf, pos, payload_len, "netcmd payload"); + inbuf.erase(0, pos); + out.payload=inbuf.substr(payload_len); + inbuf.erase(payload_len, inbuf.npos); + inbuf.swap(out.payload); + pos=0; // they might have given us bogus data u32 checksum = extract_datum_lsb(inbuf, pos, "netcmd checksum"); + inbuf.erase(0, pos); adler32 check(reinterpret_cast(out.payload.data()), out.payload.size()); if (checksum != check.sum()) --- netsync.cc +++ netsync.cc @@ -2860,7 +2860,7 @@ { if (read_netcmd(inbuf, cmd)) { - inbuf.erase(0, cmd.encoded_size()); +// inbuf.erase(0, cmd.encoded_size()); armed = true; } }