Port to CUnit version 2

Linux distributions like openSUSE 12.3 include CUnit version 2.
Apparently libiscsi uses some CUnit version 1 data structures that
have been modified in CUnit version 2. This causes the libiscsi
build to fail against CUnit version 2. Fix this by detecting the
CUnit version during the configure step.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
iscsi_reconnect: Fix a use-after-free

This patch fixes the following Valgrind complaint:

Invalid read of size 4
   at 0x524A858: iscsi_reconnect (connect.c:378)
   by 0x5258794: iscsi_service (socket.c:707)
   by 0x52599C4: event_loop (sync.c:67)
   by 0x525AFD7: iscsi_reserve6_sync (sync.c:1096)
   by 0x40A40A: reserve6 (iscsi-support.c:3291)
   by 0x422C95: test_reserve6_target_warm_reset (test_reserve6_target_warm_reset.c:39)
   by 0x503B05F: ??? (in /usr/lib/libcunit.so.1.0.1)
   by 0x503B375: ??? (in /usr/lib/libcunit.so.1.0.1)
   by 0x503B69F: CU_run_all_tests (in /usr/lib/libcunit.so.1.0.1)
   by 0x403171: main (iscsi-test-cu.c:1258)
 Address 0x6443958 is 3,032 bytes inside a block of size 4,120 free'd
   at 0x4C2B83A: free (vg_replace_malloc.c:468)
   by 0x524A846: iscsi_reconnect (connect.c:374)
   by 0x5258794: iscsi_service (socket.c:707)
   by 0x52599C4: event_loop (sync.c:67)
   by 0x525AFD7: iscsi_reserve6_sync (sync.c:1096)
   by 0x40A40A: reserve6 (iscsi-support.c:3291)
   by 0x422C95: test_reserve6_target_warm_reset (test_reserve6_target_warm_reset.c:39)
   by 0x503B05F: ??? (in /usr/lib/libcunit.so.1.0.1)
   by 0x503B375: ??? (in /usr/lib/libcunit.so.1.0.1)
   by 0x503B69F: CU_run_all_tests (in /usr/lib/libcunit.so.1.0.1)
   by 0x403171: main (iscsi-test-cu.c:1258)

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
test_read6_simple: Avoid triggering a use-after-free

Do not use the 'task' pointer after the memory it points at has been freed.
Detected via valgrind.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>