socket/netconn recv: FIN should only be reported once

FIN should only be reported once (as '0' for sockets, as 'ERR_CLSD' for
netconns). Before this change, ERR_CLSD was returned forever...

This is the 2nd try. First try (commit ebcae98ae6)
was buggy in that it could drop the FIN if it was read together with data
(reverted in commit ebcae98ae6).

This version fixes this by adding an apiflag and a netconn flag to keep
track of this.
This commit is contained in:
goldsimon
2018-02-04 20:16:53 +01:00
parent fe828634ac
commit b1b6275110
4 changed files with 33 additions and 21 deletions

View File

@@ -173,9 +173,8 @@ static void test_sockets_allfunctions_basic_domain(int domain)
ret = lwip_read(s2, buf, 1);
fail_unless(ret == 0);
/* @todo: re-enable when this is working */
/* ret = lwip_read(s2, buf, 1);
fail_unless(ret == -1); */
ret = lwip_read(s2, buf, 1);
fail_unless(ret == -1);
ret = lwip_write(s2, "foo", 3);
fail_unless(ret == 3);
@@ -192,9 +191,8 @@ static void test_sockets_allfunctions_basic_domain(int domain)
ret = lwip_read(s3, buf, 1);
fail_unless(ret == 0);
/* @todo: re-enable when this is working */
/* ret = lwip_read(s3, buf, 1);
fail_unless(ret == -1); */
ret = lwip_read(s3, buf, 1);
fail_unless(ret == -1);
while(tcpip_thread_poll_one());