tgtd: fix memory access overrun on array of pthread_t type data

bs_thread_close function accesses memory outside allocated region
because it reads each array element with an index before confirming
that the index is within the range of the array.

This fixes the issue and gets rid of the following warning detected by
valgrind:

 ==10848== Invalid read of size 8
 ==10848==    at 0x42AF91: bs_thread_close (bs.c:461)
 ==10848==    by 0x42BD94: bs_sheepdog_exit (bs_sheepdog.c:1275)
 ==10848==    by 0x4183B7: tgt_device_destroy (target.c:739)
 ==10848==    by 0x41608D: mtask_received (mgmt.c:251)
 ==10848==    by 0x4164CB: mtask_recv_send_handler (mgmt.c:670)
 ==10848==    by 0x4141F8: event_loop (tgtd.c:428)
 ==10848==    by 0x414899: main (tgtd.c:611)

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bs_sheepdog.c: add missing initialization of request header

The create_branch function of the sheepdog driver sends a partially
uninitialized request to sheepdog.  This fixes the defect.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Reviewed-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
bs_sheepdog.c: add missing initialization of read data length

In the sheepdog driver, the read data length argument of do_req
function is not initialized by some caller functions such as
sd_sync(), sd_close(), and create_branch().

This patch adds those missing initializations to prevent uncertain
behavior in do_req() and fixes the following warning of valgrind:

 ==1885== Conditional jump or move depends on uninitialised value(s)
 ==1885==    at 0x425994: do_req (bs_sheepdog.c:598)
 ==1885==    by 0x426A06: bs_sheepdog_close (bs_sheepdog.c:1100)
 ==1885==    by 0x4142B4: tgt_device_destroy (target.c:705)
 ==1885==    by 0x412335: tgt_mgmt (mgmt.c:222)
 ==1885==    by 0x412776: mtask_handler (mgmt.c:494)
 ==1885==    by 0x4106A8: event_loop (tgtd.c:411)
 ==1885==    by 0x410D64: main (tgtd.c:583)

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Reviewed-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>