jcktej / jdiameter

Automatically exported from code.google.com/p/jdiameter
0 stars 0 forks source link

concurrency bug in TCPTransportClient.sendMessage #67

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
>      while (rc < bytes.array().length) {
>        rc += socketChannel.write(bytes);
>      }

This code is not atomic. So, if many threads write messages in same time, then 
all mixed in single garbage.

I fixed this just uncommented lock around loop. It is not problem, because if 
have not contention, that lock is very light. But if have contention, that slow 
application better than garbage instead of message.

But best fix is write from one thread through message queue.

Original issue reported on code.google.com by grinch...@gmail.com on 20 Nov 2014 at 1:11

Attachments: