| 8112 | |
| 8113 | |
| 8114 | void JRD_enum_attachments(PathNameList* dbList, ULONG& atts, ULONG& dbs, ULONG& svcs) |
| 8115 | { |
| 8116 | /************************************** |
| 8117 | * |
| 8118 | * J R D _ e n u m _ a t t a c h m e n t s |
| 8119 | * |
| 8120 | ************************************** |
| 8121 | * |
| 8122 | * Functional description |
| 8123 | * Count the number of active databases and |
| 8124 | * attachments. |
| 8125 | * |
| 8126 | **************************************/ |
| 8127 | atts = dbs = svcs = 0; |
| 8128 | |
| 8129 | try |
| 8130 | { |
| 8131 | PathNameList dbFiles(*getDefaultMemoryPool()); |
| 8132 | |
| 8133 | MutexLockGuard guard(databases_mutex, FB_FUNCTION); |
| 8134 | |
| 8135 | // Zip through the list of databases and count the number of local |
| 8136 | // connections. If buf is not NULL then copy all the database names |
| 8137 | // that will fit into it. |
| 8138 | |
| 8139 | for (Database* dbb = databases; dbb; dbb = dbb->dbb_next) |
| 8140 | { |
| 8141 | SyncLockGuard dbbGuard(&dbb->dbb_sync, SYNC_SHARED, "JRD_enum_attachments"); |
| 8142 | |
| 8143 | if (!(dbb->dbb_flags & DBB_bugcheck)) |
| 8144 | { |
| 8145 | bool found = false; // look for user attachments only |
| 8146 | for (const Jrd::Attachment* attach = dbb->dbb_attachments; attach; |
| 8147 | attach = attach->att_next) |
| 8148 | { |
| 8149 | if (!(attach->att_flags & ATT_security_db)) |
| 8150 | { |
| 8151 | atts++; |
| 8152 | found = true; |
| 8153 | } |
| 8154 | } |
| 8155 | |
| 8156 | if (found && !dbFiles.exist(dbb->dbb_filename)) |
| 8157 | dbFiles.add(dbb->dbb_filename); |
| 8158 | } |
| 8159 | } |
| 8160 | |
| 8161 | dbs = (ULONG) dbFiles.getCount(); |
| 8162 | svcs = Service::totalCount(); |
| 8163 | |
| 8164 | if (dbList) |
| 8165 | { |
| 8166 | *dbList = dbFiles; |
| 8167 | } |
| 8168 | } |
| 8169 | catch (const Exception&) |
| 8170 | { |
| 8171 | // Here we ignore possible errors from databases_mutex. |