diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-08-23 18:30:51 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-08-23 21:14:49 -0700 |
| commit | 68ff9c823d3cead2b11a003c40c8f5affc11dc71 (patch) | |
| tree | 55673a26565a7ceef918f21e198e5c7698971f73 /src/core/protocol.h | |
| parent | 2ec64a78da8df01ec534161475a87989ae527776 (diff) | |
| download | nng-68ff9c823d3cead2b11a003c40c8f5affc11dc71.tar.gz nng-68ff9c823d3cead2b11a003c40c8f5affc11dc71.tar.bz2 nng-68ff9c823d3cead2b11a003c40c8f5affc11dc71.zip | |
Add init/fini to protocols to allow them to register options.
Diffstat (limited to 'src/core/protocol.h')
| -rw-r--r-- | src/core/protocol.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/core/protocol.h b/src/core/protocol.h index 14954b49..9416b2bf 100644 --- a/src/core/protocol.h +++ b/src/core/protocol.h @@ -95,6 +95,15 @@ struct nni_proto { uint32_t proto_flags; // Protocol flags const nni_proto_sock_ops *proto_sock_ops; // Per-socket opeations const nni_proto_pipe_ops *proto_pipe_ops; // Per-pipe operations. + + // proto_init, if not NULL, provides a function that initializes + // global values. The main purpose of this may be to initialize + // protocol option values. + int (*proto_init)(void); + + // proto_fini, if not NULL, is called at shutdown, to release + // any resources allocated at proto_init time. + void (*proto_fini)(void); }; // We quite intentionally use a signature where the upper word is nonzero, @@ -118,7 +127,11 @@ struct nni_proto { // nni_proto_open is called by the protocol to create a socket instance // with its ops vector. The intent is that applications will only see // the single protocol-specific constructure, like nng_pair_v0_open(), -// which should just be a thin wrapper around this. +// which should just be a thin wrapper around this. If the protocol has +// not been initialized yet, this routine will do so. extern int nni_proto_open(nng_socket *, const nni_proto *); +extern int nni_proto_sys_init(void); +extern void nni_proto_sys_fini(void); + #endif // CORE_PROTOCOL_H |
