From 64db0f085be0c9efc6dca8d9e72d3e5a47cb792e Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Mon, 25 Sep 2017 12:49:10 -0700 Subject: Refactor option handling APIs. This makes the APIs use string keys, and largely eliminates the use of integer option IDs altogether. The underlying registration for options is also now a bit richer, letting protcols and transports declare the actual options they use, rather than calling down into each entry point carte blanche and relying on ENOTSUP. This code may not be as fast as the integers was, but it is more intuitive, easier to extend, and is not on any hot code paths. (If you're diddling options on a hot code path you're doing something wrong.) --- src/core/protocol.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/core/protocol.h') diff --git a/src/core/protocol.h b/src/core/protocol.h index 9416b2bf..0c0d93ce 100644 --- a/src/core/protocol.h +++ b/src/core/protocol.h @@ -47,6 +47,12 @@ struct nni_proto_pipe_ops { void (*pipe_stop)(void *); }; +struct nni_proto_sock_option { + const char *pso_name; + int (*pso_getopt)(void *, void *, size_t *); + int (*pso_setopt)(void *, const void *, size_t); +}; + struct nni_proto_sock_ops { // sock_init creates the protocol instance, which will be stored on // the socket. This is run without the sock lock held, and allocates @@ -68,10 +74,6 @@ struct nni_proto_sock_ops { // it can signal the socket worker threads to exit. void (*sock_close)(void *); - // Option manipulation. These may be NULL. - int (*sock_setopt)(void *, int, const void *, size_t); - int (*sock_getopt)(void *, int, void *, size_t *); - // Receive filter. This may be NULL, but if it isn't, then // messages coming into the system are routed here just before being // delivered to the application. To drop the message, the prtocol @@ -81,6 +83,9 @@ struct nni_proto_sock_ops { // Send filter. This may be NULL, but if it isn't, then messages // here are filtered just after they come from the application. nni_msg *(*sock_sfilter)(void *, nni_msg *); + + // Options. Must not be NULL. Final entry should have NULL name. + nni_proto_sock_option *sock_options; }; typedef struct nni_proto_id { -- cgit v1.2.3-70-g09d2