blob: a88d32c99c04d852356870144a79385acf9b93e3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
/*-
* Copyright (c) 2014-present MongoDB, Inc.
* Copyright (c) 2008-2014 WiredTiger, Inc.
* All rights reserved.
*
* See the file LICENSE for redistribution information.
*/
#include "wt_internal.h"
/*
* __wt_op_timer_start --
* Start the operations timer.
*/
static inline void
__wt_op_timer_start(WT_SESSION_IMPL *session)
{
uint64_t timeout_us;
/* Timer can be configured per-transaction, and defaults to per-connection. */
if ((timeout_us = session->txn.operation_timeout_us) == 0)
timeout_us = S2C(session)->operation_timeout_us;
if (timeout_us == 0)
session->operation_start_us = session->operation_timeout_us = 0;
else {
session->operation_start_us = __wt_clock(session);
session->operation_timeout_us = timeout_us;
}
}
/*
* __wt_op_timer_stop --
* Stop the operations timer.
*/
static inline void
__wt_op_timer_stop(WT_SESSION_IMPL *session)
{
session->operation_start_us = session->operation_timeout_us = 0;
}
/*
* __wt_op_timer_fired --
* Check the operations timers.
*/
static inline bool
__wt_op_timer_fired(WT_SESSION_IMPL *session)
{
uint64_t diff, now;
if (session->operation_start_us == 0 || session->operation_timeout_us == 0)
return (false);
now = __wt_clock(session);
diff = WT_CLOCKDIFF_US(now, session->operation_start_us);
return (diff > session->operation_timeout_us);
}
|