Lines Matching defs:dctx

1249 dumptostreaminc(dns_dumpctx_t *dctx);
1252 dumpctx_destroy(dns_dumpctx_t *dctx) {
1254 dctx->magic = 0;
1255 DESTROYLOCK(&dctx->lock);
1256 dns_dbiterator_destroy(&dctx->dbiter);
1257 if (dctx->version != NULL)
1258 dns_db_closeversion(dctx->db, &dctx->version, ISC_FALSE);
1259 dns_db_detach(&dctx->db);
1260 if (dctx->task != NULL)
1261 isc_task_detach(&dctx->task);
1262 if (dctx->file != NULL)
1263 isc_mem_free(dctx->mctx, dctx->file);
1264 if (dctx->tmpfile != NULL)
1265 isc_mem_free(dctx->mctx, dctx->tmpfile);
1266 isc_mem_putanddetach(&dctx->mctx, dctx, sizeof(*dctx));
1286 dns_dumpctx_t *dctx;
1290 dctx = *dctxp;
1291 REQUIRE(DNS_DCTX_VALID(dctx));
1295 LOCK(&dctx->lock);
1296 INSIST(dctx->references != 0);
1297 dctx->references--;
1298 if (dctx->references == 0)
1300 UNLOCK(&dctx->lock);
1302 dumpctx_destroy(dctx);
1306 dns_dumpctx_version(dns_dumpctx_t *dctx) {
1307 REQUIRE(DNS_DCTX_VALID(dctx));
1308 return (dctx->version);
1312 dns_dumpctx_db(dns_dumpctx_t *dctx) {
1313 REQUIRE(DNS_DCTX_VALID(dctx));
1314 return (dctx->db);
1318 dns_dumpctx_cancel(dns_dumpctx_t *dctx) {
1319 REQUIRE(DNS_DCTX_VALID(dctx));
1321 LOCK(&dctx->lock);
1322 dctx->canceled = ISC_TRUE;
1323 UNLOCK(&dctx->lock);
1400 dns_dumpctx_t *dctx;
1403 dctx = event->ev_arg;
1404 REQUIRE(DNS_DCTX_VALID(dctx));
1405 if (dctx->canceled)
1408 result = dumptostreaminc(dctx);
1410 event->ev_arg = dctx;
1415 if (dctx->file != NULL) {
1416 tresult = closeandrename(dctx->f, result,
1417 dctx->tmpfile, dctx->file);
1421 result = flushandsync(dctx->f, result, NULL);
1422 (dctx->done)(dctx->done_arg, result);
1424 dns_dumpctx_detach(&dctx);
1428 task_send(dns_dumpctx_t *dctx) {
1431 event = isc_event_allocate(dctx->mctx, NULL, DNS_EVENT_DUMPQUANTUM,
1432 dump_quantum, dctx, sizeof(*event));
1435 isc_task_send(dctx->task, &event);
1444 dns_dumpctx_t *dctx;
1448 dctx = isc_mem_get(mctx, sizeof(*dctx));
1449 if (dctx == NULL)
1452 dctx->mctx = NULL;
1453 dctx->f = f;
1454 dctx->dbiter = NULL;
1455 dctx->db = NULL;
1456 dctx->version = NULL;
1457 dctx->done = NULL;
1458 dctx->done_arg = NULL;
1459 dctx->task = NULL;
1460 dctx->nodes = 0;
1461 dctx->first = ISC_TRUE;
1462 dctx->canceled = ISC_FALSE;
1463 dctx->file = NULL;
1464 dctx->tmpfile = NULL;
1465 dctx->format = format;
1467 dns_master_initrawheader(&dctx->header);
1469 dctx->header = *header;
1473 dctx->dumpsets = dump_rdatasets_text;
1476 dctx->dumpsets = dump_rdatasets_raw;
1479 dctx->dumpsets = dump_rdatasets_map;
1486 result = totext_ctx_init(style, &dctx->tctx);
1493 isc_stdtime_get(&dctx->now);
1494 dns_db_attach(db, &dctx->db);
1496 dctx->do_date = dns_db_iscache(dctx->db);
1498 if (dctx->format == dns_masterformat_text &&
1499 (dctx->tctx.style.flags & DNS_STYLEFLAG_REL_OWNER) != 0) {
1503 result = dns_db_createiterator(dctx->db, options, &dctx->dbiter);
1507 result = isc_mutex_init(&dctx->lock);
1511 dns_db_attachversion(dctx->db, version, &dctx->version);
1513 dns_db_currentversion(dctx->db, &dctx->version);
1514 isc_mem_attach(mctx, &dctx->mctx);
1515 dctx->references = 1;
1516 dctx->magic = DNS_DCTX_MAGIC;
1517 *dctxp = dctx;
1521 if (dctx->dbiter != NULL)
1522 dns_dbiterator_destroy(&dctx->dbiter);
1523 if (dctx->db != NULL)
1524 dns_db_detach(&dctx->db);
1525 if (dctx != NULL)
1526 isc_mem_put(mctx, dctx, sizeof(*dctx));
1531 writeheader(dns_dumpctx_t *dctx) {
1539 bufmem = isc_mem_get(dctx->mctx, initial_buffer_length);
1545 switch (dctx->format) {
1555 if (dctx->do_date) {
1556 result = dns_time32_totext(dctx->now, &buffer);
1559 fprintf(dctx->f, "$DATE %.*s\n",
1584 now32 = dctx->now;
1587 if ((dctx->header.flags & DNS_MASTERRAW_COMPAT) != 0)
1590 isc_buffer_putuint32(&buffer, dctx->format);
1595 isc_buffer_putuint32(&buffer, dctx->header.flags);
1597 dctx->header.sourceserial);
1598 isc_buffer_putuint32(&buffer, dctx->header.lastxfrin);
1604 dctx->f, NULL);
1613 isc_mem_put(dctx->mctx, buffer.base, buffer.length);
1618 dumptostreaminc(dns_dumpctx_t *dctx) {
1627 bufmem = isc_mem_get(dctx->mctx, initial_buffer_length);
1636 if (dctx->first) {
1637 CHECK(writeheader(dctx));
1645 if (dctx->format == dns_masterformat_map) {
1646 result = dns_db_serialize(dctx->db, dctx->version,
1647 dctx->f);
1651 result = dns_dbiterator_first(dctx->dbiter);
1655 dctx->first = ISC_FALSE;
1659 nodes = dctx->nodes;
1661 while (result == ISC_R_SUCCESS && (dctx->nodes == 0 || nodes--)) {
1665 result = dns_dbiterator_current(dctx->dbiter, &node, name);
1670 dns_fixedname_name(&dctx->tctx.origin_fixname);
1671 result = dns_dbiterator_origin(dctx->dbiter, origin);
1673 if ((dctx->tctx.style.flags &
1675 dctx->tctx.origin = origin;
1676 dctx->tctx.neworigin = origin;
1678 result = dns_db_allrdatasets(dctx->db, node, dctx->version,
1679 dctx->now, &rdsiter);
1681 dns_db_detachnode(dctx->db, &node);
1684 result = (dctx->dumpsets)(dctx->mctx, name, rdsiter,
1685 &dctx->tctx, &buffer, dctx->f);
1688 dns_db_detachnode(dctx->db, &node);
1691 dns_db_detachnode(dctx->db, &node);
1692 result = dns_dbiterator_next(dctx->dbiter);
1701 if (dctx->nodes != 0 && result == ISC_R_SUCCESS) {
1715 dctx->nodes = dctx->nodes * 2;
1716 if (dctx->nodes > 1000)
1717 dctx->nodes = 1000;
1719 nodes = dctx->nodes * interval;
1727 dctx->nodes = (nodes + dctx->nodes * 7) / 8;
1733 dctx, dctx->nodes);
1739 RUNTIME_CHECK(dns_dbiterator_pause(dctx->dbiter) == ISC_R_SUCCESS);
1740 isc_mem_put(dctx->mctx, buffer.base, buffer.length);
1752 dns_dumpctx_t *dctx = NULL;
1759 result = dumpctx_create(mctx, db, version, style, f, &dctx,
1763 isc_task_attach(task, &dctx->task);
1764 dctx->done = done;
1765 dctx->done_arg = done_arg;
1766 dctx->nodes = 100;
1768 result = task_send(dctx);
1770 dns_dumpctx_attach(dctx, dctxp);
1774 dns_dumpctx_detach(&dctx);
1808 dns_dumpctx_t *dctx = NULL;
1811 result = dumpctx_create(mctx, db, version, style, f, &dctx,
1816 result = dumptostreaminc(dctx);
1818 dns_dumpctx_detach(&dctx);
1893 dns_dumpctx_t *dctx = NULL;
1903 result = dumpctx_create(mctx, db, version, style, f, &dctx,
1911 isc_task_attach(task, &dctx->task);
1912 dctx->done = done;
1913 dctx->done_arg = done_arg;
1914 dctx->nodes = 100;
1915 dctx->file = file;
1917 dctx->tmpfile = tempname;
1920 result = task_send(dctx);
1922 dns_dumpctx_attach(dctx, dctxp);
1927 if (dctx != NULL)
1928 dns_dumpctx_detach(&dctx);
1961 dns_dumpctx_t *dctx = NULL;
1967 result = dumpctx_create(mctx, db, version, style, f, &dctx,
1972 result = dumptostreaminc(dctx);
1974 dns_dumpctx_detach(&dctx);