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

todo: Keep a non-global state #1

Closed
Savagedlight opened this issue Apr 9, 2016 · 1 comment
Closed

todo: Keep a non-global state #1

Savagedlight opened this issue Apr 9, 2016 · 1 comment
Assignees
Labels

Comments

@Savagedlight
Copy link
Owner

Currently, the error feedback is done through a global variable. This is very hostile towards multi-threading.

Instead, create a struct which keeps state for the current thread. This struct should also contain the socket cache. Applications would have to pass an instance of this struct to the API by reference.

This makes it easier to keep track of state, and applications can use libifconfig in a multithreaded way even though libifconfig is not aware of threading, so long as they use a separate instance of the state struct per thread.

Idea by: Adrian Chadd

@Savagedlight Savagedlight self-assigned this Apr 9, 2016
@Savagedlight
Copy link
Owner Author

Feedback from Kristof Provost:

libifc_handle_t* libifc_open();
void libifc_close(libifc_handle_t *h);

int libifc_set_mtu(libifc_handle_t *h, const char *name, int mtu);

Possibly also:
int libifc_get_error(libifc_handle_t *h);

If the definition of libifc_handle_t is kept opaque (so the headers only have ‘struct libifc_handle; typedef struct libifc_handle libifc_handle_t;’) you can get away with changing the size or contents of the struct without breaking any of the users.
(Because they’ll only have a pointer to keep track of, the size of the object it points to doesn’t matter to them.)

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

No branches or pull requests

1 participant