example/sock: avoid register poller multiple times

Timeout poller in hello_sock_quit which locates in hello_sock_accept_poll
can be registered multiple times, each poller allocates memory and
can't be freed.

fixed issue#521

Change-Id: I2730f0e53d99a525becca263c6731231adf5f64b
Signed-off-by: yidong0635 <dongx.yi@intel.com>
Reviewed-on: https://review.gerrithub.io/437226
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
yidong0635 2018-12-14 06:17:46 -05:00 committed by Changpeng Liu
parent 8db5ff2bdd
commit c26bd15881

View File

@ -135,8 +135,10 @@ hello_sock_quit(struct hello_context_t *ctx, int rc)
{
ctx->rc = rc;
spdk_poller_unregister(&ctx->poller_out);
ctx->time_out = spdk_poller_register(hello_sock_close_timeout_poll, ctx,
CLOSE_TIMEOUT_US);
if (!ctx->time_out) {
ctx->time_out = spdk_poller_register(hello_sock_close_timeout_poll, ctx,
CLOSE_TIMEOUT_US);
}
return 0;
}