From 00e068eb59837b299adaaf34805a47dfc94bf58a Mon Sep 17 00:00:00 2001 From: Stéphane Raimbault Date: Tue, 19 Jul 2016 12:10:28 +0200 Subject: [PATCH] tcp_modbus_accept mustn't close socket on error (closes #333) --- src/modbus-tcp.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/modbus-tcp.c b/src/modbus-tcp.c index 15a8f00..abbff5b 100644 --- a/src/modbus-tcp.c +++ b/src/modbus-tcp.c @@ -661,8 +661,6 @@ int modbus_tcp_accept(modbus_t *ctx, int *s) #endif if (ctx->s == -1) { - close(*s); - *s = -1; return -1; } @@ -691,9 +689,9 @@ int modbus_tcp_pi_accept(modbus_t *ctx, int *s) #else ctx->s = accept(*s, (struct sockaddr *)&addr, &addrlen); #endif + if (ctx->s == -1) { - close(*s); - *s = -1; + return -1; } if (ctx->debug) { -- libgit2 0.21.4