Skip to content

Commit

Permalink
jsonrpc: Add function to update all options at once.
Browse files Browse the repository at this point in the history
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
igsilya committed Dec 13, 2023
1 parent 5dfc46d commit 312e774
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/jsonrpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1337,6 +1337,15 @@ jsonrpc_session_set_dscp(struct jsonrpc_session *s, uint8_t dscp)
}
}

void
jsonrpc_session_set_options(struct jsonrpc_session *s,
const struct jsonrpc_session_options *options)
{
jsonrpc_session_set_max_backoff(s, options->max_backoff);
jsonrpc_session_set_probe_interval(s, options->probe_interval);
jsonrpc_session_set_dscp(s, options->dscp);
}

/* Sets thresholds for send backlog. If send backlog contains more than
* 'max_n_msgs' messages or is larger than 'max_backlog_bytes' bytes,
* connection will be closed (then reconnected, if that feature is enabled). */
Expand Down
8 changes: 8 additions & 0 deletions lib/jsonrpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ void jsonrpc_session_enable_reconnect(struct jsonrpc_session *);
void jsonrpc_session_force_reconnect(struct jsonrpc_session *);
void jsonrpc_session_reset_backoff(struct jsonrpc_session *);

struct jsonrpc_session_options {
int max_backoff; /* Maximum reconnection backoff, in msec. */
int probe_interval; /* Max idle time before probing, in msec. */
uint8_t dscp; /* Dscp value for passive connections. */
};

void jsonrpc_session_set_options(struct jsonrpc_session *,
const struct jsonrpc_session_options *);
void jsonrpc_session_set_max_backoff(struct jsonrpc_session *,
int max_backoff);
void jsonrpc_session_set_probe_interval(struct jsonrpc_session *,
Expand Down

0 comments on commit 312e774

Please sign in to comment.