Author: erijo
Date: Mon Oct 25 05:16:08 2010
New Revision: 7947
Log:
Run ICQ in the thread that is created by the PluginManager
Modified:
trunk/licq/include/licq/contactlist/user.h
trunk/licq/include/licq/event.h
trunk/licq/src/icq/icq.cpp
trunk/licq/src/icq/icq.h
trunk/licq/src/icq/icqprotocolplugin.cpp
trunk/licq/src/icq/threads.cpp
trunk/licq/src/licq.cpp
Modified: trunk/licq/include/licq/contactlist/user.h
==============================================================================
--- trunk/licq/include/licq/contactlist/user.h (original)
+++ trunk/licq/include/licq/contactlist/user.h Mon Oct 25 05:16:08 2010
@@ -36,7 +36,7 @@
class CSocketManager;
class IcqProtocol;
namespace Jabber { class Plugin; }
-void* MonitorSockets_tep(void *);
+void* MonitorSockets_func();
namespace LicqDaemon
@@ -895,7 +895,7 @@
friend class ::CMSN;
friend class ::IcqProtocol;
friend class Jabber::Plugin;
- friend void* ::MonitorSockets_tep(void *);
+ friend void* ::MonitorSockets_func();
};
Modified: trunk/licq/include/licq/event.h
==============================================================================
--- trunk/licq/include/licq/event.h (original)
+++ trunk/licq/include/licq/event.h Mon Oct 25 05:16:08 2010
@@ -296,7 +296,6 @@
friend void* ::ProcessRunningEvent_Client_tep(void* p);
friend void* ::ProcessRunningEvent_Server_tep(void* p);
friend void* ::OscarServiceSendQueue_tep(void* p);
-//friend void *MonitorSockets_tep(void *p);
};
} // namespace Licq
Modified: trunk/licq/src/icq/icq.cpp
==============================================================================
--- trunk/licq/src/icq/icq.cpp (original)
+++ trunk/licq/src/icq/icq.cpp Mon Oct 25 05:16:08 2010
@@ -153,12 +153,7 @@
gSocketManager.DropSocket(s);
gLog.info(tr("Spawning daemon threads"));
- nResult = pthread_create(&thread_monitorsockets, NULL, &MonitorSockets_tep, this);
- if (nResult != 0)
- {
- gLog.error("%sUnable to start socket monitor thread:\n%s%s.\n", L_ERRORxSTR, L_BLANKxSTR, strerror(nResult));
- return false;
- }
+
nResult = pthread_create(&thread_ping, NULL, &Ping_tep, this);
if (nResult != 0)
{
@@ -186,6 +181,7 @@
}
}
+ MonitorSockets_func();
return true;
}
Modified: trunk/licq/src/icq/icq.h
==============================================================================
--- trunk/licq/src/icq/icq.h (original)
+++ trunk/licq/src/icq/icq.h Mon Oct 25 05:16:08 2010
@@ -387,8 +387,7 @@
std::map <unsigned long, std::string> m_lszModifyServerUsers;
pthread_mutex_t mutex_modifyserverusers;
pthread_mutex_t mutex_cancelthread;
- pthread_t thread_monitorsockets,
- thread_ping,
+ pthread_t thread_ping,
thread_updateusers,
thread_ssbiservice;
@@ -398,7 +397,7 @@
friend void *Ping_tep(void *p);
friend void *UpdateUsers_tep(void *p);
- friend void *MonitorSockets_tep(void *p);
+ friend void *MonitorSockets_func();
friend void *ProcessRunningEvent_Client_tep(void *p);
friend void *ProcessRunningEvent_Server_tep(void *p);
friend void *Shutdown_tep(void *p);
Modified: trunk/licq/src/icq/icqprotocolplugin.cpp
==============================================================================
--- trunk/licq/src/icq/icqprotocolplugin.cpp (original)
+++ trunk/licq/src/icq/icqprotocolplugin.cpp Mon Oct 25 05:16:08 2010
@@ -16,6 +16,8 @@
* along with Licq; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+
+#include "icq.h"
#include <unistd.h>
@@ -54,6 +56,7 @@
bool LProto_icq_Init()
{
+ gIcqProtocol.initialize();
return true;
}
@@ -69,33 +72,7 @@
int LProto_icq_Main()
{
- int fd = gPluginManager.registerProtocolPlugin();
- if (fd == -1)
- return -1;
-
- bool run = true;
- while (run)
- {
- fd_set readFd;
- FD_ZERO(&readFd);
- FD_SET(fd, &readFd);
- int ret = ::select(fd + 1, &readFd, NULL, NULL, NULL);
- if (ret > 0 && FD_ISSET(fd, &readFd))
- {
- char ch;
- ::read(fd, &ch, sizeof(ch));
- switch (ch)
- {
- case Licq::ProtocolPlugin::PipeShutdown:
- run = false;
- break;
- default:
- assert(false);
- break;
- }
- }
- }
-
- gPluginManager.unregisterProtocolPlugin();
+ if (!gIcqProtocol.start())
+ return 1;
return 0;
}
Modified: trunk/licq/src/icq/threads.cpp
==============================================================================
--- trunk/licq/src/icq/threads.cpp (original)
+++ trunk/licq/src/icq/threads.cpp Mon Oct 25 05:16:08 2010
@@ -666,23 +666,18 @@
/*------------------------------------------------------------------------------
- * MonitorSockets_tep
+ * MonitorSockets_func
*
* The server thread lives here. The main guy who waits on socket activity
* and processes incoming packets.
*----------------------------------------------------------------------------*/
-void *MonitorSockets_tep(void* /* p */)
-{
- //pthread_detach(pthread_self());
-
+void *MonitorSockets_func()
+{
fd_set f;
int nSocketsAvailable, nServiceSocket, l;
while (true)
{
- /*pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
- pthread_testcancel();*/
-
f = gSocketManager.socketSet();
l = gSocketManager.LargestSocket() + 1;
@@ -701,8 +696,6 @@
nSocketsAvailable = select(l, &f, NULL, NULL, NULL);
- /*pthread_testcancel();
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);*/
if (gIcqProtocol.m_xBARTService)
{
COscarService *svc = gIcqProtocol.m_xBARTService;
@@ -730,7 +723,7 @@
else if (buf == 'X')
{
DEBUG_THREADS("[MonitorSockets_tep] Exiting.\n");
- pthread_exit(NULL);
+ return NULL;
}
}
@@ -967,9 +960,6 @@
if (gIcqProtocol.m_xBARTService)
pthread_cancel(gIcqProtocol.thread_ssbiservice);
- // Join our threads
- pthread_join(gIcqProtocol.thread_monitorsockets, NULL);
-
if (gIcqProtocol.m_nTCPSrvSocketDesc != -1 )
gIcqProtocol.icqLogoff();
if (gIcqProtocol.m_nTCPSocketDesc != -1)
Modified: trunk/licq/src/licq.cpp
==============================================================================
--- trunk/licq/src/licq.cpp (original)
+++ trunk/licq/src/licq.cpp Mon Oct 25 05:16:08 2010
@@ -36,7 +36,6 @@
#include "daemon.h"
#include "fifo.h"
#include "gettext.h"
-#include "icq/icq.h"
#include "logging/streamlogsink.h"
#include "oneventmanager.h"
#include "plugins/pluginmanager.h"
@@ -628,9 +627,6 @@
gStatistics.initialize();
gUtilityManager.loadUtilities(gDaemon.shareDir() + Daemon::UtilityDir);
- // Create the daemon
- gIcqProtocol.initialize();
-
return true;
}
@@ -777,9 +773,6 @@
}
gFifo.initialize();
-
- if (!gIcqProtocol.start())
- return 1;
// Run the plugins
gPluginManager.startAllPlugins();
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.