Skip to content

Commit

Permalink
api: add NNG1_MIGRATION transition assistance macro
Browse files Browse the repository at this point in the history
  • Loading branch information
gdamore committed Dec 31, 2024
1 parent b0874b1 commit b56a1d1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 3 additions & 2 deletions docs/ref/migrate/nng1.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ See the [Migrating From libnanomsg](nanomsg.md) chapter for details.
It is now required for applications to initialize the library explicitly before using it.
This is done using the [`nng_init`] function.

## Socket Close Function Renamed
## Renamed Functions

The `nng_close` function has been renamed to [`nng_socket_close`] to make it clearer that
the object being closed is a socket.
the object being closed is a socket. A compatible `nng_close` macro is available by defining `NNG1_TRANSITION`
in your compilation environment.

## New AIO Error Code NNG_ESTOPPED

Expand Down
17 changes: 17 additions & 0 deletions include/nng/nng.h
Original file line number Diff line number Diff line change
Expand Up @@ -1608,6 +1608,23 @@ NNG_DECL int nng_tls_config_psk(
NNG_DECL int nng_tls_config_version(
nng_tls_config *, nng_tls_version, nng_tls_version);

// These transition macros may help with migration from NNG1.
// Applications should try to avoid depending on these any longer than
// necessary, as they may be removed in a future update. This is far from a
// sufficient set for a transition.
#ifdef NNG1_TRANSITION
#define nng_nop() \
do { \
} while (0)
#define nng_close(s) nng_socket_close(s)
#define nng_inproc_register() nng_nop()
#define nng_ipc_register() nng_nop()
#define nng_tls_register() nng_nop()
#define nng_ws_register() nng_nop()
#define nng_wss_register() nng_nop()
#define nng_zt_register() nng_nop()
#endif

#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit b56a1d1

Please sign in to comment.