| 1277 | } |
| 1278 | |
| 1279 | static int bdb_queue_get_int(bdb_state_type *bdb_state, int consumer, |
| 1280 | const struct bdb_queue_cursor *prevcursor, |
| 1281 | void **fnd, size_t *fnddtalen, size_t *fnddtaoff, |
| 1282 | struct bdb_queue_cursor *fndcursor, |
| 1283 | int *bdberr) |
| 1284 | { |
| 1285 | DBT dbt_key, dbt_data; |
| 1286 | DBC *dbcp; |
| 1287 | |
| 1288 | uint8_t hdrbuf[QUEUE_HDR_LEN]; |
| 1289 | uint8_t *p_buf = hdrbuf, *p_buf_end = (p_buf + sizeof(hdrbuf)); |
| 1290 | uint8_t *p_item_buf, *p_item_buf_start, *p_item_buf_end; |
| 1291 | |
| 1292 | struct bdb_queue_header hdr; |
| 1293 | int getop; |
| 1294 | db_recno_t recno; |
| 1295 | db_recno_t *recnos; |
| 1296 | struct bdb_queue_found item = {0}; |
| 1297 | size_t item_len; |
| 1298 | char *dtaptr; |
| 1299 | size_t next_frag; |
| 1300 | int rc; |
| 1301 | unsigned long long lastgenid = 0; |
| 1302 | int tmptid = 0; |
| 1303 | DB_TXN *tid = NULL; |
| 1304 | int scanmode = 0; |
| 1305 | |
| 1306 | if (consumer < 0 || consumer >= BDBQUEUE_MAX_CONSUMERS) { |
| 1307 | *bdberr = BDBERR_BADARGS; |
| 1308 | return -1; |
| 1309 | } |
| 1310 | |
| 1311 | bdb_state->qpriv->stats.n_logical_gets++; |
| 1312 | |
| 1313 | if (TXN_READ_HACK()) { |
| 1314 | rc = bdb_state->dbenv->txn_begin(bdb_state->dbenv, NULL, &tid, 0); |
| 1315 | if (rc != 0) { |
| 1316 | logmsg(LOGMSG_ERROR, "bdb_queue_get_int: txn_begin failed %d %s\n", rc, |
| 1317 | db_strerror(rc)); |
| 1318 | *bdberr = BDBERR_MISC; |
| 1319 | return -1; |
| 1320 | } |
| 1321 | tmptid = 1; |
| 1322 | } |
| 1323 | |
| 1324 | rc = bdb_state->dbp_data[0][0]->cursor(bdb_state->dbp_data[0][0], tid, |
| 1325 | &dbcp, 0); |
| 1326 | if (rc != 0) { |
| 1327 | switch (rc) { |
| 1328 | case DB_REP_HANDLE_DEAD: |
| 1329 | case DB_LOCK_DEADLOCK: |
| 1330 | bdb_state->qpriv->stats.n_get_deadlocks++; |
| 1331 | *bdberr = BDBERR_DEADLOCK; |
| 1332 | break; |
| 1333 | |
| 1334 | default: |
| 1335 | logmsg(LOGMSG_ERROR, "bdb_queue_get_int: cursor failed %d %s\n", rc, |
| 1336 | db_strerror(rc)); |
no test coverage detected