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

Method getSegment

src/remote/client/interface.cpp:5588–5793  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5586
5587
5588int Blob::getSegment(CheckStatusWrapper* status, unsigned int bufferLength, void* buffer,
5589 unsigned int* segmentLength)
5590{
5591/**************************************
5592 *
5593 * g d s _ g e t _ s e g m e n t
5594 *
5595 **************************************
5596 *
5597 * Functional description
5598 * Buffer segments of a blob and pass
5599 * them one by one to the caller.
5600 *
5601 **************************************/
5602
5603 try
5604 {
5605 reset(status);
5606
5607 UCHAR* bufferPtr = static_cast<UCHAR*>(buffer);
5608
5609 // Sniff out handles, etc, and find the various blocks.
5610
5611 CHECK_HANDLE(blob, isc_bad_segstr_handle);
5612
5613 Rdb* rdb = blob->rbl_rdb;
5614 CHECK_HANDLE(rdb, isc_bad_db_handle);
5615 rem_port* port = rdb->rdb_port;
5616 RefMutexGuard portGuard(*port->port_sync, FB_FUNCTION);
5617
5618 // Build the primary packet to get the operation started.
5619
5620 PACKET* packet = &rdb->rdb_packet;
5621 P_SGMT* segment = &packet->p_sgmt;
5622 P_RESP* response = &packet->p_resp;
5623 UsePreallocatedBuffer temp(response->p_resp_data, bufferLength, bufferPtr);
5624
5625 // Handle a blob that has been created rather than opened (this should yield an error)
5626
5627 if (blob->rbl_flags & Rbl::CREATE)
5628 {
5629 packet->p_operation = op_get_segment;
5630 segment->p_sgmt_length = bufferLength;
5631 segment->p_sgmt_blob = blob->rbl_id;
5632 segment->p_sgmt_segment.cstr_length = 0;
5633
5634 send_packet(port, packet);
5635 receive_response(status, rdb, packet);
5636
5637 if (segmentLength)
5638 *segmentLength = response->p_resp_data.cstr_length;
5639 return IStatus::RESULT_OK;
5640 }
5641
5642 // New protocol -- ask for a 1K chunk of blob and
5643 // fill segment requests from it until its time to
5644 // get the next section. In other words, get a bunch,
5645 // pass it out piece by piece, then when there isn't

Callers 2

get_segmentMethod · 0.45
sendInlineBlobMethod · 0.45

Calls 7

CHECK_HANDLEFunction · 0.85
send_packetFunction · 0.85
receive_responseFunction · 0.85
isCachedMethod · 0.80
resetFunction · 0.70
getBufferMethod · 0.45
stuffExceptionMethod · 0.45

Tested by

no test coverage detected