Skip to content

Commit b379e13

Browse files
committed
Fix handling of MSG_DONTWAIT after unifying I/O stuff
1 parent 15e0a49 commit b379e13

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/lib/lwan-io-wrappers.h

+7-8
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@
1414
*
1515
* You should have received a copy of the GNU General Public License
1616
* along with this program; if not, write to the Free Software
17-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
18+
* USA.
1819
*/
1920

2021
#pragma once
2122

22-
#include <unistd.h>
23+
#include <errno.h>
2324
#include <sys/uio.h>
25+
#include <unistd.h>
2426

2527
#include "lwan.h"
2628

@@ -40,11 +42,8 @@ int lwan_sendfile_fd(struct lwan_request *request,
4042
size_t count,
4143
const char *header,
4244
size_t header_len);
43-
ssize_t lwan_recv_fd(struct lwan_request *request,
44-
int fd,
45-
void *buf,
46-
size_t count,
47-
int flags);
45+
ssize_t lwan_recv_fd(
46+
struct lwan_request *request, int fd, void *buf, size_t count, int flags);
4847
ssize_t lwan_readv_fd(struct lwan_request *request,
4948
int fd,
5049
struct iovec *iov,
@@ -94,7 +93,7 @@ static inline ssize_t
9493
lwan_recv(struct lwan_request *request, void *buf, size_t count, int flags)
9594
{
9695
ssize_t r = lwan_recv_fd(request, request->fd, buf, count, flags);
97-
if (UNLIKELY(r < 0)) {
96+
if (UNLIKELY(r < 0 && !(flags & MSG_NOSIGNAL))) {
9897
coro_yield(request->conn->coro, CONN_CORO_ABORT);
9998
__builtin_unreachable();
10099
}

src/lib/lwan-websocket.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,11 @@ int lwan_response_websocket_read_hint(struct lwan_request *request,
343343
next_frame:
344344
last_opcode = opcode;
345345

346-
if (!lwan_recv(request, &header, sizeof(header),
347-
continuation ? 0 : MSG_DONTWAIT))
348-
return EAGAIN;
346+
ssize_t r = lwan_recv(request, &header, sizeof(header),
347+
MSG_DONTWAIT | MSG_NOSIGNAL);
348+
if (r < 0) {
349+
return (int)-r;
350+
}
349351
header = htons(header);
350352
continuation = false;
351353

0 commit comments

Comments
 (0)