Hi,

I'm having some issues with the Java bindings for librbd and I'm not sure what the problem is here.

The problem is with listing snapshot of a RBD image. I test it in this test case:

public void testCreateAndClone() {
    try {
        ..
        ..
        image.snapCreate(snapName);
        image.snapProtect(snapName);

        List<RbdSnapInfo> snaps = image.snapList();
        assertEquals("There should only be one snapshot", 1, snaps.size());
    ..
    ..
    }
}

This test fails 95% of the time with my whole JVM crashing.

The code to blame is in RbdImage.java:

public List<RbdSnapInfo> snapList() throws RbdException {
    IntByReference numSnaps = new IntByReference(16);
    PointerByReference snaps = new PointerByReference();
    List<RbdSnapInfo> list = new ArrayList<RbdSnapInfo>();
    RbdSnapInfo snapInfo, snapInfos[];

    while (true) {
        int r = rbd.rbd_snap_list(this.getPointer(), snaps, numSnaps);
        if (r >= 0) {
            numSnaps.setValue(r);
            break;
        } else {
            throw new RbdException("Failed listing snapshots", r);
        }
    }

    Pointer p = snaps.getValue(); <<<< crash
    snapInfo = new RbdSnapInfo(p);

    ..
    ..
}

So it crashes when it wants to get the value of the snaps var.

I can't figure out why this is happening and why it isn't consistent. I'm not a real JNA expert and I was hoping somebody around here would be able to figure out what I'm doing wrong.

Any Java/JNA experts around who might have a clue?

The source of rados-java: https://github.com/wido/rados-java

--
Wido den Hollander
42on B.V.

Phone: +31 (0)20 700 9902
Skype: contact42on
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to