Datagram socket leak
Chris Hegarty
chris.hegarty at oracle.com
Thu Sep 8 09:54:49 PDT 2011
I think you've covered all the bases here, at least that I can see.
-Chris.
On 09/ 8/11 05:14 PM, Michael McMahon wrote:
> Sigh. Hopefully this is the last webrev.
>
> http://cr.openjdk.java.net/~michaelm/7085981/webrev.4/
>
> Socket.java changed from last one. If there's no objection
> I'll push this version.
>
> - Michael.
>
> On 08/09/11 15:20, Salter, Thomas A wrote:
>> Doesn't the socket get created by the createImpl before the bind in
>> the Socket constructor? Then bind or connect might throw an
>> IllegalArgumentException.
>>
>>
>> private Socket(SocketAddress address, SocketAddress localAddr,
>> boolean stream) throws IOException {
>> setImpl();
>>
>> // backward compatibility
>> if (address == null)
>> throw new NullPointerException();
>>
>> try {
>> createImpl(stream);<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>> if (localAddr != null)
>> bind(localAddr);
>> if (address != null)
>> connect(address);
>> } catch (IOException e) {
>> close();
>> throw e;
>> }
>> }
>>
>> -----Original Message-----
>> From: Michael McMahon [mailto:michael.x.mcmahon at oracle.com]
>> Sent: Thursday, September 08, 2011 4:11 AM
>> To: chris hegarty
>> Cc: Salter, Thomas A; net-dev at openjdk.java.net
>> Subject: Re: Datagram socket leak
>>
>> On 07/09/11 21:54, chris hegarty wrote:
>>> On 07/09/2011 17:24, Michael McMahon wrote:
>>>> Hi all,
>>>>
>>>> I've posted a webrev for this at:
>>>>
>>>> http://cr.openjdk.java.net/~michaelm/7085981/webrev.1/
>>>>
>>>> After checking Socket and ServerSocket, I believe they are not actually
>>>> affected by this issue. The IllegalArgumentExceptions are thrown
>>>> before the
>>>> impl is created in both cases.
>>> Sorry Michael, I don't see this. It looks like the impl is create in
>>> the private Socket before bind is called, then bind can throw IAE. Or
>>> have I missed something.
>>>
>>> Trivially, the no-args constructor can call this(new
>>> InetSocketAddress(0)). I just noticed that these are the same.
>>>
>>> -Chris.
>>>
>> Chris,
>>
>> The impl is set but the socket is not created until impl.create() is
>> called.
>>
>> - Michael.
>>
>
More information about the net-dev
mailing list