WebSocket: a signal during a blocking receive closes the connection

Open Beginner friendly
#925 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
84/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c
Domain
networking

Research direction

Start in src/net/websocket/websocket.c at read_exact() and compare its recv() handling with the existing EINTR retry in ws_send_all(). The issue identifies the expected behavior: retry when recv() fails with errno == EINTR. Verify that interrupted receives no longer close the connection and that other nonpositive results retain their existing handling.

Written by the indexing model from the issue text.

Description

bug

Location: src/net/websocket/websocket.c, read_exact().

Found by code reading on dev at 04ada5ffa; not reproduced with a running program.

read_exact() returns -1 for any recv() result <= 0, including -1 with errno == EINTR. A signal delivered to the thread blocked in cwist_websocket_receive() (for example a timer or SIGCHLD without SA_RESTART) is treated as a closed connection. The send side (ws_send_all()) already retries on EINTR.

Expected: EINTR is retried.

Dominant language
C
Stars
16
Forks
7
Avg merge
4h 56m
Merged PRs (30d)
194

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from c4punks/CWIST

All issues in c4punks/CWIST

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.