Handling of total_timeout in C aerospike client

Hi All,
Aerospike’s C client has handled socket closure from server side (by reaper/thr_demarshal_reaper_fn) properly.
It has not handled below case where response from server comes after timeout at client side. In this case, I am getting SEGFAULT with below trace.

(gdb) bt
#0 as_uv_command_buffer (handle=0x7facf80c6120, suggested_size=65536, buf=0x7fad508ef9d0) at src/main/aerospike/as_event_uv.c:256
#1 0x00007fadafb05d43 in uv__read (stream=0x7facf80c6120) at /root/disk/libuv/src/unix/stream.c:1161
#2 0x00007fadafb063ff in uv__stream_io (loop=0x7facf80008c0, w=0x7facf80c61a8, events=1) at /root/disk/libuv/src/unix/stream.c:1324
#3 0x00007fadafb0c1bb in uv__io_poll (loop=0x7facf80008c0, timeout=0) at /root/disk/libuv/src/unix/linux-core.c:378
#4 0x00007fadafaf660c in uv_run (loop=0x7facf80008c0, mode=UV_RUN_DEFAULT) at /root/disk/libuv/src/unix/core.c:370
#5 0x00007fadafd56b39 in as_uv_worker (udata=0x7fad2b7fcde0) at src/main/aerospike/as_event_uv.c:160
#6 0x00007fadb12956ba in start_thread (arg=0x7fad508f3700) at pthread_create.c:333
#7 0x00007fadae03141d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Lets consider following scenario.

  1. client has set total_timeout to 50 msec.
  2. server sleeps/takes 1 sec for transaction completion before putting response over socket.

libuv’s uv__read() would do alloc_cb which results in call to as_uv_command_buffer().

aerospike client should in this case first check whether as_uv_connection_alive() & then only should derefence cmd->buf.

handling of server response after total_timeout has happened. · Issue #88 · aerospike/aerospike-client-c · GitHub