Skip to content

Commit

Permalink
tcp_modbus_accept mustn't close socket on error (closes stephane#333)
Browse files Browse the repository at this point in the history
The socket management belongs to the application.

The return code was missing in modbus_tcp_pi_accept().
  • Loading branch information
stephane committed Jul 19, 2016
1 parent 1c42e59 commit 4b723c6
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/modbus-tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,8 +661,6 @@ int modbus_tcp_accept(modbus_t *ctx, int *s)
#endif

if (ctx->s == -1) {
close(*s);
*s = -1;
return -1;
}

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 4b723c6

Please sign in to comment.