RFR: 7152948 msghdr structure not initialized properly in DatagramDispatcher

Alan Bateman Alan.Bateman at oracle.com
Mon Mar 12 03:42:25 PDT 2012


On 12/03/2012 09:34, Shi Jun Zhang wrote:
> Hi nio-dev,
>
> In jdk/src/solaris/native/sun/nio/ch/DatagramDispatcher.c, there are 
> some invocations of system call sendmsg/recvmsg. The second parameter 
> of these 2 calls is a pointer to structure msghdr. The pointer needs 
> to be initialized before it can be used. Currently it is initialized 
> with #ifdef platform clause and it is NOT initialized properly on AIX. 
> I think we can use memset(&m, 0, sizeof(m)) to initialized the pointer 
> once for all platforms.
>
> Here is the webrev:
> http://cr.openjdk.java.net/~zhangshj/7152948/webrev.00/
>
I see 7152948 has been submitted as an incident, I've moved it to the 
right place as:

7152948: (dc) DatagramDispatcher.c should memset msghdr to make it 
portable to other platforms

The changes look okay to me but I think might be a bit cleaner to do the 
memset just prior to setting msg_iov/msg_iovlen (to keep the 
initialization of the msghdr structure in one place).

While you are there, can you change the value 16 to IOV_MAX? (requires 
limits.h).

-Alan






More information about the nio-dev mailing list