* | Inspire Internet Relay Chat Daemon |
* +------------------------------------+
*
- * InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ * InspIRCd: (C) 2002-2010 InspIRCd Development Team
* See: http://wiki.inspircd.org/Credits
*
* This program is free but copyrighted software; see
*/
#include "inspircd_config.h"
-#ifndef CONFIG_USE_IOCP
#include "inspircd.h"
-#ifndef WINDOWS
-#include <sys/select.h>
-#endif // WINDOWS
-
-#ifndef __SOCKETENGINE_SELECT__
-#define __SOCKETENGINE_SELECT__
+#include "socketengine.h"
-#include <vector>
-#include <string>
-#include <map>
#ifndef WINDOWS
#include <sys/select.h>
#endif // WINDOWS
-#include "inspircd.h"
-#include "socketengine.h"
/** A specialisation of the SocketEngine class, designed to use traditional select().
*/
*/
virtual ~SelectEngine();
virtual bool AddFd(EventHandler* eh, int event_mask);
- virtual bool DelFd(EventHandler* eh, bool force = false);
+ virtual void DelFd(EventHandler* eh);
void OnSetEvent(EventHandler* eh, int, int);
virtual int DispatchEvents();
virtual std::string GetName();
};
-#endif
-
-
-
SelectEngine::SelectEngine()
{
MAX_DESCRIPTORS = FD_SETSIZE;
return true;
}
-bool SelectEngine::DelFd(EventHandler* eh, bool force)
+void SelectEngine::DelFd(EventHandler* eh)
{
int fd = eh->GetFd();
if ((fd < 0) || (fd > GetMaxFds() - 1))
- return false;
+ return;
CurrentSetSize--;
ref[fd] = NULL;
ServerInstance->Logs->Log("SOCKET",DEBUG,"Remove file descriptor: %d", fd);
- return true;
}
void SelectEngine::OnSetEvent(EventHandler* eh, int old_mask, int new_mask)
FD_ZERO(&rfdset);
FD_ZERO(&errfdset);
- /* Populate the select FD sets (this is why select sucks compared to epoll, kqueue, IOCP) */
+ /* Populate the select FD sets (this is why select sucks compared to epoll, kqueue) */
for (unsigned int i = 0; i < FD_SETSIZE; i++)
{
EventHandler* eh = ref[i];
tval.tv_usec = 0;
sresult = select(FD_SETSIZE, &rfdset, &wfdset, &errfdset, &tval);
+ ServerInstance->UpdateTime();
/* Nothing to process this time around */
if (sresult < 1)
ReadEvents++;
SetEventMask(ev, ev->GetEventMask() & ~FD_READ_WILL_BLOCK);
ev->HandleEvent(EVENT_READ);
+ if (ev != ref[i])
+ continue;
}
if (FD_ISSET (i, &wfdset))
{
{
return new SelectEngine;
}
-#endif
\ No newline at end of file