Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ option(ENABLE_COMPLY_WITH_ORAN_WG11 "Comply with the O-RAN WG11 security spec (e
option(BUILD_SHARED_LIBS "By default, shared libs are enabled. Turn off for a static build." ON)
set(READ_INACTIVE_TIMEOUT 20 CACHE STRING "Maximum number of seconds waiting for new data once some data have arrived")
set(READ_ACTIVE_TIMEOUT 300 CACHE STRING "Maximum number of seconds for receiving a full message")
set(MAX_PSPOLL_THREAD_COUNT 6 CACHE STRING "Maximum number of threads that could simultaneously access a ps_poll structure")
set(TRANSPORT_HANDSHAKE_TIMEOUT 10 CACHE STRING "SSH key exchange and TLS handshake timeout in seconds")
set(MESSAGE_MAX_SIZE 1048576 CACHE STRING "Maximum size of a message in kB")
set(TIMEOUT_STEP 100 CACHE STRING "Number of microseconds tasks are repeated until timeout elapses")
Expand Down
12 changes: 0 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,18 +183,6 @@ to arrive in its entirety once a beginning is read. The default is 300 (5 minute
$ cmake -D READ_ACTIVE_TIMEOUT:String="300" ..
```

### PSPoll Thread Count

This value limits the maximum number of threads that can concurrently access
(wait for access) a single pspoll structure. To simplify, how many threads could
simultaneously call a function whose parameter is one and the same pspoll structure.
If using **netopeer2-server**, it will warn that this value needs to be adjusted if
too small.

```
$ cmake -D MAX_PSPOLL_THREAD_COUNT:String="6" ..
```

### Code Coverage

Based on the tests run, it is possible to generate code coverage report. But
Expand Down
1 change: 0 additions & 1 deletion libnetconf2.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ Version: @LIBNETCONF2_VERSION@
Libs: -L${libdir} -lnetconf2
Cflags: -I${includedir}

LN2_MAX_THREAD_COUNT=@MAX_PSPOLL_THREAD_COUNT@
LN2_SCHEMAS_DIR=@YANG_MODULE_DIR@
5 changes: 0 additions & 5 deletions src/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@
*/
#define NC_READ_ACT_TIMEOUT @READ_ACTIVE_TIMEOUT@

/*
* pspoll structure queue size (also found in nc_server.h)
*/
#define NC_PS_QUEUE_SIZE @MAX_PSPOLL_THREAD_COUNT@

/*
* Timeout in msec for transport layer connection handshake/key exchange.
* It can be quite a lot on slow machines (waiting for TLS cert-to-name resolution, SSH key cryptography, ...).
Expand Down
42 changes: 34 additions & 8 deletions src/session_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,15 @@ extern struct nc_server_opts server_opts;
#define NC_SESSION_FREE_SSH_POLL_EOF_TIMEOUT 100

/**
* Timeout in msec for a thread to wait for its turn to work with a pollsession structure.
* Initial number of threads the queue of a pollsession structure is allocated for, it grows
* on demand.
*/
#define NC_PS_QUEUE_SIZE 8

/**
* Timeout in msec for a preempting thread to wait for its turn to work with a pollsession
* structure before the queue is considered jammed. Poll threads may wait behind several other
* poll threads, so they may legitimately wait longer than this.
*/
#define NC_PS_QUEUE_TIMEOUT 5000

Expand Down Expand Up @@ -1225,11 +1233,12 @@ struct nc_pollsession {
uint16_t session_count;
uint16_t last_event_session;

pthread_cond_t cond;
pthread_mutex_t lock;
uint8_t queue[NC_PS_QUEUE_SIZE]; /**< round buffer, queue is empty when queue_len == 0 */
uint8_t queue_begin; /**< queue starts on queue[queue_begin] */
uint8_t queue_len; /**< queue ends on queue[(queue_begin + queue_len - 1) % NC_PS_QUEUE_SIZE] */
pthread_cond_t cond; /**< broadcasted whenever a pollsession turn is given up */
pthread_mutex_t lock; /**< lock for the cond and the queue */
pthread_t *queue; /**< round buffer, queue is empty when queue_len == 0 */
uint8_t queue_size; /**< allocated size of queue, 0 until the first thread queues up */
uint8_t queue_begin; /**< queue starts on queue[queue_begin], that thread has the turn */
uint8_t queue_len; /**< queue ends on queue[(queue_begin + queue_len - 1) % queue_size] */
};

struct nc_ntf_thread_arg {
Expand Down Expand Up @@ -1518,9 +1527,26 @@ int nc_mutex_lock(pthread_mutex_t *mutex, int timeout, const char *func_name);
*/
void nc_mutex_unlock(pthread_mutex_t *mutex, const char *func_name);

int nc_ps_lock(struct nc_pollsession *ps, uint8_t *id, const char *func);
/**
* @brief Wait for the turn of this thread to work with a pollsession.
*
* @param[in,out] ps Pollsession structure.
* @param[in] preempt Whether this thread preempts the poll thread that currently has the turn,
* meaning it is queued up in front of all the threads waiting for it. Set for every operation that
* only walks the session array, clear for ::nc_ps_poll() which polls for a whole poll interval.
* @param[in] func Caller function name for logging.
* @return 0 on success, -1 on error.
*/
int nc_ps_lock(struct nc_pollsession *ps, int preempt, const char *func);

int nc_ps_unlock(struct nc_pollsession *ps, uint8_t id, const char *func);
/**
* @brief Give up the pollsession turn of this thread.
*
* @param[in,out] ps Pollsession structure.
* @param[in] func Caller function name for logging.
* @return 0 on success, -1 on error.
*/
int nc_ps_unlock(struct nc_pollsession *ps, const char *func);

int nc_client_session_new_ctx(struct nc_session *session, struct ly_ctx *ctx);

Expand Down
Loading