Changeset 706
- Timestamp:
- 12/01/11 12:29:46 (6 months ago)
- Location:
- trunk/sources/thelib
- Files:
-
- 3 added
- 10 edited
-
include/netio/epoll/iohandler.h (modified) (2 diffs)
-
include/netio/epoll/iohandlermanager.h (modified) (4 diffs)
-
include/netio/fdstats.h (added)
-
include/netio/iohandlertype.h (added)
-
include/netio/kqueue/iohandler.h (modified) (2 diffs)
-
include/netio/kqueue/iohandlermanager.h (modified) (4 diffs)
-
include/netio/netio.h (modified) (2 diffs)
-
include/netio/select/iohandler.h (modified) (2 diffs)
-
include/netio/select/iohandlermanager.h (modified) (5 diffs)
-
src/netio/epoll/iohandlermanager.cpp (modified) (6 diffs)
-
src/netio/fdstats.cpp (added)
-
src/netio/kqueue/iohandlermanager.cpp (modified) (6 diffs)
-
src/netio/select/iohandlermanager.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/thelib/include/netio/epoll/iohandler.h
r637 r706 1 /* 1 /* 2 2 * Copyright (c) 2010, 3 3 * Gavriloaie Eugen-Andrei (shiretu@gmail.com) … … 24 24 #include "common.h" 25 25 #include "netio/epoll/iohandlermanagertoken.h" 26 27 typedef enum _IOHandlerType { 28 IOHT_ACCEPTOR, 29 IOHT_TCP_CONNECTOR, 30 IOHT_TCP_CARRIER, 31 IOHT_UDP_CARRIER, 32 IOHT_INBOUNDNAMEDPIPE_CARRIER, 33 IOHT_TIMER, 34 IOHT_STDIO 35 } IOHandlerType; 26 #include "netio/iohandlertype.h" 36 27 37 28 class BaseProtocol; -
trunk/sources/thelib/include/netio/epoll/iohandlermanager.h
r614 r706 1 /* 1 /* 2 2 * Copyright (c) 2010, 3 3 * Gavriloaie Eugen-Andrei (shiretu@gmail.com) … … 24 24 #include "common.h" 25 25 #include "netio/epoll/iohandlermanagertoken.h" 26 #include "netio/fdstats.h" 26 27 27 28 class IOHandler; … … 41 42 static TimersManager *_pTimersManager; 42 43 static struct epoll_event _dummy; 44 static FdStats _fdStats; 43 45 public: 44 46 static map<uint32_t, IOHandler *> & GetActiveHandlers(); … … 51 53 static void RegisterIOHandler(IOHandler *pIOHandler); 52 54 static void UnRegisterIOHandler(IOHandler *pIOHandler); 55 static int CreateRawUDPSocket(); 56 static void CloseRawUDPSocket(int socket); 53 57 static bool EnableReadData(IOHandler *pIOHandler); 54 58 static bool DisableReadData(IOHandler *pIOHandler, bool ignoreError = false); -
trunk/sources/thelib/include/netio/kqueue/iohandler.h
r637 r706 1 /* 1 /* 2 2 * Copyright (c) 2010, 3 3 * Gavriloaie Eugen-Andrei (shiretu@gmail.com) … … 24 24 #include "common.h" 25 25 #include "netio/kqueue/iohandlermanagertoken.h" 26 27 typedef enum _IOHandlerType { 28 IOHT_ACCEPTOR, 29 IOHT_TCP_CONNECTOR, 30 IOHT_TCP_CARRIER, 31 IOHT_UDP_CARRIER, 32 IOHT_INBOUNDNAMEDPIPE_CARRIER, 33 IOHT_TIMER, 34 IOHT_STDIO 35 } IOHandlerType; 26 #include "netio/iohandlertype.h" 36 27 37 28 class BaseProtocol; -
trunk/sources/thelib/include/netio/kqueue/iohandlermanager.h
r617 r706 1 /* 1 /* 2 2 * Copyright (c) 2010, 3 3 * Gavriloaie Eugen-Andrei (shiretu@gmail.com) … … 24 24 #include "common.h" 25 25 #include "netio/kqueue/iohandlermanagertoken.h" 26 #include "netio/fdstats.h" 26 27 27 28 class IOHandler; … … 40 41 static int32_t _pendingEventsCount; 41 42 static int32_t _eventsSize; 43 static FdStats _fdStats; 42 44 #ifndef HAS_KQUEUE_TIMERS 43 45 static struct timespec _timeout; … … 61 63 static void RegisterIOHandler(IOHandler *pIOHandler); 62 64 static void UnRegisterIOHandler(IOHandler *pIOHandler); 65 static int CreateRawUDPSocket(); 66 static void CloseRawUDPSocket(int socket); 63 67 static bool EnableReadData(IOHandler *pIOHandler); 64 68 static bool DisableReadData(IOHandler *pIOHandler, bool ignoreError = false); -
trunk/sources/thelib/include/netio/netio.h
r177 r706 1 /* 1 /* 2 2 * Copyright (c) 2010, 3 3 * Gavriloaie Eugen-Andrei (shiretu@gmail.com) … … 21 21 #ifndef _NETIO_H 22 22 #define _NETIO_H 23 24 #include "netio/iohandlertype.h" 25 #include "netio/fdstats.h" 23 26 24 27 #ifdef NET_KQUEUE -
trunk/sources/thelib/include/netio/select/iohandler.h
r637 r706 1 /* 1 /* 2 2 * Copyright (c) 2010, 3 3 * Gavriloaie Eugen-Andrei (shiretu@gmail.com) … … 23 23 24 24 #include "common.h" 25 26 /*! 27 IO Handler types. 28 */ 29 typedef enum _IOHandlerType { 30 IOHT_ACCEPTOR, 31 IOHT_TCP_CONNECTOR, 32 IOHT_TCP_CARRIER, 33 IOHT_UDP_CARRIER, 34 IOHT_INBOUNDNAMEDPIPE_CARRIER, 35 IOHT_TIMER, 36 IOHT_STDIO 37 } IOHandlerType; 25 #include "netio/iohandlertype.h" 38 26 39 27 class BaseProtocol; -
trunk/sources/thelib/include/netio/select/iohandlermanager.h
r614 r706 1 /* 1 /* 2 2 * Copyright (c) 2010, 3 3 * Gavriloaie Eugen-Andrei (shiretu@gmail.com) … … 24 24 25 25 #include "common.h" 26 #include "netio/fdstats.h" 26 27 27 28 class IOHandler; … … 39 40 static map<int32_t, map<uint32_t, uint8_t> > _fdState; 40 41 static bool _isShuttingDown; 42 static FdStats _fdStats; 41 43 public: 42 44 static map<uint32_t, IOHandler *> & GetActiveHandlers(); … … 79 81 static void UnRegisterIOHandler(IOHandler *pIOHandler); 80 82 83 static int CreateRawUDPSocket(); 84 static void CloseRawUDPSocket(int socket); 85 81 86 /*! 82 @brief Enables the IO handler to read data. 87 @brief Enables the IO handler to read data. 83 88 @discussion This assigns a FDSTATE_READ_ENABLED to the inbound file descriptor's state 84 89 */ … … 91 96 92 97 /*! 93 @brief Enables the IO handler to write data. 98 @brief Enables the IO handler to write data. 94 99 @discussion This assigns a FDSTATE_WRITE_ENABLED to the inbound file descriptor's state 95 100 */ -
trunk/sources/thelib/src/netio/epoll/iohandlermanager.cpp
r614 r706 1 /* 1 /* 2 2 * Copyright (c) 2010, 3 3 * Gavriloaie Eugen-Andrei (shiretu@gmail.com) … … 31 31 vector<IOHandlerManagerToken *> *IOHandlerManager::_pRecycledTokens; 32 32 TimersManager *IOHandlerManager::_pTimersManager = NULL; 33 FdStats IOHandlerManager::_fdStats; 33 34 struct epoll_event IOHandlerManager::_dummy = {0, 34 35 {0}}; … … 43 44 44 45 void IOHandlerManager::Initialize() { 46 _fdStats.Reset(); 45 47 _eq = 0; 46 48 _pAvailableTokens = &_tokensVector1; … … 97 99 size_t before = _activeIOHandlers.size(); 98 100 _activeIOHandlers[pIOHandler->GetId()] = pIOHandler; 101 _fdStats.RegisterManaged(pIOHandler->GetType()); 99 102 DEBUG("Handlers count changed: %"PRIz"u->%"PRIz"u %s", before, before + 1, 100 103 STR(IOHandler::IOHTToString(pIOHandler->GetType()))); … … 103 106 void IOHandlerManager::UnRegisterIOHandler(IOHandler *pIOHandler) { 104 107 if (MAP_HAS1(_activeIOHandlers, pIOHandler->GetId())) { 108 _fdStats.UnRegisterManaged(pIOHandler->GetType()); 105 109 FreeToken(pIOHandler); 106 110 size_t before = _activeIOHandlers.size(); … … 109 113 STR(IOHandler::IOHTToString(pIOHandler->GetType()))); 110 114 } 115 } 116 117 int IOHandlerManager::CreateRawUDPSocket() { 118 int result = socket(AF_INET, SOCK_DGRAM, 0); 119 if (result >= 0) { 120 _fdStats.RegisterRawUdp(); 121 } else { 122 uint32_t err = LASTSOCKETERROR; 123 FATAL("Unable to create raw udp socket. Error code was: %"PRIu32, err); 124 } 125 return result; 126 } 127 128 void IOHandlerManager::CloseRawUDPSocket(int socket) { 129 if (socket > 0) { 130 _fdStats.UnRegisterRawUdp(); 131 } 132 CLOSE_SOCKET(socket); 111 133 } 112 134 -
trunk/sources/thelib/src/netio/kqueue/iohandlermanager.cpp
r617 r706 1 /* 1 /* 2 2 * Copyright (c) 2010, 3 3 * Gavriloaie Eugen-Andrei (shiretu@gmail.com) … … 35 35 int32_t IOHandlerManager::_pendingEventsCount = 0; 36 36 int32_t IOHandlerManager::_eventsSize = 0; 37 FdStats IOHandlerManager::_fdStats; 37 38 #ifndef HAS_KQUEUE_TIMERS 38 39 struct timespec IOHandlerManager::_timeout = {1, 0}; … … 82 83 83 84 void IOHandlerManager::Initialize() { 85 _fdStats.Reset(); 84 86 _kq = 0; 85 87 _pAvailableTokens = &_tokensVector1; … … 144 146 _activeIOHandlers[pIOHandler->GetId()] = pIOHandler; 145 147 SetupToken(pIOHandler); 148 _fdStats.RegisterManaged(pIOHandler->GetType()); 146 149 DEBUG("Handlers count changed: %"PRIz"u->%"PRIz"u %s", before, before + 1, 147 150 STR(IOHandler::IOHTToString(pIOHandler->GetType()))); … … 150 153 void IOHandlerManager::UnRegisterIOHandler(IOHandler *pIOHandler) { 151 154 if (MAP_HAS1(_activeIOHandlers, pIOHandler->GetId())) { 155 _fdStats.UnRegisterManaged(pIOHandler->GetType()); 152 156 FreeToken(pIOHandler); 153 157 size_t before = _activeIOHandlers.size(); … … 156 160 STR(IOHandler::IOHTToString(pIOHandler->GetType()))); 157 161 } 162 } 163 164 int IOHandlerManager::CreateRawUDPSocket() { 165 int result = socket(AF_INET, SOCK_DGRAM, 0); 166 if (result >= 0) { 167 _fdStats.RegisterRawUdp(); 168 } else { 169 uint32_t err = LASTSOCKETERROR; 170 FATAL("Unable to create raw udp socket. Error code was: %"PRIu32, err); 171 } 172 return result; 173 } 174 175 void IOHandlerManager::CloseRawUDPSocket(int socket) { 176 if (socket > 0) { 177 _fdStats.UnRegisterRawUdp(); 178 } 179 CLOSE_SOCKET(socket); 158 180 } 159 181 -
trunk/sources/thelib/src/netio/select/iohandlermanager.cpp
r614 r706 1 /* 1 /* 2 2 * Copyright (c) 2010, 3 3 * Gavriloaie Eugen-Andrei (shiretu@gmail.com) … … 37 37 select_event IOHandlerManager::_currentEvent = {0}; 38 38 bool IOHandlerManager::_isShuttingDown = false; 39 FdStats IOHandlerManager::_fdStats; 39 40 40 41 map<uint32_t, IOHandler *> & IOHandlerManager::GetActiveHandlers() { … … 47 48 48 49 void IOHandlerManager::Initialize() { 50 _fdStats.Reset(); 49 51 FD_ZERO(&_readFds); 50 52 FD_ZERO(&_writeFds); … … 84 86 size_t before = _activeIOHandlers.size(); 85 87 _activeIOHandlers[pIOHandler->GetId()] = pIOHandler; 88 _fdStats.RegisterManaged(pIOHandler->GetType()); 86 89 DEBUG("Handlers count changed: %"PRIz"u->%"PRIz"u %s", before, before + 1, 87 90 STR(IOHandler::IOHTToString(pIOHandler->GetType()))); … … 94 97 DisableTimer(pIOHandler); 95 98 if (MAP_HAS1(_activeIOHandlers, pIOHandler->GetId())) { 99 _fdStats.UnRegisterManaged(pIOHandler->GetType()); 96 100 size_t before = _activeIOHandlers.size(); 97 101 _activeIOHandlers.erase(pIOHandler->GetId()); … … 99 103 STR(IOHandler::IOHTToString(pIOHandler->GetType()))); 100 104 } 105 } 106 107 int IOHandlerManager::CreateRawUDPSocket() { 108 int result = socket(AF_INET, SOCK_DGRAM, 0); 109 if (result >= 0) { 110 _fdStats.RegisterRawUdp(); 111 } else { 112 uint32_t err = LASTSOCKETERROR; 113 FATAL("Unable to create raw udp socket. Error code was: %"PRIu32, err); 114 } 115 return result; 116 } 117 118 void IOHandlerManager::CloseRawUDPSocket(int socket) { 119 if (socket > 0) { 120 _fdStats.UnRegisterRawUdp(); 121 } 122 CLOSE_SOCKET(socket); 101 123 } 102 124
Note: See TracChangeset
for help on using the changeset viewer.
