Discussion:
[jcifs] DcerpcHandle thread safety
Mateusz Kołodziej
2015-01-09 09:02:33 UTC
Permalink
Hi

Is class DcerpcHandle thread safe?

There is a field:
private static int call_id = 1; and a method: public void sendrecv(DcerpcMessage msg){ ... msg.call_id = call_id++;...}
I guess it is not thread safe. Is this a bug or it will work anyway?

Thanks
Michael B Allen
2015-01-12 03:25:01 UTC
Permalink
On Fri, Jan 9, 2015 at 4:02 AM, Mateusz Kołodziej
Post by Mateusz Kołodziej
Hi
Is class DcerpcHandle thread safe?
private static int call_id = 1;
public void sendrecv(DcerpcMessage msg){
...
msg.call_id = call_id++;
...
}
I guess it is not thread safe. Is this a bug or it will work anyway?
Hi Mateusz,

Yeah, that code looks dubious. In practice there are locks (bind()
locks 'this') but other calls lock on different objects so it looks
like it is very possible for the same call_id to be used.

It might be sufficient to make call_id volatile but I think there
should probably be a synchronized(this) {} around at least that one
line.

I have added this to the TODO list for further investigation.

Thanks for reporting it.

Mike
--
Michael B Allen
Java Active Directory Integration
http://www.ioplex.com/
Loading...