MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / PIO_header

Function PIO_header

src/jrd/os/posix/unix.cpp:531–582  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

529
530
531void PIO_header(thread_db* tdbb, UCHAR* address, int length)
532{
533/**************************************
534 *
535 * P I O _ h e a d e r
536 *
537 **************************************
538 *
539 * Functional description
540 * Read the page header.
541 *
542 **************************************/
543 Database* const dbb = tdbb->getDatabase();
544
545 int i;
546 SINT64 bytes;
547
548 PageSpace* pageSpace = dbb->dbb_page_manager.findPageSpace(DB_PAGE_SPACE);
549 jrd_file* file = pageSpace->file;
550
551 if (file->fil_desc == -1)
552 unix_error("PIO_header", file, isc_io_read_err);
553
554 for (i = 0; i < IO_RETRY; i++)
555 {
556 if ((bytes = os_utils::pread(file->fil_desc, address, length, 0)) == length)
557 break;
558 if (bytes < 0 && !SYSCALL_INTERRUPTED(errno))
559 unix_error("read", file, isc_io_read_err);
560 if (bytes >= 0)
561 block_size_error(file, bytes);
562 }
563
564 if (i == IO_RETRY)
565 {
566 if (bytes == 0)
567 {
568#ifdef DEV_BUILD
569 fprintf(stderr, "PIO_header: an empty page read!\n");
570 fflush(stderr);
571#endif
572 }
573 else
574 {
575#ifdef DEV_BUILD
576 fprintf(stderr, "PIO_header: retry count exceeded\n");
577 fflush(stderr);
578#endif
579 unix_error("read_retry", file, isc_io_read_err);
580 }
581 }
582}
583
584// we need a class here only to return memory on shutdown and avoid
585// false memory leak reports

Callers 2

check_single_maintenanceFunction · 0.50
PAG_header_initFunction · 0.50

Calls 6

unix_errorFunction · 0.85
block_size_errorFunction · 0.85
fflushFunction · 0.85
getDatabaseMethod · 0.80
findPageSpaceMethod · 0.80
preadFunction · 0.70

Tested by

no test coverage detected