Author: mladen.turk(a)jboss.com
Date: 2007-10-31 08:57:25 -0400 (Wed, 31 Oct 2007)
New Revision: 1160
Modified:
trunk/sight/java/org/jboss/sight/Shm.java
Log:
Use network byte order for shared memory
Modified: trunk/sight/java/org/jboss/sight/Shm.java
===================================================================
--- trunk/sight/java/org/jboss/sight/Shm.java 2007-10-31 09:02:34 UTC (rev 1159)
+++ trunk/sight/java/org/jboss/sight/Shm.java 2007-10-31 12:57:25 UTC (rev 1160)
@@ -25,6 +25,7 @@
package org.jboss.sight;
import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
/** Shm
*
@@ -43,6 +44,7 @@
private static native ByteBuffer addr0(long instance, long size);
private static native int remove0(String name, long pool);
+ private ByteBuffer bb = null;
/**
* Create new Shm with root as parent pool.
*/
@@ -192,7 +194,14 @@
*/
public ByteBuffer getBytes()
{
- return addr0(INSTANCE, -1);
+ if (bb == null) {
+ bb = addr0(INSTANCE, -1);
+ if (bb != null) {
+ // Always use network byte order
+ bb.order(ByteOrder.BIG_ENDIAN);
+ }
+ }
+ return bb;
}
/**
@@ -205,7 +214,14 @@
*/
public ByteBuffer getBytes(long size)
{
- return addr0(INSTANCE, size);
+ if (bb == null) {
+ bb = addr0(INSTANCE, size);
+ if (bb != null) {
+ // Always use network byte order
+ bb.order(ByteOrder.BIG_ENDIAN);
+ }
+ }
+ return bb;
}
/**
Show replies by date