| 1738 | } |
| 1739 | |
| 1740 | static int bdb_queue_consume_int(bdb_state_type *bdb_state, tran_type *intran, |
| 1741 | int consumer, const void *prevfnd, int *bdberr) |
| 1742 | { |
| 1743 | struct bdb_queue_found item; |
| 1744 | uint8_t hdrbuf[QUEUE_HDR_LEN]; |
| 1745 | uint8_t *p_buf = hdrbuf, *p_buf_end = (p_buf + QUEUE_HDR_LEN); |
| 1746 | uint8_t *p_item_buf, *p_item_buf_end; |
| 1747 | size_t fragn; |
| 1748 | int rc; |
| 1749 | tran_type *tran; |
| 1750 | DBT dbt_key, dbt_data; |
| 1751 | db_recno_t recno; |
| 1752 | db_recno_t *recnos; |
| 1753 | struct bdb_queue_header hdr; |
| 1754 | |
| 1755 | if (gbl_rowlocks) { |
| 1756 | get_physical_transaction(bdb_state, intran, &tran, 0); |
| 1757 | } else |
| 1758 | tran = intran; |
| 1759 | |
| 1760 | if (!bdb_state->read_write) { |
| 1761 | *bdberr = BDBERR_READONLY; |
| 1762 | return -1; |
| 1763 | } |
| 1764 | |
| 1765 | if (!prevfnd) { |
| 1766 | *bdberr = BDBERR_BADARGS; |
| 1767 | return -1; |
| 1768 | } |
| 1769 | |
| 1770 | if (consumer < 0 || consumer >= BDBQUEUE_MAX_CONSUMERS) { |
| 1771 | *bdberr = BDBERR_BADARGS; |
| 1772 | return -1; |
| 1773 | } |
| 1774 | |
| 1775 | *bdberr = BDBERR_NOERROR; |
| 1776 | |
| 1777 | p_item_buf = (uint8_t *)prevfnd; |
| 1778 | p_item_buf_end = (p_item_buf + QUEUE_FOUND_LEN); |
| 1779 | |
| 1780 | if (!(p_item_buf = |
| 1781 | (uint8_t *)queue_found_get(&item, p_item_buf, p_item_buf_end))) { |
| 1782 | logmsg(LOGMSG_ERROR, "%s line %d: queue_found_get returns NULL\n", __func__, |
| 1783 | __LINE__); |
| 1784 | *bdberr = BDBERR_MISC; |
| 1785 | return -1; |
| 1786 | } |
| 1787 | |
| 1788 | /* Find the first fragment (header only). */ |
| 1789 | recnos = (db_recno_t *)p_item_buf; |
| 1790 | recno = ntohl(recnos[0]); |
| 1791 | bzero(&dbt_key, sizeof(dbt_key)); |
| 1792 | dbt_key.size = sizeof(db_recno_t); |
| 1793 | dbt_key.ulen = sizeof(db_recno_t); |
| 1794 | dbt_key.data = &recno; |
| 1795 | dbt_key.flags = DB_DBT_USERMEM; |
| 1796 | |
| 1797 | bzero(&dbt_data, sizeof(dbt_data)); |
no test coverage detected