diff options
author | Attila Molnar <attilamolnar@hush.com> | 2014-02-08 22:20:05 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2014-02-08 22:20:05 +0100 |
commit | dd43a49fc43c1ec07b41e19a8bd3649fadccad70 (patch) | |
tree | 18beafde2663779f5c3f5de12ceb8da948594015 /src/socketengines | |
parent | ed6176383eef5de23a62c7de70b58b8d80239005 (diff) |
Move variables in socketengines
Move timespec to DispatchEvents() in kqueue, there is no reason for it to be a member variable
Diffstat (limited to 'src/socketengines')
-rw-r--r-- | src/socketengines/socketengine_epoll.cpp | 4 | ||||
-rw-r--r-- | src/socketengines/socketengine_kqueue.cpp | 4 | ||||
-rw-r--r-- | src/socketengines/socketengine_poll.cpp | 7 |
3 files changed, 6 insertions, 9 deletions
diff --git a/src/socketengines/socketengine_epoll.cpp b/src/socketengines/socketengine_epoll.cpp index 800cc7657..34f943dee 100644 --- a/src/socketengines/socketengine_epoll.cpp +++ b/src/socketengines/socketengine_epoll.cpp @@ -185,8 +185,6 @@ void EPollEngine::DelFd(EventHandler* eh) int EPollEngine::DispatchEvents() { - socklen_t codesize = sizeof(int); - int errcode; int i = epoll_wait(EngineHandle, &events[0], events.size(), 1000); ServerInstance->UpdateTime(); @@ -216,6 +214,8 @@ int EPollEngine::DispatchEvents() { ErrorEvents++; /* Get error number */ + socklen_t codesize = sizeof(int); + int errcode; if (getsockopt(ev.data.fd, SOL_SOCKET, SO_ERROR, &errcode, &codesize) < 0) errcode = errno; eh->HandleEvent(EVENT_ERROR, errcode); diff --git a/src/socketengines/socketengine_kqueue.cpp b/src/socketengines/socketengine_kqueue.cpp index 53bd741f0..517451237 100644 --- a/src/socketengines/socketengine_kqueue.cpp +++ b/src/socketengines/socketengine_kqueue.cpp @@ -37,9 +37,6 @@ private: /** These are used by kqueue() to hold socket events */ std::vector<struct kevent> ke_list; - /** This is a specialised time value used by kqueue() - */ - struct timespec ts; public: /** Create a new KQueueEngine */ @@ -203,6 +200,7 @@ void KQueueEngine::OnSetEvent(EventHandler* eh, int old_mask, int new_mask) int KQueueEngine::DispatchEvents() { + struct timespec ts; ts.tv_nsec = 0; ts.tv_sec = 1; diff --git a/src/socketengines/socketengine_poll.cpp b/src/socketengines/socketengine_poll.cpp index 53953626f..323de422b 100644 --- a/src/socketengines/socketengine_poll.cpp +++ b/src/socketengines/socketengine_poll.cpp @@ -185,13 +185,10 @@ void PollEngine::DelFd(EventHandler* eh) int PollEngine::DispatchEvents() { int i = poll(&events[0], CurrentSetSize, 1000); - int index; - socklen_t codesize = sizeof(int); - int errcode; int processed = 0; ServerInstance->UpdateTime(); - for (index = 0; index < CurrentSetSize && processed < i; index++) + for (int index = 0; index < CurrentSetSize && processed < i; index++) { struct pollfd& pfd = events[index]; @@ -215,6 +212,8 @@ int PollEngine::DispatchEvents() if (revents & POLLERR) { // Get error number + socklen_t codesize = sizeof(int); + int errcode; if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &errcode, &codesize) < 0) errcode = errno; eh->HandleEvent(EVENT_ERROR, errcode); |