26 #include <unordered_map>
29 #include <netinet/in.h>
52 void create(
int fd,
struct sockaddr_in &addr, OpenFileDataPtr &fdata) {
53 std::lock_guard<std::mutex> lock(
m_mutex);
58 bool get(
int fd, OpenFileDataPtr &fdata) {
59 std::lock_guard<std::mutex> lock(
m_mutex);
62 fdata = (*iter).second;
68 bool remove(
int fd, OpenFileDataPtr &fdata) {
69 std::lock_guard<std::mutex> lock(
m_mutex);
72 fdata = (*iter).second;
80 std::lock_guard<std::mutex> lock(
m_mutex);
87 std::lock_guard<std::mutex> lock(
m_mutex);
91 if ((*iter).second->addr.sin_family == addr.sin_family &&
92 (*iter).second->addr.sin_port == addr.sin_port &&
93 (*iter).second->addr.sin_addr.s_addr == addr.sin_addr.s_addr) {
94 FileMap::iterator del_it = iter;
95 HT_INFOF(
"Removing handle %d from open file map because of lost "
96 "owning client connection", (*iter).first);
106 std::lock_guard<std::mutex> lock(
m_mutex);
112 typedef std::unordered_map<int, OpenFileDataPtr>
FileMap;
std::unordered_map< int, OpenFileDataPtr > FileMap
std::shared_ptr< OpenFileData > OpenFileDataPtr
void remove_all(struct sockaddr_in &addr)
Logging routines and macros.
#define HT_INFOF(msg,...)
void create(int fd, struct sockaddr_in &addr, OpenFileDataPtr &fdata)