2006-01-19 Al Riddoch <alriddoch@zepler.org>
* aiclient/ClientAccount.cpp, aiclient/ClientAccount.h,
aiclient/ClientConnection.cpp, aiclient/ClientConnection.h,
aiclient/client.cpp, aiclient/client.h, client/BaseClient.cpp,
client/BaseClient.h, client/CharacterClient.cpp,
client/CharacterClient.h, client/ClientConnection.cpp,
client/ClientConnection.h, client/CreatorClient.cpp,
client/CreatorClient.h, client/ObserverClient.cpp,
client/ObserverClient.h, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp,
client/define_world.cpp, client/define_world.h, common/Add.h,
common/Affect.h, common/AtlasFileLoader.cpp,
common/AtlasFileLoader.h, common/Attack.h, common/BaseEntity.cpp,
common/BaseEntity.h, common/BaseWorld.cpp, common/BaseWorld.h,
common/Burn.h, common/Chop.h, common/Connect.h, common/CustomOp.cpp,
common/CustomOp.h, common/CustomOp_impl.h, common/Cut.h,
common/Database.cpp, common/Database.h, common/Delve.h, common/Dig.h,
common/Eat.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/Generic.h, common/Load.h,
common/Monitor.h, common/Mow.h, common/Nourish.h,
common/OOGThing.cpp, common/OOGThing.h, common/Property.cpp,
common/Property.h, common/Property_impl.h, common/Save.h,
common/Setup.h, common/Tick.h, common/Unseen.h, common/Update.h,
common/Use.h, common/Wield.h, common/accountbase.cpp,
common/accountbase.h, common/const.cpp, common/const.h,
common/custom.cpp, common/debug.h, common/globals.cpp,
common/globals.h, common/id.cpp, common/id.h, common/inheritance.cpp,
common/inheritance.h, common/inheritance_impl.h, common/log.cpp,
common/log.h, common/newid.cpp, common/nls.h, common/op_switch.h,
common/operations.cpp, common/operations.h, common/random.h,
common/refno.h, common/serialno.cpp, common/serialno.h,
common/system.cpp, common/system.h, common/terrain_utils.cpp,
common/terrain_utils.h, common/type_utils.h, common/types.h,
common/utility.cpp, common/utility.h, modules/DateTime.cpp,
modules/DateTime.h, modules/Location.cpp, modules/Location.h,
modules/WorldTime.cpp, modules/WorldTime.h, physics/BBox.cpp,
physics/BBox.h, physics/Collision.cpp, physics/Collision.h,
physics/Quaternion.cpp, physics/Quaternion.h, physics/Vector3D.cpp,
physics/Vector3D.h, physics/VectorPol.h, rulesets/Area.cpp,
rulesets/Area.h, rulesets/AreaProperty.cpp, rulesets/AreaProperty.h,
rulesets/ArithmeticScript.cpp, rulesets/ArithmeticScript.h,
rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/CalendarProperty.cpp, rulesets/CalendarProperty.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Combat.cpp,
rulesets/Combat.h, rulesets/Container.cpp, rulesets/Container.h,
rulesets/Creator.cpp, rulesets/Creator.h, rulesets/Entity.cpp,
rulesets/Entity.h, rulesets/EntityProperties.cpp,
rulesets/Entity_getLocation.h, rulesets/Fell.cpp, rulesets/Fell.h,
rulesets/Food.cpp, rulesets/Food.h, rulesets/Line.cpp,
rulesets/Line.h, rulesets/LineProperty.cpp, rulesets/LineProperty.h,
rulesets/MemEntity.cpp, rulesets/MemEntity.h, rulesets/MemMap.cpp,
rulesets/MemMap.h, rulesets/MemMap_methods.h,
rulesets/MindFactory.cpp, rulesets/MindFactory.h, rulesets/Missile.h,
rulesets/Motion.cpp, rulesets/Motion.h, rulesets/Movement.cpp,
rulesets/Movement.h, rulesets/Pedestrian.cpp, rulesets/Pedestrian.h,
rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_BBox.cpp,
rulesets/Py_BBox.h, rulesets/Py_EntityWrapper.h,
rulesets/Py_Location.cpp, rulesets/Py_Location.h,
rulesets/Py_Map.cpp, rulesets/Py_Map.h, rulesets/Py_Mind.cpp,
rulesets/Py_Mind.h, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Operation.h,
rulesets/Py_Oplist.cpp, rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp,
rulesets/Py_Optime.h, rulesets/Py_Point3D.cpp, rulesets/Py_Point3D.h,
rulesets/Py_Property.cpp, rulesets/Py_Property.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_RootEntity.cpp, rulesets/Py_RootEntity.h,
rulesets/Py_Statistics.cpp, rulesets/Py_Statistics.h,
rulesets/Py_Task.cpp, rulesets/Py_Task.h, rulesets/Py_Thing.cpp,
rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonArithmeticScript.cpp,
rulesets/PythonArithmeticScript.h, rulesets/PythonMindScript.cpp,
rulesets/PythonMindScript.h, rulesets/PythonScript.cpp,
rulesets/PythonScript.h, rulesets/PythonThingScript.cpp,
rulesets/PythonThingScript.h, rulesets/PythonWrapper.cpp,
rulesets/PythonWrapper.h, rulesets/Python_API.cpp,
rulesets/Python_API.h, rulesets/Python_Script_Utils.h,
rulesets/Script.cpp, rulesets/Script.h, rulesets/Stackable.cpp,
rulesets/Stackable.h, rulesets/Statistics.cpp, rulesets/Statistics.h,
rulesets/StatisticsProperty.cpp, rulesets/StatisticsProperty.h,
rulesets/Structure.cpp, rulesets/Structure.h, rulesets/Task.cpp,
rulesets/Task.h, rulesets/TaskScript.cpp, rulesets/TaskScript.h,
rulesets/TerrainProperty.cpp, rulesets/TerrainProperty.h,
rulesets/Thing.cpp, rulesets/Thing.h, rulesets/ThingFactory.cpp,
rulesets/ThingFactory.h, rulesets/World.cpp, rulesets/World.h,
rulesets/attributes.h, server/Account.cpp, server/Account.h,
server/Admin.cpp, server/Admin.h, server/ArithmeticFactory.cpp,
server/ArithmeticFactory.h, server/CommClient.cpp,
server/CommClient.h, server/CommIdleSocket.cpp,
server/CommIdleSocket.h, server/CommListener.cpp,
server/CommListener.h, server/CommLocalClient.cpp,
server/CommLocalClient.h, server/CommMDNSPublisher.cpp,
server/CommMDNSPublisher.h, server/CommMaster.cpp,
server/CommMaster.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommPSQLSocket.cpp,
server/CommPSQLSocket.h, server/CommPeer.cpp,
server/CommPeer.h, server/CommPeerListener.cpp,
server/CommPeerListener.h, server/CommRemoteClient.cpp,
server/CommRemoteClient.h, server/CommServer.cpp,
server/CommServer.h, server/CommSlaveClient.cpp,
server/CommSlaveClient.h, server/CommSlaveListener.cpp,
server/CommSlaveListener.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/Connection_methods.h,
server/EntityFactory.cpp, server/EntityFactory.h,
server/ExternalMind.cpp, server/ExternalMind.h,
server/Idle.cpp, server/Idle.h, server/Lobby.cpp, server/Lobby.h,
server/Master.cpp, server/Master.h, server/Peer.cpp, server/Peer.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.cpp, server/PersistantThingFactory.h,
server/PersistantThingFactory_impl.h, server/Persistor.cpp,
server/Persistor.h, server/Persistor_impl.h,
server/Player.cpp, server/Player.h, server/Restoration.cpp,
server/Restoration.h, server/Restorer.cpp, server/Restorer.h,
server/Restorer_impl.h, server/ScriptFactory.cpp,
server/ScriptFactory.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/ServerRouting_methods.h,
server/SlaveClientConnection.cpp, server/SlaveClientConnection.h,
server/TaskFactory.cpp, server/TaskFactory.h,
server/TrustedConnection.cpp, server/TrustedConnection.h,
server/WorldRouter.cpp, server/WorldRouter.h,
server/server.cpp, server/server.h, server/slave.cpp,
tests/Areatest.cpp, tests/BaseEntitytest.cpp,
tests/Charactertest.cpp, tests/Containertest.cpp,
tests/Creatortest.cpp, tests/EntityExerciser.h,
tests/EntityFactorytest.cpp, tests/Entitytest.cpp,
tests/Foodtest.cpp, tests/IGEntityExerciser.h,
tests/Linetest.cpp, tests/Locationtest.cpp, tests/OOGThingtest.cpp,
tests/Planttest.cpp, tests/Propertytest.cpp, tests/Stackabletest.cpp,
tests/Structuretest.cpp, tests/Tasktest.cpp, tests/TestWorld.h,
tests/Thingtest.cpp, tests/WorldTimetest.cpp, tests/Worldtest.cpp,
tests/allOperations.h, tests/collisiontest.cpp, tests/consttest.cpp,
tests/distancetest.cpp, tests/emergencetest.cpp,
tests/inheritancetest.cpp, tests/logtest.cpp, tests/randomtest.cpp,
tests/systemtest.cpp, tests/transformtest.cpp,
tests/type_utilstest.cpp, tests/utilitytest.cpp,
tools/AdminClient.cpp, tools/AdminClient.h, tools/cyaddrules.cpp,
tools/cycmd.cpp, tools/cyconfig.cpp, tools/cyconvertrules.cpp,
tools/cyctrl.cpp, tools/cydbload.cpp, tools/cydumprules.cpp,
tools/cyisoload.cpp, tools/cyloadrules.cpp, tools/cypasswd.cpp,
tools/cywatchdog.cpp: Replace the copyright and license statements
with new versions that include disclaimer of warranty, and
permit distribution under later versions of the GPL.
2006-01-19 02:17:06 +00:00
|
|
|
// Cyphesis Online RPG Server and AI Engine
|
2005-05-03 01:12:08 +00:00
|
|
|
// Copyright (C) 2000-2005 Alistair Riddoch
|
2006-01-19 Al Riddoch <alriddoch@zepler.org>
* aiclient/ClientAccount.cpp, aiclient/ClientAccount.h,
aiclient/ClientConnection.cpp, aiclient/ClientConnection.h,
aiclient/client.cpp, aiclient/client.h, client/BaseClient.cpp,
client/BaseClient.h, client/CharacterClient.cpp,
client/CharacterClient.h, client/ClientConnection.cpp,
client/ClientConnection.h, client/CreatorClient.cpp,
client/CreatorClient.h, client/ObserverClient.cpp,
client/ObserverClient.h, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp,
client/define_world.cpp, client/define_world.h, common/Add.h,
common/Affect.h, common/AtlasFileLoader.cpp,
common/AtlasFileLoader.h, common/Attack.h, common/BaseEntity.cpp,
common/BaseEntity.h, common/BaseWorld.cpp, common/BaseWorld.h,
common/Burn.h, common/Chop.h, common/Connect.h, common/CustomOp.cpp,
common/CustomOp.h, common/CustomOp_impl.h, common/Cut.h,
common/Database.cpp, common/Database.h, common/Delve.h, common/Dig.h,
common/Eat.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/Generic.h, common/Load.h,
common/Monitor.h, common/Mow.h, common/Nourish.h,
common/OOGThing.cpp, common/OOGThing.h, common/Property.cpp,
common/Property.h, common/Property_impl.h, common/Save.h,
common/Setup.h, common/Tick.h, common/Unseen.h, common/Update.h,
common/Use.h, common/Wield.h, common/accountbase.cpp,
common/accountbase.h, common/const.cpp, common/const.h,
common/custom.cpp, common/debug.h, common/globals.cpp,
common/globals.h, common/id.cpp, common/id.h, common/inheritance.cpp,
common/inheritance.h, common/inheritance_impl.h, common/log.cpp,
common/log.h, common/newid.cpp, common/nls.h, common/op_switch.h,
common/operations.cpp, common/operations.h, common/random.h,
common/refno.h, common/serialno.cpp, common/serialno.h,
common/system.cpp, common/system.h, common/terrain_utils.cpp,
common/terrain_utils.h, common/type_utils.h, common/types.h,
common/utility.cpp, common/utility.h, modules/DateTime.cpp,
modules/DateTime.h, modules/Location.cpp, modules/Location.h,
modules/WorldTime.cpp, modules/WorldTime.h, physics/BBox.cpp,
physics/BBox.h, physics/Collision.cpp, physics/Collision.h,
physics/Quaternion.cpp, physics/Quaternion.h, physics/Vector3D.cpp,
physics/Vector3D.h, physics/VectorPol.h, rulesets/Area.cpp,
rulesets/Area.h, rulesets/AreaProperty.cpp, rulesets/AreaProperty.h,
rulesets/ArithmeticScript.cpp, rulesets/ArithmeticScript.h,
rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/CalendarProperty.cpp, rulesets/CalendarProperty.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Combat.cpp,
rulesets/Combat.h, rulesets/Container.cpp, rulesets/Container.h,
rulesets/Creator.cpp, rulesets/Creator.h, rulesets/Entity.cpp,
rulesets/Entity.h, rulesets/EntityProperties.cpp,
rulesets/Entity_getLocation.h, rulesets/Fell.cpp, rulesets/Fell.h,
rulesets/Food.cpp, rulesets/Food.h, rulesets/Line.cpp,
rulesets/Line.h, rulesets/LineProperty.cpp, rulesets/LineProperty.h,
rulesets/MemEntity.cpp, rulesets/MemEntity.h, rulesets/MemMap.cpp,
rulesets/MemMap.h, rulesets/MemMap_methods.h,
rulesets/MindFactory.cpp, rulesets/MindFactory.h, rulesets/Missile.h,
rulesets/Motion.cpp, rulesets/Motion.h, rulesets/Movement.cpp,
rulesets/Movement.h, rulesets/Pedestrian.cpp, rulesets/Pedestrian.h,
rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_BBox.cpp,
rulesets/Py_BBox.h, rulesets/Py_EntityWrapper.h,
rulesets/Py_Location.cpp, rulesets/Py_Location.h,
rulesets/Py_Map.cpp, rulesets/Py_Map.h, rulesets/Py_Mind.cpp,
rulesets/Py_Mind.h, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Operation.h,
rulesets/Py_Oplist.cpp, rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp,
rulesets/Py_Optime.h, rulesets/Py_Point3D.cpp, rulesets/Py_Point3D.h,
rulesets/Py_Property.cpp, rulesets/Py_Property.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_RootEntity.cpp, rulesets/Py_RootEntity.h,
rulesets/Py_Statistics.cpp, rulesets/Py_Statistics.h,
rulesets/Py_Task.cpp, rulesets/Py_Task.h, rulesets/Py_Thing.cpp,
rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonArithmeticScript.cpp,
rulesets/PythonArithmeticScript.h, rulesets/PythonMindScript.cpp,
rulesets/PythonMindScript.h, rulesets/PythonScript.cpp,
rulesets/PythonScript.h, rulesets/PythonThingScript.cpp,
rulesets/PythonThingScript.h, rulesets/PythonWrapper.cpp,
rulesets/PythonWrapper.h, rulesets/Python_API.cpp,
rulesets/Python_API.h, rulesets/Python_Script_Utils.h,
rulesets/Script.cpp, rulesets/Script.h, rulesets/Stackable.cpp,
rulesets/Stackable.h, rulesets/Statistics.cpp, rulesets/Statistics.h,
rulesets/StatisticsProperty.cpp, rulesets/StatisticsProperty.h,
rulesets/Structure.cpp, rulesets/Structure.h, rulesets/Task.cpp,
rulesets/Task.h, rulesets/TaskScript.cpp, rulesets/TaskScript.h,
rulesets/TerrainProperty.cpp, rulesets/TerrainProperty.h,
rulesets/Thing.cpp, rulesets/Thing.h, rulesets/ThingFactory.cpp,
rulesets/ThingFactory.h, rulesets/World.cpp, rulesets/World.h,
rulesets/attributes.h, server/Account.cpp, server/Account.h,
server/Admin.cpp, server/Admin.h, server/ArithmeticFactory.cpp,
server/ArithmeticFactory.h, server/CommClient.cpp,
server/CommClient.h, server/CommIdleSocket.cpp,
server/CommIdleSocket.h, server/CommListener.cpp,
server/CommListener.h, server/CommLocalClient.cpp,
server/CommLocalClient.h, server/CommMDNSPublisher.cpp,
server/CommMDNSPublisher.h, server/CommMaster.cpp,
server/CommMaster.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommPSQLSocket.cpp,
server/CommPSQLSocket.h, server/CommPeer.cpp,
server/CommPeer.h, server/CommPeerListener.cpp,
server/CommPeerListener.h, server/CommRemoteClient.cpp,
server/CommRemoteClient.h, server/CommServer.cpp,
server/CommServer.h, server/CommSlaveClient.cpp,
server/CommSlaveClient.h, server/CommSlaveListener.cpp,
server/CommSlaveListener.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/Connection_methods.h,
server/EntityFactory.cpp, server/EntityFactory.h,
server/ExternalMind.cpp, server/ExternalMind.h,
server/Idle.cpp, server/Idle.h, server/Lobby.cpp, server/Lobby.h,
server/Master.cpp, server/Master.h, server/Peer.cpp, server/Peer.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.cpp, server/PersistantThingFactory.h,
server/PersistantThingFactory_impl.h, server/Persistor.cpp,
server/Persistor.h, server/Persistor_impl.h,
server/Player.cpp, server/Player.h, server/Restoration.cpp,
server/Restoration.h, server/Restorer.cpp, server/Restorer.h,
server/Restorer_impl.h, server/ScriptFactory.cpp,
server/ScriptFactory.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/ServerRouting_methods.h,
server/SlaveClientConnection.cpp, server/SlaveClientConnection.h,
server/TaskFactory.cpp, server/TaskFactory.h,
server/TrustedConnection.cpp, server/TrustedConnection.h,
server/WorldRouter.cpp, server/WorldRouter.h,
server/server.cpp, server/server.h, server/slave.cpp,
tests/Areatest.cpp, tests/BaseEntitytest.cpp,
tests/Charactertest.cpp, tests/Containertest.cpp,
tests/Creatortest.cpp, tests/EntityExerciser.h,
tests/EntityFactorytest.cpp, tests/Entitytest.cpp,
tests/Foodtest.cpp, tests/IGEntityExerciser.h,
tests/Linetest.cpp, tests/Locationtest.cpp, tests/OOGThingtest.cpp,
tests/Planttest.cpp, tests/Propertytest.cpp, tests/Stackabletest.cpp,
tests/Structuretest.cpp, tests/Tasktest.cpp, tests/TestWorld.h,
tests/Thingtest.cpp, tests/WorldTimetest.cpp, tests/Worldtest.cpp,
tests/allOperations.h, tests/collisiontest.cpp, tests/consttest.cpp,
tests/distancetest.cpp, tests/emergencetest.cpp,
tests/inheritancetest.cpp, tests/logtest.cpp, tests/randomtest.cpp,
tests/systemtest.cpp, tests/transformtest.cpp,
tests/type_utilstest.cpp, tests/utilitytest.cpp,
tools/AdminClient.cpp, tools/AdminClient.h, tools/cyaddrules.cpp,
tools/cycmd.cpp, tools/cyconfig.cpp, tools/cyconvertrules.cpp,
tools/cyctrl.cpp, tools/cydbload.cpp, tools/cydumprules.cpp,
tools/cyisoload.cpp, tools/cyloadrules.cpp, tools/cypasswd.cpp,
tools/cywatchdog.cpp: Replace the copyright and license statements
with new versions that include disclaimer of warranty, and
permit distribution under later versions of the GPL.
2006-01-19 02:17:06 +00:00
|
|
|
//
|
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
// along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2001-09-13 18:21:56 +00:00
|
|
|
|
2006-11-02 05:14:54 +00:00
|
|
|
// $Id: CommServer.cpp,v 1.58 2006-11-02 05:14:55 alriddoch Exp $
|
2006-10-26 00:48:00 +00:00
|
|
|
|
2004-11-24 01:19:31 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include "config.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2001-09-13 18:21:56 +00:00
|
|
|
#include "CommServer.h"
|
2002-11-23 Al Riddoch <alriddoch@zepler.org>
* Increment to devel version 0.3, and start breaking things.
* server/CommClient.cpp, server/CommClient.h, server/CommServer.cpp,
server/CommServer.h, server/server.cpp, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommSocket.cpp, server/CommSocket.h:
Refactor network code so metaserver and listen socket are no longer
special cases, opening up the way for a database connection handler.
2002-11-23 17:13:39 +00:00
|
|
|
|
2004-12-08 16:36:42 +00:00
|
|
|
#include "CommSocket.h"
|
|
|
|
|
#include "Idle.h"
|
2004-12-08 02:09:04 +00:00
|
|
|
#include "ServerRouting.h"
|
2002-07-14 21:04:50 +00:00
|
|
|
|
2003-03-07 00:22:12 +00:00
|
|
|
#include "common/log.h"
|
|
|
|
|
#include "common/debug.h"
|
2006-11-02 05:14:54 +00:00
|
|
|
#include "common/system.h"
|
2005-10-04 23:01:32 +00:00
|
|
|
#include "common/compose.hpp"
|
2006-11-02 05:14:54 +00:00
|
|
|
#include "common/BaseWorld.h"
|
|
|
|
|
|
|
|
|
|
#include <skstream/sksocket.h>
|
2001-09-13 18:21:56 +00:00
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
2004-12-08 16:36:42 +00:00
|
|
|
extern "C" {
|
2004-11-24 01:19:31 +00:00
|
|
|
#ifdef HAVE_EPOLL_CREATE
|
2004-12-08 16:36:42 +00:00
|
|
|
#include <sys/epoll.h>
|
2004-11-24 01:19:31 +00:00
|
|
|
#endif // HAVE_EPOLL_CREATE
|
2005-05-03 01:12:08 +00:00
|
|
|
#include <errno.h>
|
2004-12-08 16:36:42 +00:00
|
|
|
}
|
2004-11-24 01:19:31 +00:00
|
|
|
|
2001-09-13 18:21:56 +00:00
|
|
|
static const bool debug_flag = false;
|
|
|
|
|
|
2004-08-07 11:25:30 +00:00
|
|
|
/// \brief Construct a new CommServer object, storing a reference to the core
|
|
|
|
|
/// server object.
|
2005-10-04 23:01:32 +00:00
|
|
|
CommServer::CommServer(ServerRouting & svr) : m_congested(false), m_server(svr)
|
2001-09-13 18:21:56 +00:00
|
|
|
{
|
2004-11-24 01:19:31 +00:00
|
|
|
#ifdef HAVE_EPOLL_CREATE
|
2006-08-07 14:10:52 +00:00
|
|
|
// 64 seems like a suitable value for initial number of sockets to be
|
|
|
|
|
// handled, though there is very little documentation on what would be
|
|
|
|
|
// a good choice here.
|
2004-11-24 01:19:31 +00:00
|
|
|
m_epollFd = epoll_create(64);
|
|
|
|
|
if (m_epollFd < 0) {
|
2006-08-06 23:35:46 +00:00
|
|
|
log(CRITICAL, String::compose("epoll_create: %s", strerror(errno)).c_str());
|
2004-11-24 01:19:31 +00:00
|
|
|
exit_flag = true;
|
|
|
|
|
}
|
|
|
|
|
#endif // HAVE_EPOLL_CREATE
|
2001-09-13 18:21:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CommServer::~CommServer()
|
|
|
|
|
{
|
2004-11-24 01:19:31 +00:00
|
|
|
#ifdef HAVE_EPOLL_CREATE
|
|
|
|
|
close(m_epollFd);
|
|
|
|
|
#endif // HAVE_EPOLL_CREATE
|
2004-11-06 Al Riddoch <alriddoch@zepler.org>
* aiclient/ClientConnection.cpp, client/BaseClient.cpp,
client/CharacterClient.cpp, client/ClientConnection.cpp,
common/Database.cpp, common/FormattedXMLWriter.cpp,
common/inheritance.cpp, common/refno.h, common/terrain_utils.cpp,
common/type_utils.h, common/utility.cpp, modules/WorldTime.cpp,
modules/WorldTime.h, physics/Collision.cpp, rulesets/Area.cpp,
rulesets/BaseMind.cpp, rulesets/Character.cpp, rulesets/Entity.cpp,
rulesets/Line.cpp, rulesets/MemMap.cpp, rulesets/MemMap_methods.h,
rulesets/Movement.cpp, rulesets/Plant.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Oplist.cpp, rulesets/PythonMindScript.cpp,
rulesets/PythonThingScript.cpp, rulesets/Python_API.cpp,
rulesets/Stackable.cpp, rulesets/TerrainProperty.cpp,
rulesets/Thing.cpp, rulesets/World.cpp, server/Account.cpp,
server/CommClient.cpp, server/CommServer.cpp, server/Connection.cpp,
server/EntityFactory.cpp, server/Lobby.cpp, server/Persistance.cpp,
server/Player.cpp, server/Restoration.cpp, server/ServerRouting.cpp,
server/WorldRouter.cpp, tests/EntityExerciser.h,
tests/IGEntityExerciser.h, tests/inheritancetest.cpp,
tools/cycmd.cpp, tools/cyconvertrules.cpp, tools/cydbload.cpp,
tools/cyloadrules.cpp:
Tweak for loops to avoid creating a temporary iterator each
iteration.
* tests/type_utilstest.cpp: New test for function which does
list conversions.
2004-11-06 20:36:03 +00:00
|
|
|
CommSocketSet::const_iterator Iend = m_sockets.end();
|
|
|
|
|
for (CommSocketSet::const_iterator I = m_sockets.begin(); I != Iend; ++I) {
|
2002-06-19 14:17:42 +00:00
|
|
|
delete *I;
|
2001-09-13 18:21:56 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-07 11:25:30 +00:00
|
|
|
/// \brief Idle function called from the main loop.
|
|
|
|
|
///
|
2004-11-20 22:10:04 +00:00
|
|
|
/// Poll all the Idle objects that want to be polled regularly,
|
2005-05-03 01:12:08 +00:00
|
|
|
/// Call the core server object idle function.
|
2004-08-07 11:25:30 +00:00
|
|
|
/// @return true if the core server wants to be called again as soon as
|
|
|
|
|
/// possible.
|
|
|
|
|
bool CommServer::idle()
|
2001-09-13 18:21:56 +00:00
|
|
|
{
|
|
|
|
|
// Update the time, and get the core server object to process
|
|
|
|
|
// stuff.
|
2006-08-14 09:29:17 +00:00
|
|
|
time_t old_seconds = m_timeVal.tv_sec;
|
2005-10-04 23:01:32 +00:00
|
|
|
gettimeofday(&m_timeVal, NULL);
|
|
|
|
|
|
|
|
|
|
bool busy = m_server.m_world.idle(m_timeVal.tv_sec, m_timeVal.tv_usec);
|
|
|
|
|
|
2005-11-30 18:04:28 +00:00
|
|
|
// We only call the idlers if the world has returned that it is not busy,
|
|
|
|
|
// and the last call to select/poll with a sleep time provided did not
|
|
|
|
|
// return any traffic.
|
2006-08-14 09:29:17 +00:00
|
|
|
if (!busy && !m_congested && old_seconds != m_timeVal.tv_sec) {
|
2005-10-04 23:01:32 +00:00
|
|
|
IdleSet::const_iterator I = m_idlers.begin();
|
|
|
|
|
IdleSet::const_iterator Iend = m_idlers.end();
|
|
|
|
|
for (; I != Iend; ++I) {
|
|
|
|
|
(*I)->idle(m_timeVal.tv_sec);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// if (busy) { std::cout << "No idle because server busy" << std::endl << std::flush; }
|
|
|
|
|
// if (m_congested) { std::cout << "No idle because clients busy" << std::endl << std::flush; }
|
2001-09-13 18:21:56 +00:00
|
|
|
}
|
2004-12-08 02:09:04 +00:00
|
|
|
|
2005-10-04 23:01:32 +00:00
|
|
|
return busy;
|
2001-09-13 18:21:56 +00:00
|
|
|
}
|
|
|
|
|
|
2004-08-07 11:25:30 +00:00
|
|
|
/// \brief Main program loop called repeatedly.
|
|
|
|
|
///
|
|
|
|
|
/// Call the server idle function to do its processing. If the server is
|
|
|
|
|
/// is currently busy, poll all the sockets as quickly as possible.
|
|
|
|
|
/// If the server is idle, use select() to sleep on the sockets for
|
|
|
|
|
/// a short period of time. If any sockets get broken or disconnected,
|
|
|
|
|
/// they are noted and closed down at the end of the process.
|
2004-12-08 16:36:42 +00:00
|
|
|
void CommServer::poll()
|
2001-09-13 18:21:56 +00:00
|
|
|
{
|
|
|
|
|
// This is the main code loop.
|
2004-09-05 23:36:36 +00:00
|
|
|
// Classic select code for checking incoming data on sockets.
|
2005-10-04 23:01:32 +00:00
|
|
|
|
|
|
|
|
// It would be useful to let idle know if we are currently dealing with
|
|
|
|
|
// traffic
|
2004-05-11 21:48:25 +00:00
|
|
|
bool busy = idle();
|
|
|
|
|
|
2004-11-24 01:19:31 +00:00
|
|
|
#ifdef HAVE_EPOLL_CREATE
|
2006-08-07 14:10:52 +00:00
|
|
|
static const int max_events = 16;
|
2004-11-24 01:19:31 +00:00
|
|
|
|
2006-08-07 14:10:52 +00:00
|
|
|
static struct epoll_event events[max_events];
|
|
|
|
|
|
|
|
|
|
int rval = ::epoll_wait(m_epollFd, events, max_events, (busy ? 0 : 100));
|
2004-11-24 01:19:31 +00:00
|
|
|
|
2005-10-04 23:01:32 +00:00
|
|
|
if (rval < 0) {
|
2005-10-22 01:48:21 +00:00
|
|
|
if (errno != EINTR) {
|
2006-11-02 05:14:54 +00:00
|
|
|
log(CYLOG_ERROR, String::compose("epoll_wait: %1", strerror(errno)).c_str());
|
2005-10-22 01:48:21 +00:00
|
|
|
}
|
2006-08-07 14:10:52 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_congested = (rval != 0) || m_congested && busy;
|
|
|
|
|
|
|
|
|
|
if (rval == max_events) {
|
|
|
|
|
// If we see this alot, we should increase the maximum
|
|
|
|
|
log(NOTICE, "epoll_wait returned the maximum number of events.");
|
2005-10-04 23:01:32 +00:00
|
|
|
}
|
|
|
|
|
|
2004-11-24 01:19:31 +00:00
|
|
|
for (int i = 0; i < rval; ++i) {
|
|
|
|
|
struct epoll_event & event = events[i];
|
|
|
|
|
CommSocket * cs = (CommSocket *)event.data.ptr;
|
|
|
|
|
if (event.events & EPOLLHUP) {
|
|
|
|
|
removeSocket(cs);
|
|
|
|
|
} else {
|
|
|
|
|
// FIXME If this never happens, then it can go
|
|
|
|
|
if (event.events & EPOLLERR) {
|
|
|
|
|
log(WARNING, "Socket error returned by epoll()");
|
|
|
|
|
}
|
|
|
|
|
if (event.events & EPOLLIN) {
|
|
|
|
|
if (cs->eof()) {
|
|
|
|
|
removeSocket(cs);
|
|
|
|
|
} else {
|
|
|
|
|
if (cs->read() != 0) {
|
|
|
|
|
// Remove it?
|
|
|
|
|
// FIXME It could be bad to do this, as dispatch()
|
|
|
|
|
// has not been called.
|
|
|
|
|
removeSocket(cs);
|
|
|
|
|
} else {
|
|
|
|
|
cs->dispatch();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#else // HAVE_EPOLL_CREATE
|
|
|
|
|
|
2001-09-13 18:21:56 +00:00
|
|
|
fd_set sock_fds;
|
2006-11-02 05:14:54 +00:00
|
|
|
SOCKET_TYPE highest = 0;
|
2001-09-13 18:21:56 +00:00
|
|
|
struct timeval tv;
|
|
|
|
|
|
2002-06-19 14:17:42 +00:00
|
|
|
tv.tv_sec = 0;
|
2004-05-11 21:48:25 +00:00
|
|
|
tv.tv_usec = (busy ? 0 : 100000);
|
2001-09-13 18:21:56 +00:00
|
|
|
|
|
|
|
|
FD_ZERO(&sock_fds);
|
|
|
|
|
|
2003-08-07 23:03:26 +00:00
|
|
|
bool pendingConnections = false;
|
2004-11-06 Al Riddoch <alriddoch@zepler.org>
* aiclient/ClientConnection.cpp, client/BaseClient.cpp,
client/CharacterClient.cpp, client/ClientConnection.cpp,
common/Database.cpp, common/FormattedXMLWriter.cpp,
common/inheritance.cpp, common/refno.h, common/terrain_utils.cpp,
common/type_utils.h, common/utility.cpp, modules/WorldTime.cpp,
modules/WorldTime.h, physics/Collision.cpp, rulesets/Area.cpp,
rulesets/BaseMind.cpp, rulesets/Character.cpp, rulesets/Entity.cpp,
rulesets/Line.cpp, rulesets/MemMap.cpp, rulesets/MemMap_methods.h,
rulesets/Movement.cpp, rulesets/Plant.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Oplist.cpp, rulesets/PythonMindScript.cpp,
rulesets/PythonThingScript.cpp, rulesets/Python_API.cpp,
rulesets/Stackable.cpp, rulesets/TerrainProperty.cpp,
rulesets/Thing.cpp, rulesets/World.cpp, server/Account.cpp,
server/CommClient.cpp, server/CommServer.cpp, server/Connection.cpp,
server/EntityFactory.cpp, server/Lobby.cpp, server/Persistance.cpp,
server/Player.cpp, server/Restoration.cpp, server/ServerRouting.cpp,
server/WorldRouter.cpp, tests/EntityExerciser.h,
tests/IGEntityExerciser.h, tests/inheritancetest.cpp,
tools/cycmd.cpp, tools/cyconvertrules.cpp, tools/cydbload.cpp,
tools/cyloadrules.cpp:
Tweak for loops to avoid creating a temporary iterator each
iteration.
* tests/type_utilstest.cpp: New test for function which does
list conversions.
2004-11-06 20:36:03 +00:00
|
|
|
CommSocketSet::const_iterator Iend = m_sockets.end();
|
|
|
|
|
for (CommSocketSet::const_iterator I = m_sockets.begin(); I != Iend; ++I) {
|
2003-08-07 23:03:26 +00:00
|
|
|
if (!(*I)->isOpen()) {
|
|
|
|
|
pendingConnections = true;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2006-11-02 05:14:54 +00:00
|
|
|
SOCKET_TYPE socket_fd = (*I)->getFd();
|
2004-09-05 23:36:36 +00:00
|
|
|
FD_SET(socket_fd, &sock_fds);
|
|
|
|
|
if (socket_fd > highest) {
|
|
|
|
|
highest = socket_fd;
|
2001-09-13 18:21:56 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
highest++;
|
2003-05-06 16:09:39 +00:00
|
|
|
int rval = ::select(highest, &sock_fds, NULL, NULL, &tv);
|
2001-09-13 18:21:56 +00:00
|
|
|
|
|
|
|
|
if (rval < 0) {
|
2003-05-12 08:37:15 +00:00
|
|
|
if (errno != EINTR) {
|
2006-11-02 05:14:54 +00:00
|
|
|
log(CYLOG_ERROR, "Error caused by select() in main loop");
|
|
|
|
|
logSysError(CYLOG_ERROR);
|
2003-05-12 08:37:15 +00:00
|
|
|
}
|
2003-05-06 16:09:39 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-07 23:03:26 +00:00
|
|
|
if ((rval == 0) && !pendingConnections) {
|
2001-09-13 18:21:56 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2004-11-06 Al Riddoch <alriddoch@zepler.org>
* aiclient/ClientConnection.cpp, client/BaseClient.cpp,
client/CharacterClient.cpp, client/ClientConnection.cpp,
common/Database.cpp, common/FormattedXMLWriter.cpp,
common/inheritance.cpp, common/refno.h, common/terrain_utils.cpp,
common/type_utils.h, common/utility.cpp, modules/WorldTime.cpp,
modules/WorldTime.h, physics/Collision.cpp, rulesets/Area.cpp,
rulesets/BaseMind.cpp, rulesets/Character.cpp, rulesets/Entity.cpp,
rulesets/Line.cpp, rulesets/MemMap.cpp, rulesets/MemMap_methods.h,
rulesets/Movement.cpp, rulesets/Plant.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Oplist.cpp, rulesets/PythonMindScript.cpp,
rulesets/PythonThingScript.cpp, rulesets/Python_API.cpp,
rulesets/Stackable.cpp, rulesets/TerrainProperty.cpp,
rulesets/Thing.cpp, rulesets/World.cpp, server/Account.cpp,
server/CommClient.cpp, server/CommServer.cpp, server/Connection.cpp,
server/EntityFactory.cpp, server/Lobby.cpp, server/Persistance.cpp,
server/Player.cpp, server/Restoration.cpp, server/ServerRouting.cpp,
server/WorldRouter.cpp, tests/EntityExerciser.h,
tests/IGEntityExerciser.h, tests/inheritancetest.cpp,
tools/cycmd.cpp, tools/cyconvertrules.cpp, tools/cydbload.cpp,
tools/cyloadrules.cpp:
Tweak for loops to avoid creating a temporary iterator each
iteration.
* tests/type_utilstest.cpp: New test for function which does
list conversions.
2004-11-06 20:36:03 +00:00
|
|
|
// We assume Iend is still valid. m_sockets must not have been modified
|
|
|
|
|
// between Iend's initialisation and here.
|
2005-05-03 01:12:08 +00:00
|
|
|
CommSocketSet obsoleteConnections;
|
2004-11-06 Al Riddoch <alriddoch@zepler.org>
* aiclient/ClientConnection.cpp, client/BaseClient.cpp,
client/CharacterClient.cpp, client/ClientConnection.cpp,
common/Database.cpp, common/FormattedXMLWriter.cpp,
common/inheritance.cpp, common/refno.h, common/terrain_utils.cpp,
common/type_utils.h, common/utility.cpp, modules/WorldTime.cpp,
modules/WorldTime.h, physics/Collision.cpp, rulesets/Area.cpp,
rulesets/BaseMind.cpp, rulesets/Character.cpp, rulesets/Entity.cpp,
rulesets/Line.cpp, rulesets/MemMap.cpp, rulesets/MemMap_methods.h,
rulesets/Movement.cpp, rulesets/Plant.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Oplist.cpp, rulesets/PythonMindScript.cpp,
rulesets/PythonThingScript.cpp, rulesets/Python_API.cpp,
rulesets/Stackable.cpp, rulesets/TerrainProperty.cpp,
rulesets/Thing.cpp, rulesets/World.cpp, server/Account.cpp,
server/CommClient.cpp, server/CommServer.cpp, server/Connection.cpp,
server/EntityFactory.cpp, server/Lobby.cpp, server/Persistance.cpp,
server/Player.cpp, server/Restoration.cpp, server/ServerRouting.cpp,
server/WorldRouter.cpp, tests/EntityExerciser.h,
tests/IGEntityExerciser.h, tests/inheritancetest.cpp,
tools/cycmd.cpp, tools/cyconvertrules.cpp, tools/cydbload.cpp,
tools/cyloadrules.cpp:
Tweak for loops to avoid creating a temporary iterator each
iteration.
* tests/type_utilstest.cpp: New test for function which does
list conversions.
2004-11-06 20:36:03 +00:00
|
|
|
for (CommSocketSet::const_iterator I = m_sockets.begin(); I != Iend; ++I) {
|
2004-09-05 23:36:36 +00:00
|
|
|
CommSocket * socket = *I;
|
|
|
|
|
if (!socket->isOpen()) {
|
|
|
|
|
obsoleteConnections.insert(socket);
|
2002-06-19 14:17:42 +00:00
|
|
|
continue;
|
|
|
|
|
}
|
2004-09-05 23:36:36 +00:00
|
|
|
if (FD_ISSET(socket->getFd(), &sock_fds)) {
|
|
|
|
|
if (!socket->eof()) {
|
2004-10-03 Al Riddoch <alriddoch@zepler.org>
* server/CommClient.cpp, server/CommClient.h, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommPSQLSocket.cpp,
server/CommPSQLSocket.h, server/CommServer.cpp, server/CommSocket.h,
server/CommUnixListener.cpp, server/CommUnixListener.h:
Use int for returning error status.
2004-10-03 01:16:10 +00:00
|
|
|
if (socket->read() != 0) {
|
|
|
|
|
debug(std::cout << "Removing socket due to failure"
|
|
|
|
|
<< std::endl << std::flush;);
|
2004-09-05 23:36:36 +00:00
|
|
|
obsoleteConnections.insert(socket);
|
2001-09-13 19:35:16 +00:00
|
|
|
}
|
2004-09-05 23:36:36 +00:00
|
|
|
socket->dispatch();
|
2001-09-13 18:21:56 +00:00
|
|
|
} else {
|
2002-08-26 14:37:48 +00:00
|
|
|
// It is not clear why but on some implementation/circumstances
|
2004-09-05 23:36:36 +00:00
|
|
|
// socket->eof() is true, and sometimes it isn't.
|
2002-08-26 14:37:48 +00:00
|
|
|
// Either way, the stream is now done, and we should remove it
|
2004-09-05 23:36:36 +00:00
|
|
|
obsoleteConnections.insert(socket);
|
2001-09-13 18:21:56 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-11-06 Al Riddoch <alriddoch@zepler.org>
* aiclient/ClientConnection.cpp, client/BaseClient.cpp,
client/CharacterClient.cpp, client/ClientConnection.cpp,
common/Database.cpp, common/FormattedXMLWriter.cpp,
common/inheritance.cpp, common/refno.h, common/terrain_utils.cpp,
common/type_utils.h, common/utility.cpp, modules/WorldTime.cpp,
modules/WorldTime.h, physics/Collision.cpp, rulesets/Area.cpp,
rulesets/BaseMind.cpp, rulesets/Character.cpp, rulesets/Entity.cpp,
rulesets/Line.cpp, rulesets/MemMap.cpp, rulesets/MemMap_methods.h,
rulesets/Movement.cpp, rulesets/Plant.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Oplist.cpp, rulesets/PythonMindScript.cpp,
rulesets/PythonThingScript.cpp, rulesets/Python_API.cpp,
rulesets/Stackable.cpp, rulesets/TerrainProperty.cpp,
rulesets/Thing.cpp, rulesets/World.cpp, server/Account.cpp,
server/CommClient.cpp, server/CommServer.cpp, server/Connection.cpp,
server/EntityFactory.cpp, server/Lobby.cpp, server/Persistance.cpp,
server/Player.cpp, server/Restoration.cpp, server/ServerRouting.cpp,
server/WorldRouter.cpp, tests/EntityExerciser.h,
tests/IGEntityExerciser.h, tests/inheritancetest.cpp,
tools/cycmd.cpp, tools/cyconvertrules.cpp, tools/cydbload.cpp,
tools/cyloadrules.cpp:
Tweak for loops to avoid creating a temporary iterator each
iteration.
* tests/type_utilstest.cpp: New test for function which does
list conversions.
2004-11-06 20:36:03 +00:00
|
|
|
CommSocketSet::const_iterator J = obsoleteConnections.begin();
|
|
|
|
|
CommSocketSet::const_iterator Jend = obsoleteConnections.end();
|
|
|
|
|
for (; J != Jend; ++J) {
|
2002-11-23 Al Riddoch <alriddoch@zepler.org>
* Increment to devel version 0.3, and start breaking things.
* server/CommClient.cpp, server/CommClient.h, server/CommServer.cpp,
server/CommServer.h, server/server.cpp, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommSocket.cpp, server/CommSocket.h:
Refactor network code so metaserver and listen socket are no longer
special cases, opening up the way for a database connection handler.
2002-11-23 17:13:39 +00:00
|
|
|
removeSocket(*J);
|
2002-06-19 14:17:42 +00:00
|
|
|
}
|
2004-11-24 01:19:31 +00:00
|
|
|
#endif // HAVE_EPOLL_CREATE
|
2001-09-13 18:21:56 +00:00
|
|
|
}
|
|
|
|
|
|
2004-11-20 22:10:04 +00:00
|
|
|
/// Add a new CommSocket object to the manager.
|
|
|
|
|
void CommServer::addSocket(CommSocket * cs)
|
|
|
|
|
{
|
2004-11-24 01:19:31 +00:00
|
|
|
#ifdef HAVE_EPOLL_CREATE
|
|
|
|
|
struct epoll_event ee;
|
|
|
|
|
ee.events = EPOLLIN | EPOLLERR | EPOLLHUP;
|
2005-01-12 14:51:25 +00:00
|
|
|
ee.data.u64 = 0;
|
2004-11-24 01:19:31 +00:00
|
|
|
ee.data.ptr = cs;
|
|
|
|
|
int ret = ::epoll_ctl(m_epollFd, EPOLL_CTL_ADD, cs->getFd(), &ee);
|
|
|
|
|
if (ret != 0) {
|
2006-11-02 05:14:54 +00:00
|
|
|
log(CYLOG_ERROR, "Error calling epoll_ctl to add socket");
|
|
|
|
|
logSysError(CYLOG_ERROR);
|
2004-11-24 01:19:31 +00:00
|
|
|
}
|
|
|
|
|
#endif // HAVE_EPOLL_CREATE
|
2004-11-20 22:10:04 +00:00
|
|
|
m_sockets.insert(cs);
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-05 23:36:36 +00:00
|
|
|
/// \brief Remove and delete a CommSocket from the server.
|
|
|
|
|
///
|
|
|
|
|
/// Does not take into account if the socket is
|
|
|
|
|
/// @param socket Pointer to the socket object to be removed.
|
2004-11-24 01:19:31 +00:00
|
|
|
void CommServer::removeSocket(CommSocket * cs)
|
2001-09-13 18:21:56 +00:00
|
|
|
{
|
2004-11-24 01:19:31 +00:00
|
|
|
#ifdef HAVE_EPOLL_CREATE
|
|
|
|
|
struct epoll_event ee;
|
|
|
|
|
// FIXME This may not be necessary
|
|
|
|
|
int ret = ::epoll_ctl(m_epollFd, EPOLL_CTL_DEL, cs->getFd(), &ee);
|
|
|
|
|
if (ret != 0) {
|
2006-11-02 05:14:54 +00:00
|
|
|
log(CYLOG_ERROR, "Error calling epoll_ctl to remove socket");
|
|
|
|
|
logSysError(CYLOG_ERROR);
|
2004-11-24 01:19:31 +00:00
|
|
|
}
|
|
|
|
|
#endif // HAVE_EPOLL_CREATE
|
|
|
|
|
m_sockets.erase(cs);
|
|
|
|
|
delete cs;
|
2001-09-13 18:21:56 +00:00
|
|
|
}
|