-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDnsSocket.cpp
More file actions
36 lines (32 loc) · 929 Bytes
/
DnsSocket.cpp
File metadata and controls
36 lines (32 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "DnsSocket.hpp"
#include "Dns.hpp"
#include <iostream>
DnsSocket::DnsSocket(const int &fd) :
EpollObject(fd,EpollObject::Kind::Kind_Dns)
{
this->kind=EpollObject::Kind::Kind_Dns;
//add to event loop
epoll_event event;
event.data.ptr = this;
event.events = EPOLLIN;
#ifdef DEBUGFASTCGI
std::cerr << "EPOLL_CTL_ADD: " << event.data.ptr << " " << __FILE__ << ":" << __LINE__ << std::endl;
#endif
if((uint64_t)event.data.ptr<100)
{
std::cerr << "EPOLL_CTL_ADD: " << event.data.ptr << " " << __FILE__ << ":" << __LINE__ << " (abort)" << std::endl;
abort();
}
if(epoll_ctl(epollfd,EPOLL_CTL_ADD, fd, &event) == -1)
{
std::cerr << "epoll_ctl failed to add server errno: " << errno << std::endl;
abort();
}
}
DnsSocket::~DnsSocket()
{
}
void DnsSocket::parseEvent(const epoll_event &event)
{
Dns::dns->parseEvent(event,this);
}