| 152 | } |
| 153 | |
| 154 | void *deadlockdetect_thread(void *arg) |
| 155 | { |
| 156 | bdb_state_type *bdb_state; |
| 157 | int aborted; |
| 158 | |
| 159 | bdb_state = (bdb_state_type *)arg; |
| 160 | |
| 161 | if (bdb_state->parent) |
| 162 | bdb_state = bdb_state->parent; |
| 163 | |
| 164 | while (!bdb_state->after_llmeta_init_done) |
| 165 | sleep(1); |
| 166 | |
| 167 | thread_started("bdb deadlockdetect"); |
| 168 | |
| 169 | bdb_thread_event(bdb_state, 1); |
| 170 | |
| 171 | while (1) { |
| 172 | int rc; |
| 173 | int policy; |
| 174 | |
| 175 | BDB_READLOCK("deadlockdetect thread"); |
| 176 | |
| 177 | policy = DB_LOCK_MINWRITE; |
| 178 | |
| 179 | if (bdb_state->attr->deadlock_most_writes) |
| 180 | policy = DB_LOCK_MAXWRITE; |
| 181 | if (bdb_state->attr->deadlock_youngest_ever) |
| 182 | policy = DB_LOCK_YOUNGEST_EVER; |
| 183 | |
| 184 | if (db_is_exiting()) { |
| 185 | logmsg(LOGMSG_DEBUG, "deadlockdetect_thread: exiting\n"); |
| 186 | |
| 187 | BDB_RELLOCK(); |
| 188 | bdb_thread_event(bdb_state, 0); |
| 189 | pthread_exit(NULL); |
| 190 | } |
| 191 | |
| 192 | aborted = 0; |
| 193 | |
| 194 | rc = bdb_state->dbenv->lock_detect(bdb_state->dbenv, 0, policy, |
| 195 | &aborted); |
| 196 | |
| 197 | if (rc != 0) { |
| 198 | logmsg(LOGMSG_FATAL, "lock_detect rc %d\n", rc); |
| 199 | exit(1); |
| 200 | } |
| 201 | |
| 202 | BDB_RELLOCK(); |
| 203 | |
| 204 | if (aborted != 0) /* loop hard if aborted */ |
| 205 | poll(0, 0, bdb_state->attr->deadlockdetectms); |
| 206 | else |
| 207 | sleep(1); |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | void *master_lease_thread(void *arg) |
nothing calls this directly
no test coverage detected