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

Method internalWrite

src/jrd/CryptoManager.cpp:1331–1373  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1329 }
1330
1331 CryptoManager::IoResult CryptoManager::internalWrite(thread_db* tdbb, FbStatusVector* sv,
1332 Ods::pag* page, IOCallback* io)
1333 {
1334 Buffer to;
1335 Ods::pag* dest = page;
1336 UCHAR savedFlags = page->pag_flags;
1337
1338 if (crypt && Ods::pag_crypt_page[page->pag_type])
1339 {
1340 fb_assert(cryptPlugin);
1341 if (!cryptPlugin)
1342 {
1343 Arg::Gds(isc_encrypt_error).copyTo(sv);
1344 return FAILED_CRYPT;
1345 }
1346
1347 FbLocalStatus ls;
1348 to[0] = page[0];
1349 cryptPlugin->encrypt(&ls, dbb.dbb_page_size - sizeof(Ods::pag),
1350 &page[1], &to[1]);
1351 if (ls->getState() & IStatus::STATE_ERRORS)
1352 {
1353 ERR_post_nothrow(&ls, sv);
1354 return FAILED_CRYPT;
1355 }
1356
1357 to->pag_flags |= Ods::crypted_page; // Mark page that is going to be written as encrypted
1358 page->pag_flags |= Ods::crypted_page; // Set the mark for page in cache as well
1359 dest = to; // Choose correct destination
1360 }
1361 else
1362 {
1363 page->pag_flags &= ~Ods::crypted_page;
1364 }
1365
1366 if (!io->callback(tdbb, sv, dest))
1367 {
1368 page->pag_flags = savedFlags;
1369 return FAILED_IO;
1370 }
1371
1372 return SUCCESS_ALL;
1373 }
1374
1375 int CryptoManager::blockingAstChangeCryptState(void* object)
1376 {

Callers

nothing calls this directly

Calls 6

GdsClass · 0.85
ERR_post_nothrowFunction · 0.85
copyToMethod · 0.45
encryptMethod · 0.45
getStateMethod · 0.45
callbackMethod · 0.45

Tested by

no test coverage detected