Skip to content

Commit

Permalink
support 0-length UDP packet for #604 #541
Browse files Browse the repository at this point in the history
  • Loading branch information
ithewei committed Aug 16, 2024
1 parent 4697294 commit f1d5a27
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions event/nio.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,15 +323,14 @@ static void nio_read(hio_t* io) {
// goto read_done;
return;
} else if (err == EMSGSIZE) {
// ignore
return;
nread = len;
} else {
// perror("read");
io->error = err;
goto read_error;
}
}
if (nread == 0) {
if (nread == 0 && (io->io_type & HIO_TYPE_SOCK_STREAM)) {
goto disconnect;
}
if (nread < len) {
Expand Down Expand Up @@ -385,7 +384,7 @@ static void nio_write(hio_t* io) {
goto write_error;
}
}
if (nwrite == 0) {
if (nwrite == 0 && (io->io_type & HIO_TYPE_SOCK_STREAM)) {
goto disconnect;
}
pbuf->offset += nwrite;
Expand Down Expand Up @@ -516,12 +515,12 @@ int hio_write (hio_t* io, const void* buf, size_t len) {
goto write_error;
}
}
if (nwrite == 0) {
goto disconnect;
}
if (nwrite == len) {
goto write_done;
}
if (nwrite == 0 && (io->io_type & HIO_TYPE_SOCK_STREAM)) {
goto disconnect;
}
enqueue:
hio_add(io, hio_handle_events, HV_WRITE);
}
Expand Down

0 comments on commit f1d5a27

Please sign in to comment.