Skip to content

Add tcp servers and clients to standard library #1058

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
Draft

Conversation

phischu
Copy link
Collaborator

@phischu phischu commented Jun 23, 2025

  • Fix warnings
  • Equivalent JS implementation
  • Fix bug with server_client and more than 2 clients
  • Do todos

@phischu phischu marked this pull request as draft June 23, 2025 15:16
This fixes a memory leak and increases the backlog of uv_listen to
SOMAXCONN, such that connections are put in a queue when the previous
acceptor is not yet finished (this is the case with a timeout, which
triggers the connects at the same time)

Another memory leak remains which I couldn't find.

```
==130847== 128 bytes in 1 blocks are definitely lost in loss record 1 of 1
==130847==    at 0x48577A8: malloc (vg_replace_malloc.c:446)
==130847==    by 0x4003F90: ??? (in server_client)
==130847==    by 0x4004499: ??? (in server_client)
==130847==    by 0x4004557: run (in server_client)
==130847==    by 0x4004A1C: spawn_4055 (in server_client)
==130847==    by 0x40044F6: resume_Int (in server_client)
==130847==    by 0x4002BA0: c_tcp_listen (io.c:367)
==130847==    by 0x4004B65: listen_4331 (in server_client)
==130847==    by 0x400CA5D: effektMain (in server_client)
==130847==    by 0x4003D60: main (main.c:37)
```
@phischu
Copy link
Collaborator Author

phischu commented Jul 1, 2025

Perhaps the other leak is the same as this one: libuv/libuv#559

@marvinborner
Copy link
Member

Looks indeed similar, I believe the 128 byte object to be some internal UV structure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants