Skip to content

Problem with recent change to the calling sequence for the function 'ws_socket() #86

@grm1209

Description

@grm1209

The recent change to the calling sequence for the function 'ws_socket(struct ws_server *ws_srv)' causes problems if the 'ws_server' structure is in the stack of the calling function and the function exits after calling a non-blocking 'ws_socket()'.

Previously, the callers 'ws_events' structure was copied the wsServer's 'ws_server' structure. Now, the caller's pointer to it's 'ws_server' structure is placed in the wsServer's 'ws_accept_params' structure.

When the calling function exits, it's 'ws_server' structure becomes undefined. The solution for the caller is to allocate the 'ws_server' structure in local space.

A note of this should be included in the documentation. And maybe the examples like 'echo' should do this instead of using stack allocation.

My environment:

  • wsServer version (commit hash)
  • OS version: Debian GNU/Linux 12 (bookworm)
    • If Linux:
      • kernel version: 6.1.0-15-amd64
      • Libc used: Debian GLIBC 2.36-9+deb12u3
  • Architecture: x86-64...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions