| 203 | } |
| 204 | |
| 205 | Status LibCache::CheckSymbolExists(const string& hdfs_lib_file, LibType type, |
| 206 | const string& symbol, bool quiet, time_t* mtime) { |
| 207 | if (type == TYPE_SO) { |
| 208 | void* dummy_ptr = nullptr; |
| 209 | LibCacheEntry* entry = nullptr; |
| 210 | RETURN_IF_ERROR( |
| 211 | GetSoFunctionPtr(hdfs_lib_file, symbol, -1, &dummy_ptr, &entry, quiet)); |
| 212 | *mtime = -1; |
| 213 | if (entry != nullptr) { |
| 214 | *mtime = entry->last_mod_time; |
| 215 | // done holding this entry, so decrement its use count. |
| 216 | DecrementUseCount(entry); |
| 217 | } |
| 218 | return Status::OK(); |
| 219 | } else if (type == TYPE_IR) { |
| 220 | unique_lock<mutex> lock; |
| 221 | LibCacheEntry* entry = nullptr; |
| 222 | RETURN_IF_ERROR(GetCacheEntry(hdfs_lib_file, type, -1, &lock, &entry)); |
| 223 | DCHECK(entry != nullptr); |
| 224 | DCHECK_EQ(entry->type, TYPE_IR); |
| 225 | if (entry->symbols.find(symbol) == entry->symbols.end()) { |
| 226 | stringstream ss; |
| 227 | ss << "Symbol '" << symbol << "' does not exist in module: " << hdfs_lib_file |
| 228 | << " (local path: " << entry->local_path << ")"; |
| 229 | return quiet ? Status::Expected(ss.str()) : Status(ss.str()); |
| 230 | } |
| 231 | *mtime = entry->last_mod_time; |
| 232 | return Status::OK(); |
| 233 | } else if (type == TYPE_JAR) { |
| 234 | // TODO: figure out how to inspect contents of jars |
| 235 | unique_lock<mutex> lock; |
| 236 | LibCacheEntry* entry = nullptr; |
| 237 | RETURN_IF_ERROR(GetCacheEntry(hdfs_lib_file, type, -1, &lock, &entry)); |
| 238 | *mtime = entry->last_mod_time; |
| 239 | return Status::OK(); |
| 240 | } else { |
| 241 | DCHECK(false); |
| 242 | return Status("Shouldn't get here."); |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | void LibCache::SetNeedsRefresh(const string& hdfs_lib_file) { |
| 247 | unique_lock<mutex> lib_cache_lock(lock_); |