]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/socketengines/socketengine_select.cpp
Add support for blocking tag messages with the deaf mode.
[user/henk/code/inspircd.git] / src / socketengines / socketengine_select.cpp
index 42f634db18c35aa9c9db22f27b76261c6496b6e8..bc7b5c63fcd4aa77365eef479651e17b6fcc6cfe 100644 (file)
@@ -1,9 +1,15 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
- *   Copyright (C) 2014 Adam <Adam@anope.org>
- *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
- *   Copyright (C) 2007-2008 Craig Edwards <craigedwards@brainbox.cc>
+ *   Copyright (C) 2013-2015 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2013, 2017, 2019 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2012 Robby <robby@chatbelgie.be>
+ *   Copyright (C) 2012 ChrisTX <xpipe@hotmail.de>
+ *   Copyright (C) 2011, 2014 Adam <Adam@anope.org>
+ *   Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
+ *   Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
+ *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
+ *   Copyright (C) 2006-2008 Craig Edwards <brain@inspircd.org>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
  * redistribute it and/or modify it under the terms of the GNU General Public
@@ -35,7 +41,13 @@ namespace
 
 void SocketEngine::Init()
 {
-       MAX_DESCRIPTORS = FD_SETSIZE;
+#ifdef _WIN32
+       // Set up winsock.
+       WSADATA wsadata;
+       WSAStartup(MAKEWORD(2,2), &wsadata);
+#endif
+
+       MaxSetSize = FD_SETSIZE;
 
        FD_ZERO(&ReadSet);
        FD_ZERO(&WriteSet);
@@ -53,7 +65,11 @@ void SocketEngine::RecoverFromFork()
 bool SocketEngine::AddFd(EventHandler* eh, int event_mask)
 {
        int fd = eh->GetFd();
-       if ((fd < 0) || (fd > GetMaxFds() - 1))
+
+       if (fd < 0)
+               return false;
+
+       if (static_cast<size_t>(fd) >= GetMaxFds())
                return false;
 
        if (!SocketEngine::AddFdRef(eh))
@@ -73,7 +89,10 @@ void SocketEngine::DelFd(EventHandler* eh)
 {
        int fd = eh->GetFd();
 
-       if ((fd < 0) || (fd > GetMaxFds() - 1))
+       if (fd < 0)
+               return;
+
+       if (static_cast<size_t>(fd) >= GetMaxFds())
                return;
 
        SocketEngine::DelFdRef(eh);