diff options
| author | Werner Koch <[email protected]> | 2019-06-07 10:10:40 +0000 |
|---|---|---|
| committer | Werner Koch <[email protected]> | 2019-06-07 10:10:40 +0000 |
| commit | 92883efe7176c2022e25e913c1d2f40c35a0754a (patch) | |
| tree | 3b6163237f6878a494171f05f6b6d2dd1db0d511 /src/context.h | |
| parent | core: Replace the posix close notify mechanism by a new generic one. (diff) | |
| download | gpgme-92883efe7176c2022e25e913c1d2f40c35a0754a.tar.gz gpgme-92883efe7176c2022e25e913c1d2f40c35a0754a.zip | |
core: Introduce a context serial number.
* src/context.h: Include stdint.h.
(struct gpgme_context): Add field 'serial'.
(CTXSERIAL): New.
* src/gpgme.c: (last_ctx_serial): New.
(gpgme_new): Set serial.
* src/gpgme.c: Change trace calls to use the serial.
* src/wait.c (_gpgme_add_io_cb): Ditto
(_gpgme_remove_io_cb): Ditto.
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'src/context.h')
| -rw-r--r-- | src/context.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/context.h b/src/context.h index d65bf9b5..076d0731 100644 --- a/src/context.h +++ b/src/context.h @@ -21,6 +21,8 @@ #ifndef CONTEXT_H #define CONTEXT_H +#include <stdint.h> + #include "gpgme.h" #include "engine.h" #include "wait.h" @@ -78,6 +80,12 @@ struct gpgme_context { DECLARE_LOCK (lock); + /* The unique serial number of this context object. This is used + * for a weak reference of the context. Using the address of the + * context is not always possible becuase it might have already been + * freed and reused. */ + uint64_t serial; + /* True if the context was canceled asynchronously. */ int canceled; @@ -186,4 +194,9 @@ struct gpgme_context struct gpgme_io_cbs io_cbs; }; + +/* Macro to retrieve the serial number. Returns 0 if CTX is NULL. */ +#define CTXSERIAL(ctx) (ctx? (unsigned long)ctx->serial : 0) + + #endif /* CONTEXT_H */ |
