Skip to content

Commit

Permalink
session server UPDATE set start time to timespec
Browse files Browse the repository at this point in the history
  • Loading branch information
roman committed Nov 3, 2023
1 parent f60c87e commit ca3c9dd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/session_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,8 @@ struct nc_session {
} client;
struct {
/* server side only data */
time_t session_start; /**< real time the session was created */
time_t last_rpc; /**< monotonic time (seconds) the last RPC was received on this session */
struct timespec session_start; /**< real time the session was created */
time_t last_rpc; /**< monotonic time (seconds) the last RPC was received on this session */

pthread_mutex_t ntf_status_lock; /**< lock for ntf_status */
uint32_t ntf_status; /**< flag (count) whether the session is subscribed to notifications */
Expand Down
14 changes: 8 additions & 6 deletions src/session_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ nc_accept_inout(int fdin, int fdout, const char *username, const struct ly_ctx *
nc_timeouttime_get(&ts_cur, 0);
(*session)->opts.server.last_rpc = ts_cur.tv_sec;
nc_realtime_get(&ts_cur);
(*session)->opts.server.session_start = ts_cur.tv_sec;
(*session)->opts.server.session_start = ts_cur;

(*session)->status = NC_STATUS_RUNNING;

Expand Down Expand Up @@ -2188,7 +2188,7 @@ nc_accept(int timeout, const struct ly_ctx *ctx, struct nc_session **session)
nc_timeouttime_get(&ts_cur, 0);
(*session)->opts.server.last_rpc = ts_cur.tv_sec;
nc_realtime_get(&ts_cur);
(*session)->opts.server.session_start = ts_cur.tv_sec;
(*session)->opts.server.session_start = ts_cur;
(*session)->status = NC_STATUS_RUNNING;

return msgtype;
Expand Down Expand Up @@ -2363,7 +2363,7 @@ nc_connect_ch_endpt(struct nc_ch_endpt *endpt, nc_server_ch_session_acquire_ctx_
nc_timeouttime_get(&ts_cur, 0);
(*session)->opts.server.last_rpc = ts_cur.tv_sec;
nc_realtime_get(&ts_cur);
(*session)->opts.server.session_start = ts_cur.tv_sec;
(*session)->opts.server.session_start = ts_cur;
(*session)->status = NC_STATUS_RUNNING;

return msgtype;
Expand Down Expand Up @@ -2783,14 +2783,16 @@ nc_connect_ch_client_dispatch(const char *client_name, nc_server_ch_session_acqu

#endif /* NC_ENABLED_SSH_TLS */

API time_t
API struct timespec
nc_session_get_start_time(const struct nc_session *session)
{
NC_CHECK_ARG_RET(session, session, 0);
struct timespec fail = {0};

NC_CHECK_ARG_RET(session, session, fail);

if (session->side != NC_SERVER) {
ERRARG(session, "session");
return 0;
return fail;
}

return session->opts.server.session_start;
Expand Down
2 changes: 1 addition & 1 deletion src/session_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ void nc_server_tls_set_verify_clb(int (*verify_clb)(const struct nc_session *ses
* @param[in] session Session to get the information from.
* @return Session start time.
*/
time_t nc_session_get_start_time(const struct nc_session *session);
struct timespec nc_session_get_start_time(const struct nc_session *session);

/**
* @brief Increase session notification subscription flag count.
Expand Down
4 changes: 2 additions & 2 deletions src/session_server_ssh.c
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,7 @@ nc_session_accept_ssh_channel(struct nc_session *orig_session, struct nc_session
}

nc_realtime_get(&ts_cur);
new_session->opts.server.session_start = ts_cur.tv_sec;
new_session->opts.server.session_start = ts_cur;
nc_timeouttime_get(&ts_cur, 0);
new_session->opts.server.last_rpc = ts_cur.tv_sec;
new_session->status = NC_STATUS_RUNNING;
Expand Down Expand Up @@ -1396,7 +1396,7 @@ nc_ps_accept_ssh_channel(struct nc_pollsession *ps, struct nc_session **session)
}

nc_realtime_get(&ts_cur);
new_session->opts.server.session_start = ts_cur.tv_sec;
new_session->opts.server.session_start = ts_cur;
nc_timeouttime_get(&ts_cur, 0);
new_session->opts.server.last_rpc = ts_cur.tv_sec;
new_session->status = NC_STATUS_RUNNING;
Expand Down

0 comments on commit ca3c9dd

Please sign in to comment.