sock_read_buf: properly detect closed connection
This commit is contained in:
parent
576aca9ac6
commit
bdec49c3b6
|
@ -2,7 +2,7 @@ CONFIG_LOG=y
|
|||
CONFIG_NET_LOG=y
|
||||
CONFIG_LOG_BUFFER_SIZE=1024
|
||||
CONFIG_LOG_PRINTK=y
|
||||
CONFIG_LOG_DEFAULT_LEVEL=4
|
||||
CONFIG_LOG_DEFAULT_LEVEL=3
|
||||
|
||||
CONFIG_NETWORKING=y
|
||||
CONFIG_NET_IPV4=y
|
||||
|
|
|
@ -70,6 +70,8 @@ sock_read_buf(int sock, struct bufptr *bp, bool entire)
|
|||
{
|
||||
do {
|
||||
ssize_t l = zsock_recv(sock, bp->p, bp->left, 0);
|
||||
if (l == 0)
|
||||
return -ECONNRESET;
|
||||
if (l < 0)
|
||||
return -errno;
|
||||
|
||||
|
@ -88,6 +90,8 @@ sock_write_buf(int sock, struct bufptr *bp)
|
|||
*/
|
||||
while (bp->left) {
|
||||
ssize_t l = zsock_send(sock, bp->p, bp->left, 0);
|
||||
if (l == 0)
|
||||
return -ECONNRESET;
|
||||
if (l < 0)
|
||||
return -errno;
|
||||
bp->p += l;
|
||||
|
|
Loading…
Reference in New Issue