Can I delete this post? I found out my own mistake. I stored shared_ptr to 
a data structure as shared_ptr&, and since the original share_ptr is 
out-of-scope, the object has reference 0 and thusly deallocated, which is 
why there is segfault.

I now store shared_ptr as shared_ptr, copied the whole shared_ptr into the 
data structure as the new container, and now problem is fixed. & is good 
for performance, but watch out because it's not a reference to the actual 
object and does not count as shared_ptr count!.

On Sunday, December 10, 2017 at 7:14:55 PM UTC-5, Jasper Wu wrote:
>
> I'm working on a async client that keeps on sending tasks to servers. To 
> make it efficient and fail-tolerant, I maintain server status by constantly 
> checking if the channel is working.
>
> However, for all channel query apis, I've tried
> channel::GetState(), channel::WaitForConnnected(T deadline), etc...
> All of them gives segfault after multiple queries.
> Does anyone know why? And how should I query about channel connectivity or 
> server up/down info?
>
> I read connectivity-semantics-and-api.md 
> <https://github.com/grpc/grpc/blob/master/doc/connectivity-semantics-and-api.md>
>  
> and understand that connection status will become "TRANSIENT_FAILURE" if 
> the server is down.
>
> My goal here is to know if that server is later up so that I can 
> distribute tasks to it. I understand that I can simply keep sending 
> messages to potentially up servers and grpc will keep reconnecting if the 
> server is down. But I keep tasks as a pool and send the task while removing 
> it from the pool. And later if deadline is exceeded, I will then added back 
> to the pool. So if I keep sending the task to an already-known-failed 
> server, I would waste time resources by keep sending tasks. So any other 
> idea for implementing this?
>
> I'm not sure if I can my points clearly. My project is kind of involved 
> and yet I'm a newbie to this area, sorry and thanks for reading!!
>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/00250b6c-ddbc-48e8-86e9-e96fed32730b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to