[Libwebsockets] new context_info structs

"Andy Green (林安廸)" andy at warmcat.com
Mon Feb 11 16:14:34 CET 2013


On 11/02/13 23:09, the mail apparently from Jack Mitchell included:
> Hi,
>
> I am having issues trying to create my contexts properly (I think) with
> the new struct layout.
>
> I have the following:
>
> static struct libwebsocket_protocols generic_protocol[] =
> {
>     {"http-only", callback_http, 0, 0},
>     {"send-receive-value", webSock_genericSendRecieve, sizeof(struct
> per_session_data_genericSendRecieve), RX_BUFFER_SIZE},
>     {NULL, NULL, 0, 0},
> };
>
> card {
>        .context_info =
>        {
>           .port = PORT_BASE_ADDRESS,
>           .protocols = generic_protocol,
>           .extensions = libwebsocket_internal_extensions,
>           .gid = -1,
>           .uid = -1,
>        },
> }
>
> libwebsocket_create_context(&card->context_info);
>
> However, when I run my application I get a segfault, under GDB it points
> to this:
>
> [946686144:9408] NOTICE: Initial logging level 7
> [946686144:9426] NOTICE: Library version: 1.1 224149a
> [946686144:9445] NOTICE:  static allocation: 5460 + (12 x 1024 fds) =
> 17748 bytes
> [946686144:9500] NOTICE:  canonical_hostname = xx
> [946686144:9524] NOTICE:  Compiled without SSL support
> [946686144:9543] NOTICE:  per-conn mem: 172 + 1328 headers + protocol rx
> buf
> [946686144:9557] NOTICE:  Listening on port 8000
>
>
> Program received signal SIGSEGV, Segmentation fault.
> libwebsocket_callback_on_writable_all_protocol
> (protocol=protocol at entry=0x1d370 <systemConf+96>)
>      at libwebsockets.c:1342
> 1342        for (n = 0; n < context->fds_count; n++) {
>
> It looks like I am initialising something wrong but I'm not sure what...
>
> Does this set off any alarm bells. Am I initialising everything fully in
> the .context_info struct, do I need to put all the SSL related
> parameters and such in there?

The test server is updated to match, you can use that as a reference.

If you're creating the info on the stack, make sure you memset it to 0 
and then fill in the nonzero / non-NULL members.  Even the things you 
don't care about will need to be NULL or 0 and not random stack contents.

-Andy






More information about the Libwebsockets mailing list