# Handling of total\_timeout in C aerospike client

**URL:** <https://discuss.aerospike.com/t/handling-of-total-timeout-in-c-aerospike-client/5935>\
**Category:** How Aerospike Works\
**Created:** [February 8, 2019, 6:17am UTC](https://discuss.aerospike.com/t/handling-of-total-timeout-in-c-aerospike-client/5935 "2019-02-08T06:17:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mahaveer\_Darade](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/mahaveer_darade/32/1060_2.png) [@Mahaveer\_Darade](https://discuss.aerospike.com/u/Mahaveer_Darade)\
**Post date:** [February 8, 2019, 6:17am UTC](https://discuss.aerospike.com/t/handling-of-total-timeout-in-c-aerospike-client/5935/1 "2019-02-08T06:17:10Z")

</div>

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.

```auto
(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
(gdb) 

```

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.

---

<div class="post-metadata">

**Author:** ![meher](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/meher/32/1644_2.png) [@meher](https://discuss.aerospike.com/u/meher)\
**Post date:** [February 14, 2019, 2:58am UTC](https://discuss.aerospike.com/t/handling-of-total-timeout-in-c-aerospike-client/5935/2 "2019-02-14T02:58:54Z")

</div>

[handling of server response after total\_timeout has happened. · Issue #88 · aerospike/aerospike-client-c · GitHub](https://github.com/aerospike/aerospike-client-c/issues/88#issuecomment-463057273)
