Skip to content
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

user_data pointer and design flaw #10

Open
questor opened this issue Apr 4, 2013 · 1 comment
Open

user_data pointer and design flaw #10

questor opened this issue Apr 4, 2013 · 1 comment

Comments

@questor
Copy link

questor commented Apr 4, 2013

some more errors :)

  • first when you set the user_data pointer it will be overwritten in the reset_connection function which is not only called on a new incoming connection, but also in the serving state (see webby.c line 1191)
  • there's a problem in the design of webby in my usecase: I've written a monitoring component were the http-page opens a websocket to webby and my c-code sends new values every second (without more traffic generated from the webpage). but to be able to send values from the c-code to the client I need to give webby a connection pointer which isn't available. (the connection pointer is only given if for example something is sent from the client to the server and the websockets-received-callback it triggered). saving the connection pointer during a websocket connection callback isn't working because the connections are moved by the memmove when another connection is closed.

for my usecase I've made a work-a-round in webby to be able to search for a user_data pointer and returning the corresponding connection, it's working for me but that's not really a good design :) I'm not sure how to fix this issue, perhaps by introducing connection id's.

@deplinenoise
Copy link
Owner

Good point, hadn't thought about that when connections were moved/compacted. What about keeping a rolling sequence number (a connection id) and then we'd modulo into the connections array to see if it still has the same ID?

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

No branches or pull requests

2 participants