diff options
Diffstat (limited to 'zebra/zserv.h')
-rw-r--r-- | zebra/zserv.h | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/zebra/zserv.h b/zebra/zserv.h index 9d442899f..b943c246c 100644 --- a/zebra/zserv.h +++ b/zebra/zserv.h @@ -96,6 +96,14 @@ struct zserv { /* Client file descriptor. */ int sock; + /* Attributes used to permit access to zapi clients from + * other pthreads: the client has a busy counter, and a + * 'closed' flag. These attributes are managed using a + * lock, via the acquire_client() and release_client() apis. + */ + int busy_count; + bool is_closed; + /* Input/output buffer to the client. */ pthread_mutex_t ibuf_mtx; struct stream_fifo *ibuf_fifo; @@ -116,7 +124,7 @@ struct zserv { /* Event for message processing, for the main pthread */ struct thread *t_process; - /* Threads for the main pthread */ + /* Event for the main pthread */ struct thread *t_cleanup; /* This client's redistribute flag. */ @@ -306,6 +314,27 @@ struct zserv *zserv_find_client_session(uint8_t proto, unsigned short instance, uint32_t session_id); /* + * Retrieve a client object by the complete tuple of + * {protocol, instance, session}. This version supports use + * from a different pthread: the object will be returned marked + * in-use. The caller *must* release the client object with the + * release_client() api, to ensure that the in-use marker is cleared properly. + * + * Returns: + * The Zebra API client. + */ +extern struct zserv *zserv_acquire_client(uint8_t proto, + unsigned short instance, + uint32_t session_id); + +/* + * Release a client object that was acquired with the acquire_client() api. + * After this has been called, the pointer must not be used - it may be freed + * in another pthread if the client has closed. + */ +extern void zserv_release_client(struct zserv *client); + +/* * Close a client. * * Kills a client's thread, removes the client from the client list and cleans |