diff options
author | Szymon Tokarz <wsx22@o2.pl> | 2012-11-03 00:42:26 +0000 |
---|---|---|
committer | Szymon Tokarz <wsx22@o2.pl> | 2012-11-03 00:42:26 +0000 |
commit | b6c5e03eb8c6e746ec4b1f28c472c93305986bbf (patch) | |
tree | 7007abe8c39ee405d6fd9cc1f23287fc836eaaec /protocols/Gadu-Gadu/src | |
parent | 3a0bfdecae261d7a33c2114ec47dda0eaafe6572 (diff) |
GaduGadu-Gadu protocol
- more info logged to netlog at debug version. schould help track multithread issues
- netlog logging messages fixes
git-svn-id: http://svn.miranda-ng.org/main/trunk@2157 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Gadu-Gadu/src')
-rw-r--r-- | protocols/Gadu-Gadu/src/avatar.cpp | 96 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/core.cpp | 259 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/dialogs.cpp | 8 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/filetransfer.cpp | 167 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/gg.cpp | 31 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/gg.h | 5 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/gg_proto.cpp | 146 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/gg_proto.h | 36 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/groupchat.cpp | 38 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/image.cpp | 75 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/import.cpp | 36 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/keepalive.cpp | 14 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/oauth.cpp | 20 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/ownerinfo.cpp | 25 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/services.cpp | 38 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/sessions.cpp | 12 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/userutils.cpp | 8 |
17 files changed, 615 insertions, 399 deletions
diff --git a/protocols/Gadu-Gadu/src/avatar.cpp b/protocols/Gadu-Gadu/src/avatar.cpp index 46b41361c3..92bb9f141a 100644 --- a/protocols/Gadu-Gadu/src/avatar.cpp +++ b/protocols/Gadu-Gadu/src/avatar.cpp @@ -52,14 +52,14 @@ void GGPROTO::getAvatarFilename(HANDLE hContact, TCHAR *pszDest, int cbLen) if (hContact != NULL) {
DBVARIANT dbv;
if (!db_get_s(hContact, m_szModuleName, GG_KEY_AVATARHASH, &dbv, DBVT_ASCIIZ)) {
- TCHAR* avatarHashT = mir_a2t(dbv.pszVal);
+ TCHAR* avatarHashT = mir_a2t(dbv.pszVal);
mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("\\%s.%s"), avatarHashT, avatartype);
- mir_free(avatarHashT);
+ mir_free(avatarHashT);
DBFreeVariant(&dbv);
}
} else {
- mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("\\%s avatar.%s"), m_tszUserName, avatartype);
- }
+ mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("\\%s avatar.%s"), m_tszUserName, avatartype);
+ }
}
void GGPROTO::getAvatarFileInfo(uin_t uin, char **avatarurl, int *type)
@@ -122,10 +122,10 @@ void GGPROTO::getAvatarFileInfo(uin_t uin, char **avatarurl, int *type) mir_free(tag);
mir_free(xmlAction);
}
- else netlog("gg_getavatarfileinfo(): Invalid response code from HTTP request");
+ else netlog("getAvatarFileInfo(): Invalid response code from HTTP request");
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp);
}
- else netlog("gg_getavatarfileinfo(): No response from HTTP request");
+ else netlog("getAvatarFileInfo(): No response from HTTP request");
}
char *gg_avatarhash(char *param)
@@ -152,13 +152,16 @@ typedef struct void GGPROTO::getAvatar(HANDLE hContact, char *szAvatarURL)
{
+#ifdef DEBUGMODE
+ netlog("getAvatar(): start");
+#endif
if (pth_avatar.dwThreadId) {
GGGETAVATARDATA *data = (GGGETAVATARDATA*)mir_alloc(sizeof(GGGETAVATARDATA));
data->hContact = hContact;
data->AvatarURL = mir_strdup(szAvatarURL);
- EnterCriticalSection(&avatar_mutex);
+ gg_EnterCriticalSection(&avatar_mutex, "getAvatar", 1, "avatar_mutex", 1);
list_add(&avatar_transfers, data, 0);
- LeaveCriticalSection(&avatar_mutex);
+ gg_LeaveCriticalSection(&avatar_mutex, "getAvatar", 1, 1, "avatar_mutex", 1);
}
}
@@ -170,14 +173,18 @@ typedef struct void GGPROTO::requestAvatar(HANDLE hContact, int iWaitFor)
{
+#ifdef DEBUGMODE
+ netlog("requestAvatar(): start");
+#endif
+
if (db_get_b(NULL, m_szModuleName, GG_KEY_ENABLEAVATARS, GG_KEYDEF_ENABLEAVATARS)
&& pth_avatar.dwThreadId) {
GGREQUESTAVATARDATA *data = (GGREQUESTAVATARDATA*)mir_alloc(sizeof(GGREQUESTAVATARDATA));
data->hContact = hContact;
data->iWaitFor = iWaitFor;
- EnterCriticalSection(&avatar_mutex);
+ gg_EnterCriticalSection(&avatar_mutex, "requestAvatar", 2, "avatar_mutex", 1);
list_add(&avatar_requests, data, 0);
- LeaveCriticalSection(&avatar_mutex);
+ gg_LeaveCriticalSection(&avatar_mutex, "requestAvatar", 2, 1, "avatar_mutex", 1);
}
}
@@ -185,10 +192,10 @@ void __cdecl GGPROTO::avatarrequestthread(void*) {
list_t l;
- netlog("gg_avatarrequestthread(): Avatar Request Thread Starting");
+ netlog("avatarrequestthread() started. Avatar Request Thread Starting");
while (pth_avatar.dwThreadId)
{
- EnterCriticalSection(&avatar_mutex);
+ gg_EnterCriticalSection(&avatar_mutex, "avatarrequestthread", 3, "avatar_mutex", 1);
if (avatar_requests) {
GGREQUESTAVATARDATA *data = (GGREQUESTAVATARDATA *)avatar_requests->data;
char *AvatarURL;
@@ -197,7 +204,7 @@ void __cdecl GGPROTO::avatarrequestthread(void*) list_remove(&avatar_requests, data, 0);
mir_free(data);
- LeaveCriticalSection(&avatar_mutex);
+ gg_LeaveCriticalSection(&avatar_mutex, "avatarrequestthread", 3, 1, "avatar_mutex", 1);
getAvatarFileInfo( db_get_dw(hContact, m_szModuleName, GG_KEY_UIN, 0), &AvatarURL, &AvatarType);
if (AvatarURL != NULL && strlen(AvatarURL) > 0)
@@ -215,10 +222,11 @@ void __cdecl GGPROTO::avatarrequestthread(void*) ProtoBroadcastAck(m_szModuleName, hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&pai, 0);
}
else ProtoBroadcastAck(m_szModuleName, hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, 0, 0);
+ } else {
+ gg_LeaveCriticalSection(&avatar_mutex, "avatarrequestthread", 3, 2, "avatar_mutex", 1);
}
- else LeaveCriticalSection(&avatar_mutex);
- EnterCriticalSection(&avatar_mutex);
+ gg_EnterCriticalSection(&avatar_mutex, "avatarrequestthread", 4, "avatar_mutex", 1);
if (avatar_transfers) {
GGGETAVATARDATA *data = (GGGETAVATARDATA *)avatar_transfers->data;
NETLIBHTTPREQUEST req = {0};
@@ -247,10 +255,10 @@ void __cdecl GGPROTO::avatarrequestthread(void*) result = 1;
}
}
- else netlog("gg_avatarrequestthread(): Invalid response code from HTTP request");
+ else netlog("avatarrequestthread(): Invalid response code from HTTP request");
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp);
}
- else netlog("gg_avatarrequestthread(): No response from HTTP request");
+ else netlog("avatarrequestthread(): No response from HTTP request");
ProtoBroadcastAck(m_szModuleName, pai.hContact, ACKTYPE_AVATAR,
result ? ACKRESULT_SUCCESS : ACKRESULT_FAILED, (HANDLE)&pai, 0);
@@ -262,8 +270,8 @@ void __cdecl GGPROTO::avatarrequestthread(void*) mir_free(data->AvatarURL);
mir_free(data);
}
- LeaveCriticalSection(&avatar_mutex);
- SleepEx(100, FALSE);
+ gg_LeaveCriticalSection(&avatar_mutex, "avatarrequestthread", 4, 1, "avatar_mutex", 1);
+ gg_sleep(100, FALSE, "avatarrequestthread", 101, 1);
}
for (l = avatar_requests; l; l = l->next) {
@@ -277,7 +285,7 @@ void __cdecl GGPROTO::avatarrequestthread(void*) }
list_destroy(avatar_requests, 0);
list_destroy(avatar_transfers, 0);
- netlog("gg_avatarrequestthread(): Avatar Request Thread Ending");
+ netlog("avatarrequestthread(): end. Avatar Request Thread Ending");
}
void GGPROTO::initavatarrequestthread()
@@ -287,6 +295,9 @@ void GGPROTO::initavatarrequestthread() GetExitCodeThread(pth_avatar.hThread, &exitCode);
if (exitCode != STILL_ACTIVE) {
avatar_requests = avatar_transfers = NULL;
+#ifdef DEBUGMODE
+ netlog("initavatarrequestthread(): forkthreadex 1 GGPROTO::avatarrequestthread");
+#endif
pth_avatar.hThread = forkthreadex(&GGPROTO::avatarrequestthread, NULL, &pth_avatar.dwThreadId);
}
}
@@ -295,9 +306,12 @@ void GGPROTO::uninitavatarrequestthread() {
pth_avatar.dwThreadId = 0;
#ifdef DEBUGMODE
- netlog("gg_uninitavatarrequestthread(): Waiting until Avatar Request Thread finished, if needed.");
+ netlog("initavatarrequestthread() Waiting pth_avatar thread. Waiting until Avatar Request Thread finished, if needed.");
#endif
threadwait(&pth_avatar);
+#ifdef DEBUGMODE
+ netlog("initavatarrequestthread() Waiting pth_avatar thread - OK");
+#endif
}
void __cdecl GGPROTO::getuseravatarthread(void*)
@@ -305,6 +319,8 @@ void __cdecl GGPROTO::getuseravatarthread(void*) char *AvatarURL;
int AvatarType;
+ netlog("getuseravatarthread() started");
+
getAvatarFileInfo( db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0), &AvatarURL, &AvatarType);
if (AvatarURL != NULL && strlen(AvatarURL) > 0)
db_set_s(NULL, m_szModuleName, GG_KEY_AVATARURL, AvatarURL);
@@ -317,13 +333,20 @@ void __cdecl GGPROTO::getuseravatarthread(void*) PROTO_AVATAR_INFORMATIONT pai = {0};
pai.cbSize = sizeof(pai);
getavatarinfo((WPARAM)GAIF_FORCE, (LPARAM)&pai);
+#ifdef DEBUGMODE
+ netlog("getuseravatarthread(): end");
+#endif
}
void GGPROTO::getUserAvatar()
{
if (db_get_b(NULL, m_szModuleName, GG_KEY_ENABLEAVATARS, GG_KEYDEF_ENABLEAVATARS)
- && db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0))
+ && db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0)){
+#ifdef DEBUGMODE
+ netlog("getUserAvatar(): forkthread 2 GGPROTO::getuseravatarthread");
+#endif
forkthread(&GGPROTO::getuseravatarthread, NULL);
+ }
}
void __cdecl GGPROTO::setavatarthread(void *param)
@@ -336,14 +359,17 @@ void __cdecl GGPROTO::setavatarthread(void *param) char szUrl[128], uin[32], *authHeader, *data, *avatardata, content[256], image_ext[4], image_type[11];
int file_fd, avatardatalen, datalen, contentlen, contentendlen, res = 0, repeat = 0;
- netlog("gg_setavatar(): Trying to set user avatar using %s...", szFilename);
+ netlog("setavatarthread(): started. Trying to set user avatar using %s...", szFilename);
UIN2ID( db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0), uin);
file_fd = _topen(szFilename, _O_RDONLY | _O_BINARY, _S_IREAD);
if (file_fd == -1) {
- netlog("gg_setavatar(): Failed to open avatar file (%s).", strerror(errno));
+ netlog("setavatarthread(): Failed to open avatar file (%s).", strerror(errno));
mir_free(szFilename);
getUserAvatar();
+#ifdef DEBUGMODE
+ netlog("setavatarthread(): end. err1");
+#endif
return;
}
avatardatalen = _filelength(file_fd);
@@ -403,16 +429,16 @@ void __cdecl GGPROTO::setavatarthread(void *param) if (resp) {
if (resp->resultCode == 200 && resp->dataLength > 0 && resp->pData) {
#ifdef DEBUGMODE
- netlog("%s", resp->pData);
+ netlog("setavatarthread(): 1 resp.data= %s", resp->pData);
#endif
res = 1;
}
- else netlog("gg_setavatar(): Invalid response code from HTTP request");
+ else netlog("setavatarthread() Invalid response code from HTTP request");
if (resp->resultCode == 403 || resp->resultCode == 401)
repeat = 1;
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp);
}
- else netlog("gg_setavatar(): No response from HTTP request");
+ else netlog("setavatarthread(): No response from HTTP request");
if (repeat) { // Access Token expired - we need to obtain new
mir_free(authHeader);
@@ -433,14 +459,14 @@ void __cdecl GGPROTO::setavatarthread(void *param) if (resp) {
if (resp->resultCode == 200 && resp->dataLength > 0 && resp->pData) {
#ifdef DEBUGMODE
- netlog("%s", resp->pData);
+ netlog("setavatarthread(): 2 resp.data= %s", resp->pData);
#endif
res = 1;
}
- else netlog("gg_setavatar(): Invalid response code from HTTP request");
+ else netlog("setavatarthread(): Invalid response code from HTTP request");
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp);
}
- else netlog("gg_setavatar(): No response from HTTP request");
+ else netlog("setavatarthread(): No response from HTTP request");
}
mir_free(authHeader);
@@ -448,15 +474,21 @@ void __cdecl GGPROTO::setavatarthread(void *param) mir_free(data);
if (res)
- netlog("gg_setavatar(): User avatar set successfully.");
+ netlog("setavatarthread(): User avatar set successfully.");
else
- netlog("gg_setavatar(): Failed to set user avatar.");
+ netlog("setavatarthread(): Failed to set user avatar.");
mir_free(szFilename);
getUserAvatar();
+#ifdef DEBUGMODE
+ netlog("setavatarthread(): end.");
+#endif
}
void GGPROTO::setAvatar(const TCHAR *szFilename)
{
+#ifdef DEBUGMODE
+ netlog("setAvatar(): forkthread 3 GGPROTO::setavatarthread");
+#endif
forkthread(&GGPROTO::setavatarthread, mir_tstrdup(szFilename));
}
diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp index 02a12bbf9f..f790be87d3 100644 --- a/protocols/Gadu-Gadu/src/core.cpp +++ b/protocols/Gadu-Gadu/src/core.cpp @@ -39,8 +39,15 @@ uint32_t swap32(uint32_t x) int GGPROTO::isonline()
{
- mir_cslock lck(sess_mutex);
- return (sess != NULL);
+
+ int isonline;
+
+ gg_EnterCriticalSection(&sess_mutex, "isonline", 76, "sess_mutex", 1);
+ isonline = (sess != NULL);
+ gg_LeaveCriticalSection(&sess_mutex, "isonline", 76, 1, "sess_mutex", 1);
+
+ return isonline;
+
}
////////////////////////////////////////////////////////////
@@ -59,9 +66,9 @@ void GGPROTO::disconnect() DBVARIANT dbv;
switch (db_get_w(NULL, m_szModuleName, GG_KEY_LEAVESTATUS, GG_KEYDEF_LEAVESTATUS)) {
case ID_STATUS_ONLINE:
- EnterCriticalSection(&modemsg_mutex);
+ gg_EnterCriticalSection(&modemsg_mutex, "disconnect", 6, "modemsg_mutex", 1);
szMsg = mir_strdup(modemsg.online);
- LeaveCriticalSection(&modemsg_mutex);
+ gg_LeaveCriticalSection(&modemsg_mutex, "disconnect", 6, 1, "modemsg_mutex", 1);
if (!szMsg && !db_get_s(NULL, "SRAway", gg_status2db(ID_STATUS_ONLINE, "Default"), &dbv, DBVT_ASCIIZ)) {
if (dbv.pszVal && *(dbv.pszVal))
szMsg = mir_strdup(dbv.pszVal);
@@ -69,9 +76,9 @@ void GGPROTO::disconnect() }
break;
case ID_STATUS_AWAY:
- EnterCriticalSection(&modemsg_mutex);
+ gg_EnterCriticalSection(&modemsg_mutex, "disconnect", 7, "modemsg_mutex", 1);
szMsg = mir_strdup(modemsg.away);
- LeaveCriticalSection(&modemsg_mutex);
+ gg_LeaveCriticalSection(&modemsg_mutex, "disconnect", 7, 1, "modemsg_mutex", 1);
if (!szMsg && !db_get_s(NULL, "SRAway", gg_status2db(ID_STATUS_AWAY, "Default"), &dbv, DBVT_ASCIIZ)) {
if (dbv.pszVal && *(dbv.pszVal))
szMsg = mir_strdup(dbv.pszVal);
@@ -79,9 +86,9 @@ void GGPROTO::disconnect() }
break;
case ID_STATUS_DND:
- EnterCriticalSection(&modemsg_mutex);
+ gg_EnterCriticalSection(&modemsg_mutex, "disconnect", 8, "modemsg_mutex", 1);
szMsg = mir_strdup(modemsg.dnd);
- LeaveCriticalSection(&modemsg_mutex);
+ gg_LeaveCriticalSection(&modemsg_mutex, "disconnect", 8, 1, "modemsg_mutex", 1);
if (!szMsg && !db_get_s(NULL, "SRAway", gg_status2db(ID_STATUS_DND, "Default"), &dbv, DBVT_ASCIIZ)) {
if (dbv.pszVal && *(dbv.pszVal))
szMsg = mir_strdup(dbv.pszVal);
@@ -89,9 +96,9 @@ void GGPROTO::disconnect() }
break;
case ID_STATUS_FREECHAT:
- EnterCriticalSection(&modemsg_mutex);
+ gg_EnterCriticalSection(&modemsg_mutex, "disconnect", 9, "modemsg_mutex", 1);
szMsg = mir_strdup(modemsg.freechat);
- LeaveCriticalSection(&modemsg_mutex);
+ gg_LeaveCriticalSection(&modemsg_mutex, "disconnect", 9, 1, "modemsg_mutex", 1);
if (!szMsg && !db_get_s(NULL, "SRAway", gg_status2db(ID_STATUS_FREECHAT, "Default"), &dbv, DBVT_ASCIIZ)) {
if (dbv.pszVal && *(dbv.pszVal))
szMsg = mir_strdup(dbv.pszVal);
@@ -99,9 +106,9 @@ void GGPROTO::disconnect() }
break;
case ID_STATUS_INVISIBLE:
- EnterCriticalSection(&modemsg_mutex);
+ gg_EnterCriticalSection(&modemsg_mutex, "disconnect", 10, "modemsg_mutex", 1);
szMsg = mir_strdup(modemsg.invisible);
- LeaveCriticalSection(&modemsg_mutex);
+ gg_LeaveCriticalSection(&modemsg_mutex, "disconnect", 10, 1, "modemsg_mutex", 1);
if (!szMsg && !db_get_s(NULL, "SRAway", gg_status2db(ID_STATUS_INVISIBLE, "Default"), &dbv, DBVT_ASCIIZ)) {
if (dbv.pszVal && *(dbv.pszVal))
szMsg = mir_strdup(dbv.pszVal);
@@ -110,13 +117,13 @@ void GGPROTO::disconnect() break;
default:
// Set last status
- EnterCriticalSection(&modemsg_mutex);
+ gg_EnterCriticalSection(&modemsg_mutex, "disconnect", 11, "modemsg_mutex", 1);
szMsg = mir_strdup(getstatusmsg(m_iStatus));
- LeaveCriticalSection(&modemsg_mutex);
+ gg_LeaveCriticalSection(&modemsg_mutex, "disconnect", 11, 1, "modemsg_mutex", 1);
}
}
- EnterCriticalSection(&sess_mutex);
+ gg_EnterCriticalSection(&sess_mutex, "disconnect", 12, "sess_mutex", 1);
// Check if it has message
if (szMsg)
{
@@ -130,7 +137,7 @@ void GGPROTO::disconnect() // Send logoff immediately
gg_logoff(sess);
}
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "disconnect", 12, 1, "sess_mutex", 1);
}
// Else cancel connection attempt
else if (sock)
@@ -246,7 +253,7 @@ void __cdecl GGPROTO::mainthread(void *) time_t timeDeviation = db_get_w(NULL, m_szModuleName, GG_KEY_TIMEDEVIATION, GG_KEYDEF_TIMEDEVIATION);
int gg_failno = 0;
- netlog("gg_mainthread(%x): Server Thread Starting", this);
+ netlog("mainthread(): started. (%x) Server Thread Starting", this);
#ifdef DEBUGMODE
gg_debug_level = GG_DEBUG_NET | GG_DEBUG_TRAFFIC | GG_DEBUG_FUNCTION | GG_DEBUG_MISC;
#else
@@ -279,7 +286,7 @@ void __cdecl GGPROTO::mainthread(void *) if (CallService(MS_NETLIB_GETUSERSETTINGS, (WPARAM)netlib, (LPARAM)&nlus))
{
if (nlus.useProxy)
- netlog("gg_mainthread(%x): Using proxy %s:%d.", this, nlus.szProxyServer, nlus.wProxyPort);
+ netlog("mainthread() (%x): Using proxy %s:%d.", this, nlus.szProxyServer, nlus.wProxyPort);
gg_proxy_enabled = nlus.useProxy;
gg_proxy_host = nlus.szProxyServer;
gg_proxy_port = nlus.wProxyPort;
@@ -293,7 +300,7 @@ void __cdecl GGPROTO::mainthread(void *) }
else
{
- netlog("gg_mainthread(%x): Failed loading proxy settings.", this);
+ netlog("mainthread() (%x): Failed loading proxy settings.", this);
gg_proxy_enabled = 0;
}
@@ -316,23 +323,29 @@ void __cdecl GGPROTO::mainthread(void *) }
else
{
- netlog("gg_mainthread(%x): No password specified. Exiting.", this);
+ netlog("mainthread() (%x): No password specified. Exiting.", this);
broadcastnewstatus(ID_STATUS_OFFLINE);
+#ifdef DEBUGMODE
+ netlog("mainthread(): end. err1");
+#endif
return;
}
// Readup number
if (!(p.uin = db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0)))
{
- netlog("gg_mainthread(%x): No Gadu-Gadu number specified. Exiting.", this);
+ netlog("mainthread() (%x): No Gadu-Gadu number specified. Exiting.", this);
broadcastnewstatus(ID_STATUS_OFFLINE);
mir_free(p.password);
+#ifdef DEBUGMODE
+ netlog("mainthread(): end. err2");
+#endif
return;
}
// Readup SSL/TLS setting
if (p.tls = db_get_b(NULL, m_szModuleName, GG_KEY_SSLCONN, GG_KEYDEF_SSLCONN))
- netlog("gg_mainthread(%x): Using TLS/SSL for connections.", this);
+ netlog("mainthread() (%x): Using TLS/SSL for connections.", this);
// Gadu-Gadu accepts image sizes upto 255
p.image_size = 255;
@@ -346,7 +359,7 @@ void __cdecl GGPROTO::mainthread(void *) // Wait for DCC
#ifdef DEBUGMODE
- netlog("gg_mainthread(%x): Waiting DCC service to start...", this);
+ netlog("mainthread() (%x): Waiting DCC service to start...", this);
#endif
while (WaitForSingleObjectEx(hEvent, INFINITE, TRUE) != WAIT_OBJECT_0);
CloseHandle(hEvent); hEvent = NULL;
@@ -365,7 +378,7 @@ void __cdecl GGPROTO::mainthread(void *) showpopup(m_tszUserName, error, GG_POPUP_WARNING | GG_POPUP_ALLOW_MSGBOX);
}
else
- netlog("gg_mainthread(%x): Loading forwarding host %s and port %d.", dbv.pszVal, p.external_port, this);
+ netlog("mainthread() (%x): Loading forwarding host %s and port %d.", dbv.pszVal, p.external_port, this);
if (p.external_addr) p.external_port = db_get_w(NULL, m_szModuleName, GG_KEY_FORWARDPORT, GG_KEYDEF_FORWARDPORT);
DBFreeVariant(&dbv);
}
@@ -375,13 +388,13 @@ void __cdecl GGPROTO::mainthread(void *) retry:
// Loadup startup status & description
- EnterCriticalSection(&modemsg_mutex);
+ gg_EnterCriticalSection(&modemsg_mutex, "mainthread", 13, "modemsg_mutex", 1);
p.status_descr = mir_strdup(getstatusmsg(m_iDesiredStatus));
p.status = status_m2gg(m_iDesiredStatus, p.status_descr != NULL);
- netlog("gg_mainthread(%x): Connecting with number %d, status %d and description \"%s\".", this, p.uin, m_iDesiredStatus,
+ netlog("mainthread() (%x): Connecting with number %d, status %d and description \"%s\".", this, p.uin, m_iDesiredStatus,
p.status_descr ? p.status_descr : "<none>");
- LeaveCriticalSection(&modemsg_mutex);
+ gg_LeaveCriticalSection(&modemsg_mutex, "mainthread", 13, 1, "modemsg_mutex", 1);
// Check manual hosts
if (hostnum < hostcount)
@@ -397,7 +410,7 @@ retry: else
{
p.server_port = hosts[hostnum].port;
- netlog("gg_mainthread(%x): Connecting to manually specified host %s (%d.%d.%d.%d) and port %d.", this,
+ netlog("mainthread() (%x): Connecting to manually specified host %s (%d.%d.%d.%d) and port %d.", this,
hosts[hostnum].hostname, LOBYTE(LOWORD(p.server_addr)), HIBYTE(LOWORD(p.server_addr)),
LOBYTE(HIWORD(p.server_addr)), HIBYTE(HIWORD(p.server_addr)), p.server_port);
}
@@ -424,7 +437,7 @@ retry: mir_sntprintf(error, SIZEOF(error), TranslateT("Connection cannot be established because of error:\n\t%s"), _tcserror(errno));
perror = error;
}
- netlog("gg_mainthread(%x): %s", this, perror);
+ netlog("mainthread() (%x): %s", this, perror);
if (db_get_b(NULL, m_szModuleName, GG_KEY_SHOWCERRORS, GG_KEYDEF_SHOWCERRORS))
showpopup(m_tszUserName, perror, GG_POPUP_ERROR | GG_POPUP_ALLOW_MSGBOX | GG_POPUP_ONCE);
@@ -454,21 +467,21 @@ retry: }
}
// We cannot do more about this
- EnterCriticalSection(&modemsg_mutex);
+ gg_EnterCriticalSection(&modemsg_mutex, "mainthread", 14, "modemsg_mutex", 1);
m_iDesiredStatus = ID_STATUS_OFFLINE;
- LeaveCriticalSection(&modemsg_mutex);
+ gg_LeaveCriticalSection(&modemsg_mutex, "mainthread", 14, 1, "modemsg_mutex", 1);
}
else
- netlog("gg_mainthread(%x)): Connection attempt cancelled by the user.", this);
+ netlog("mainthread() (%x)): Connection attempt cancelled by the user.", this);
}
else
{
// Successfully connected
logonTime = time(NULL);
db_set_dw(NULL, m_szModuleName, GG_KEY_LOGONTIME, logonTime);
- EnterCriticalSection(&sess_mutex);
+ gg_EnterCriticalSection(&sess_mutex, "mainthread", 15, "sess_mutex", 1);
sess = sess;
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "mainthread", 15, 1, "sess_mutex", 1);
// Subscribe users status notifications
notifyall();
// Set startup status
@@ -495,17 +508,27 @@ retry: while(isonline())
{
// Connection broken/closed
+#ifdef DEBUGMODE
+ netlog("mainthread(): waiting for gg_watch_fd");
+#endif
if (!(e = gg_watch_fd(sess)))
{
- netlog("gg_mainthread(%x): Connection closed.", this);
- EnterCriticalSection(&sess_mutex);
+#ifdef DEBUGMODE
+ netlog("mainthread(): waiting for gg_watch_fd - DONE error");
+#endif
+ netlog("mainthread() (%x): Connection closed.", this);
+ gg_EnterCriticalSection(&sess_mutex, "mainthread", 16, "sess_mutex", 1);
gg_free_session(sess);
sess = NULL;
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "mainthread", 16, 1, "sess_mutex", 1);
break;
}
- else
- netlog("gg_mainthread(%x): Event: %s", this, ggdebug_eventtype(e));
+ else {
+#ifdef DEBUGMODE
+ netlog("mainthread(): waiting for gg_watch_fd - DONE");
+#endif
+ netlog("mainthread() (%x): Event: %s", this, ggdebug_eventtype(e));
+ }
switch(e->type)
{
@@ -517,10 +540,10 @@ retry: // Client disconnected or connection failure
case GG_EVENT_CONN_FAILED:
case GG_EVENT_DISCONNECT:
- EnterCriticalSection(&sess_mutex);
+ gg_EnterCriticalSection(&sess_mutex, "mainthread", 17, "sess_mutex", 1);
gg_free_session(sess);
sess = NULL;
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "mainthread", 17, 1, "sess_mutex", 1);
break;
// Client allowed to disconnect
@@ -578,18 +601,18 @@ retry: if (e->type == GG_EVENT_PUBDIR50_SEARCH_REPLY)
{
- netlog("gg_mainthread(%x): Got user info.", this);
+ netlog("mainthread() (%x): Got user info.", this);
// Store next search UIN
if (res->seq == GG_SEQ_SEARCH)
next_uin = gg_pubdir50_next(res);
}
else if (e->type == GG_EVENT_PUBDIR50_READ)
{
- netlog("gg_mainthread(%x): Got owner info.", this);
+ netlog("mainthread() (%x): Got owner info.", this);
}
else if (e->type == GG_EVENT_PUBDIR50_WRITE)
{
- netlog("gg_mainthread(%x): Public directory save succesful.", this);
+ netlog("mainthread() (%x): Public directory save succesful.", this);
// Update user details
GetInfo(NULL, 0);
}
@@ -612,7 +635,7 @@ retry: uin_t uin = __fmnumber ? atoi(__fmnumber) : 0;
HANDLE hContact = (res->seq == GG_SEQ_CHINFO) ? NULL : getcontact(uin, 0, 0, NULL);
- netlog("gg_mainthread(%x): Search result for uin %d, seq %d.", this, uin, res->seq);
+ netlog("mainthread() (%x): Search result for uin %d, seq %d.", this, uin, res->seq);
if (res->seq == GG_SEQ_SEARCH)
{
char strFmt1[64];
@@ -727,7 +750,7 @@ retry: db_unset(NULL, m_szModuleName, "Gender");
}
- netlog("gg_mainthread(%x): Setting user info for uin %d.", this, uin);
+ netlog("mainthread() (%x): Setting user info for uin %d.", this, uin);
ProtoBroadcastAck(m_szModuleName, hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE) 1, 0);
}
}
@@ -813,7 +836,7 @@ retry: gcevent.ptszNick = (TCHAR*) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) getcontact(e->event.msg.sender, 1, 0, NULL), GCDNF_TCHAR);
gcevent.time = (!(e->event.msg.msgclass & GG_CLASS_OFFLINE) || e->event.msg.time > (t - timeDeviation)) ? t : e->event.msg.time;
gcevent.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
- netlog("gg_mainthread(%x): Conference message to room %s & id %s.", this, chat, id);
+ netlog("mainthread() (%x): Conference message to room %s & id %s.", this, chat, id);
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent);
mir_free(messageT);
}
@@ -846,11 +869,11 @@ retry: if (((struct gg_msg_richtext_format*)formats)->font & GG_FONT_IMAGE)
{
struct gg_msg_richtext_image *image = (struct gg_msg_richtext_image *)(formats + add_ptr);
- EnterCriticalSection(&sess_mutex);
+ gg_EnterCriticalSection(&sess_mutex, "mainthread", 18, "sess_mutex", 1);
gg_image_request(sess, e->event.msg.sender, image->size, image->crc32);
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "mainthread", 18, 1, "sess_mutex", 1);
- netlog("gg_mainthread: image request sent!");
+ netlog("mainthread(): image request sent!");
add_ptr += sizeof(struct gg_msg_richtext_image);
}
if (((struct gg_msg_richtext_format*)formats)->font & GG_FONT_COLOR)
@@ -890,7 +913,7 @@ retry: gcevent.time = e->event.multilogon_msg.time;
gcevent.bIsMe = 1;
gcevent.dwFlags = GCEF_ADDTOLOG;
- netlog("gg_mainthread(%x): Sent conference message to room %s.", this, chat);
+ netlog("mainthread() (%x): Sent conference message to room %s.", this, chat);
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent);
mir_free(messageT);
if (pszValT != NULL) mir_free(pszValT);;
@@ -916,10 +939,10 @@ retry: {
list_t l;
int* iIndexes = NULL, i;
- netlog("gg_mainthread(): Concurrent sessions count: %d.", e->event.multilogon_info.count);
+ netlog("mainthread(): Concurrent sessions count: %d.", e->event.multilogon_info.count);
if (e->event.multilogon_info.count > 0)
iIndexes = (int*)mir_calloc(e->event.multilogon_info.count * sizeof(int));
- EnterCriticalSection(&sessions_mutex);
+ gg_EnterCriticalSection(&sessions_mutex, "mainthread", 19, "sess_mutex", 1);
for (l = sessions; l; l = l->next)
{
struct gg_multilogon_session* sess = (struct gg_multilogon_session*)l->data;
@@ -945,7 +968,7 @@ retry: : Translate("Unknown client"));
list_add(&sessions, sess, 0);
}
- LeaveCriticalSection(&sessions_mutex);
+ gg_LeaveCriticalSection(&sessions_mutex, "mainthread", 19, 1, "sessions_mutex", 1);
sessions_updatedlg();
if (ServiceExists(MS_POPUP_ADDPOPUPCLASS))
{
@@ -1016,7 +1039,7 @@ retry: case GG_EVENT_DCC7_NEW:
{
struct gg_dcc7 *dcc7 = e->event.dcc7_new;
- netlog("gg_mainthread(%x): Incoming direct connection.", this);
+ netlog("mainthread() (%x): Incoming direct connection.", this);
dcc7->contact = getcontact(dcc7->peer_uin, 0, 0, NULL);
// Check if user is on the list and if it is my uin
@@ -1027,14 +1050,14 @@ retry: }
// Add to waiting transfers
- EnterCriticalSection(&ft_mutex);
+ gg_EnterCriticalSection(&ft_mutex, "mainthread", 20, "ft_mutex", 1);
list_add(&transfers, dcc7, 0);
- LeaveCriticalSection(&ft_mutex);
+ gg_LeaveCriticalSection(&ft_mutex, "mainthread", 20, 1, "ft_mutex", 1);
//////////////////////////////////////////////////
// Add file recv request
- netlog("gg_mainthread(%x): Client: %d, File ack filename \"%s\" size %d.", this, dcc7->peer_uin,
+ netlog("mainthread() (%x): Client: %d, File ack filename \"%s\" size %d.", this, dcc7->peer_uin,
dcc7->filename, dcc7->size);
TCHAR* filenameT = mir_utf8decodeT((char*)dcc7->filename);
@@ -1061,23 +1084,24 @@ retry: struct gg_dcc7 *dcc7 = e->event.dcc7_reject.dcc7;
if (dcc7->type == GG_SESSION_DCC7_SEND)
{
- netlog("gg_mainthread(%x): File transfer denied by client %d (reason = %d).", this, dcc7->peer_uin, e->event.dcc7_reject.reason);
+ netlog("mainthread() (%x): File transfer denied by client %d (reason = %d).", this, dcc7->peer_uin, e->event.dcc7_reject.reason);
ProtoBroadcastAck(m_szModuleName, dcc7->contact, ACKTYPE_FILE, ACKRESULT_DENIED, dcc7, 0);
// Remove from watches and free
- EnterCriticalSection(&ft_mutex);
+ gg_EnterCriticalSection(&ft_mutex, "mainthread", 21, "ft_mutex", 1);
list_remove(&watches, dcc7, 0);
- LeaveCriticalSection(&ft_mutex);
+ gg_LeaveCriticalSection(&ft_mutex, "mainthread", 21, 1, "ft_mutex", 1);
gg_dcc7_free(dcc7);
}
else
{
- netlog("gg_mainthread(%x): File transfer aborted by client %d.", this, dcc7->peer_uin);
+ netlog("mainthread() (%x): File transfer aborted by client %d.", this, dcc7->peer_uin);
// Remove transfer from waiting list
- EnterCriticalSection(&ft_mutex);
+ gg_EnterCriticalSection(&ft_mutex, "mainthread", 22, "ft_mutex", 1);
list_remove(&transfers, dcc7, 0);
- LeaveCriticalSection(&ft_mutex);
+ gg_LeaveCriticalSection(&ft_mutex, "mainthread", 22, 1, "ft_mutex", 1);
+
}
}
break;
@@ -1089,25 +1113,25 @@ retry: switch (e->event.dcc7_error)
{
case GG_ERROR_DCC7_HANDSHAKE:
- netlog("gg_mainthread(%x): Client: %d, Handshake error.", this, dcc7 ? dcc7->peer_uin : 0);
+ netlog("mainthread() (%x): Client: %d, Handshake error.", this, dcc7 ? dcc7->peer_uin : 0);
break;
case GG_ERROR_DCC7_NET:
- netlog("gg_mainthread(%x): Client: %d, Network error.", this, dcc7 ? dcc7->peer_uin : 0);
+ netlog("mainthread() (%x): Client: %d, Network error.", this, dcc7 ? dcc7->peer_uin : 0);
break;
case GG_ERROR_DCC7_FILE:
- netlog("gg_mainthread(%x): Client: %d, File read/write error.", this, dcc7 ? dcc7->peer_uin : 0);
+ netlog("mainthread() (%x): Client: %d, File read/write error.", this, dcc7 ? dcc7->peer_uin : 0);
break;
case GG_ERROR_DCC7_EOF:
- netlog("gg_mainthread(%x): Client: %d, End of file/connection error.", this, dcc7 ? dcc7->peer_uin : 0);
+ netlog("mainthread() (%x): Client: %d, End of file/connection error.", this, dcc7 ? dcc7->peer_uin : 0);
break;
case GG_ERROR_DCC7_REFUSED:
- netlog("gg_mainthread(%x): Client: %d, Connection refused error.", this, dcc7 ? dcc7->peer_uin : 0);
+ netlog("mainthread() (%x): Client: %d, Connection refused error.", this, dcc7 ? dcc7->peer_uin : 0);
break;
case GG_ERROR_DCC7_RELAY:
- netlog("gg_mainthread(%x): Client: %d, Relay connection error.", this, dcc7 ? dcc7->peer_uin : 0);
+ netlog("mainthread() (%x): Client: %d, Relay connection error.", this, dcc7 ? dcc7->peer_uin : 0);
break;
default:
- netlog("gg_mainthread(%x): Client: %d, Unknown error.", this, dcc7 ? dcc7->peer_uin : 0);
+ netlog("mainthread() (%x): Client: %d, Unknown error.", this, dcc7 ? dcc7->peer_uin : 0);
}
if (!dcc7) break;
@@ -1152,10 +1176,10 @@ retry: tag = mir_a2t("event/sender");
node = xi.getChildByPath(hXml, tag, 0);
sender = node != NULL ? mir_t2a(xi.getText(node)) : NULL;
- netlog("gg_mainthread(%x): XML Action type: %s.", this, type != NULL ? type : "unknown");
+ netlog("mainthread() (%x): XML Action type: %s.", this, type != NULL ? type : "unknown");
// Avatar change notify
if (type != NULL && !strcmp(type, "28")) {
- netlog("gg_mainthread(%x): Client %s changed his avatar.", this, sender);
+ netlog("mainthread() (%x): Client %s changed his avatar.", this, sender);
requestAvatar(getcontact(atoi(sender), 0, 0, NULL), 0);
}
mir_free(type);
@@ -1171,7 +1195,7 @@ retry: {
HANDLE hContact = getcontact(e->event.typing_notification.uin, 0, 0, NULL);
#ifdef DEBUGMODE
- netlog("gg_mainthread(%x): Typing notification from %d (%d).", this,
+ netlog("mainthread() (%x): Typing notification from %d (%d).", this,
e->event.typing_notification.uin, e->event.typing_notification.length);
#endif
CallService(MS_PROTO_CONTACTISTYPING, (WPARAM)hContact,
@@ -1191,7 +1215,7 @@ retry: if (m_iDesiredStatus != ID_STATUS_OFFLINE
&& db_get_b(NULL, m_szModuleName, GG_KEY_ARECONNECT, GG_KEYDEF_ARECONNECT))
{
- netlog("gg_mainthread(%x): Unintentional disconnection detected. Going to reconnect...", this);
+ netlog("mainthread() (%x): Unintentional disconnection detected. Going to reconnect...", this);
hostnum = 0;
broadcastnewstatus(ID_STATUS_CONNECTING);
mir_free(p.status_descr);
@@ -1204,7 +1228,7 @@ retry: // Destroy concurrent sessions list
{
list_t l;
- EnterCriticalSection(&sessions_mutex);
+ gg_EnterCriticalSection(&sessions_mutex, "mainthread", 23, "sessions_mutex", 1);
for (l = sessions; l; l = l->next)
{
struct gg_multilogon_session* sess = (struct gg_multilogon_session*)l->data;
@@ -1213,17 +1237,20 @@ retry: }
list_destroy(sessions, 0);
sessions = NULL;
- LeaveCriticalSection(&sessions_mutex);
+ gg_LeaveCriticalSection(&sessions_mutex, "mainthread", 23, 1, "sessions_mutex", 1);
}
// Stop dcc server
pth_dcc.dwThreadId = 0;
#ifdef DEBUGMODE
- netlog("gg_mainthread(%x): Waiting until DCC Server Thread finished, if needed.", this);
+ netlog("mainthread() (%x): Waiting pth_dcc thread. Waiting until DCC Server Thread finished, if needed.", this);
#endif
threadwait(&pth_dcc);
+#ifdef DEBUGMODE
+ netlog("mainthread() (%x): Waiting pth_dcc thread - OK", this);
+#endif
- netlog("gg_mainthread(%x): Server Thread Ending", this);
+ netlog("mainthread(): end. (%x) Server Thread Ending", this);
return;
}
@@ -1233,19 +1260,19 @@ void GGPROTO::broadcastnewstatus(int newStatus) {
int oldStatus;
- EnterCriticalSection(&modemsg_mutex);
+ gg_EnterCriticalSection(&modemsg_mutex, "broadcastnewstatus", 24, "modemsg_mutex", 1);
oldStatus = m_iStatus;
if (oldStatus == newStatus)
{
- LeaveCriticalSection(&modemsg_mutex);
+ gg_LeaveCriticalSection(&modemsg_mutex, "broadcastnewstatus", 24, 1, "modemsg_mutex", 1);
return;
}
m_iStatus = newStatus;
- LeaveCriticalSection(&modemsg_mutex);
+ gg_LeaveCriticalSection(&modemsg_mutex, "broadcastnewstatus", 24, 2, "modemsg_mutex", 1);
ProtoBroadcastAck(m_szModuleName, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE) oldStatus, newStatus);
- netlog("gg_broadcastnewstatus(): Broadcast new status: %d.", newStatus);
+ netlog("broadcastnewstatus(): Broadcast new status: %d.", newStatus);
}
////////////////////////////////////////////////////////////
@@ -1266,7 +1293,7 @@ int GGPROTO::contactdeleted(WPARAM wParam, LPARAM lParam) GCEVENT gcevent = {sizeof(GCEVENT), &gcdest};
GGGC *chat = gc_lookup(dbv.pszVal);
- netlog("gg_gc_event(): Terminating chat %x, id %s from contact list...", chat, dbv.pszVal);
+ netlog("contactdeleted(): Terminating chat %x, id %s from contact list...", chat, dbv.pszVal);
if (chat)
{
// Destroy chat entry
@@ -1283,9 +1310,9 @@ int GGPROTO::contactdeleted(WPARAM wParam, LPARAM lParam) if (uin && isonline())
{
- EnterCriticalSection(&sess_mutex);
+ gg_EnterCriticalSection(&sess_mutex, "contactdeleted", 25, "sess_mutex", 1);
gg_remove_notify_ex(sess, uin, GG_USER_NORMAL);
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "contactdeleted", 25, 1, "sess_mutex", 1);
}
return 0;
@@ -1300,6 +1327,8 @@ int GGPROTO::dbsettingchanged(WPARAM wParam, LPARAM lParam) HANDLE hContact = (HANDLE) wParam;
char *szProto = NULL;
+ netlog("dbsettingchanged(): fired. szModule=%s szSetting=%s", cws->szModule, cws->szSetting);
+
// Check if the contact is NULL or we are not online
if (!isonline())
return 0;
@@ -1327,7 +1356,7 @@ int GGPROTO::dbsettingchanged(WPARAM wParam, LPARAM lParam) GCDEST gcdest = {m_szModuleName, dbv.pszVal, GC_EVENT_CHANGESESSIONAME};
GCEVENT gcevent = {sizeof(GCEVENT), &gcdest};
gcevent.pszText = cws->value.pszVal;
- netlog("gg_dbsettingchanged(): Conference %s was renamed to %s.", dbv.pszVal, cws->value.pszVal);
+ netlog("dbsettingchanged(): Conference %s was renamed to %s.", dbv.pszVal, cws->value.pszVal);
// Mark cascading
/* FIXME */ cascade = 1;
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent);
@@ -1357,6 +1386,11 @@ int GGPROTO::dbsettingchanged(WPARAM wParam, LPARAM lParam) notifyuser(hContact, 1);
}
}
+
+#ifdef DEBUGMODE
+ netlog("dbsettingchanged(): end. szModule=%s szSetting=%s", cws->szModule, cws->szSetting);
+#endif
+
return 0;
}
@@ -1365,7 +1399,7 @@ int GGPROTO::dbsettingchanged(WPARAM wParam, LPARAM lParam) void GGPROTO::setalloffline()
{
- netlog("gg_setalloffline(): Setting buddies offline");
+ netlog("setalloffline(): started. Setting buddies offline");
db_set_w(NULL, m_szModuleName, GG_KEY_STATUS, ID_STATUS_OFFLINE);
HANDLE hContact = db_find_first();
while (hContact)
@@ -1383,7 +1417,7 @@ void GGPROTO::setalloffline() hContact = db_find_next(hContact);
}
#ifdef DEBUGMODE
- netlog("gg_setalloffline(): End");
+ netlog("setalloffline(): End.");
#endif
}
@@ -1401,28 +1435,31 @@ void GGPROTO::notifyuser(HANDLE hContact, int refresh) if ((db_get_w(hContact, m_szModuleName, GG_KEY_APPARENT, (WORD) ID_STATUS_ONLINE) == ID_STATUS_OFFLINE) ||
db_get_b(hContact, "CList", "NotOnList", 0))
{
- mir_cslock l(sess_mutex);
+ gg_EnterCriticalSection(&sess_mutex, "notifyuser", 77, "sess_mutex", 1);
if (refresh) {
gg_remove_notify_ex(sess, uin, GG_USER_NORMAL);
gg_remove_notify_ex(sess, uin, GG_USER_BLOCKED);
}
gg_add_notify_ex(sess, uin, GG_USER_OFFLINE);
+ gg_LeaveCriticalSection(&sess_mutex, "notifyuser", 77, 1, "sess_mutex", 1);
}
else if (db_get_b(hContact, m_szModuleName, GG_KEY_BLOCK, 0))
{
- mir_cslock l(sess_mutex);
+ gg_EnterCriticalSection(&sess_mutex, "notifyuser", 78, "sess_mutex", 1);
if (refresh)
gg_remove_notify_ex(sess, uin, GG_USER_OFFLINE);
gg_add_notify_ex(sess, uin, GG_USER_BLOCKED);
+ gg_LeaveCriticalSection(&sess_mutex, "notifyuser", 78, 1, "sess_mutex", 1);
}
else {
- mir_cslock l(sess_mutex);
+ gg_EnterCriticalSection(&sess_mutex, "notifyuser", 79, "sess_mutex", 1);
if (refresh)
gg_remove_notify_ex(sess, uin, GG_USER_BLOCKED);
gg_add_notify_ex(sess, uin, GG_USER_NORMAL);
+ gg_LeaveCriticalSection(&sess_mutex, "notifyuser", 79, 1, "sess_mutex", 1);
}
}
}
@@ -1435,7 +1472,7 @@ void GGPROTO::notifyall() uin_t *uins;
char *types;
- netlog("gg_notifyall(): Subscribing notification to all users");
+ netlog("notifyall(): Subscribing notification to all users");
// Readup count
hContact = db_find_first();
while (hContact)
@@ -1451,9 +1488,9 @@ void GGPROTO::notifyall() {
if (isonline())
{
- EnterCriticalSection(&sess_mutex);
+ gg_EnterCriticalSection(&sess_mutex, "notifyall", 29, "sess_mutex", 1);
gg_notify_ex(sess, NULL, NULL, 0);
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "notifyall", 29, 1, "sess_mutex", 1);
}
return;
}
@@ -1482,9 +1519,9 @@ void GGPROTO::notifyall() // Send notification
if (isonline())
{
- EnterCriticalSection(&sess_mutex);
+ gg_EnterCriticalSection(&sess_mutex, "notifyall", 30, "sess_mutex", 1);
gg_notify_ex(sess, uins, types, count);
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "notifyall", 30, 1, "sess_mutex", 1);
}
// Free variables
@@ -1496,6 +1533,9 @@ void GGPROTO::notifyall() HANDLE GGPROTO::getcontact(uin_t uin, int create, int inlist, TCHAR *szNick)
{
+#ifdef DEBUGMODE
+ netlog("getcontact(): uin=%d create=%d inlist=%d", uin, create, inlist);
+#endif
// Look for contact in DB
HANDLE hContact = db_find_first();
while (hContact) {
@@ -1517,18 +1557,18 @@ HANDLE GGPROTO::getcontact(uin_t uin, int create, int inlist, TCHAR *szNick) hContact = (HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0);
if (!hContact) {
- netlog("gg_getcontact(): Failed to create Gadu-Gadu contact %s", szNick);
+ netlog("getcontact(): Failed to create Gadu-Gadu contact %s", szNick);
return NULL;
}
if (CallService(MS_PROTO_ADDTOCONTACT, (WPARAM) hContact, (LPARAM) m_szModuleName) != 0) {
// For some reason we failed to register the protocol for this contact
CallService(MS_DB_CONTACT_DELETE, (WPARAM) hContact, 0);
- netlog("Failed to register GG contact %d", uin);
+ netlog("getcontact(): Failed to register GG contact %d", uin);
return NULL;
}
- netlog("gg_getcontact(): Added buddy: %d", uin);
+ netlog("getcontact(): Added buddy: %d", uin);
if (!inlist)
db_set_b(hContact, "CList", "NotOnList", 1);
@@ -1548,12 +1588,12 @@ HANDLE GGPROTO::getcontact(uin_t uin, int create, int inlist, TCHAR *szNick) // Add uin and search it
gg_pubdir50_add(req, GG_PUBDIR50_UIN, ditoa(uin));
gg_pubdir50_seq_set(req, GG_SEQ_GETNICK);
- EnterCriticalSection(&sess_mutex);
+ gg_EnterCriticalSection(&sess_mutex, "getcontact", 31, "sess_mutex", 1);
gg_pubdir50(sess, req);
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "getcontact", 31, 1, "sess_mutex", 1);
gg_pubdir50_free(req);
db_set_s(hContact, m_szModuleName, GG_KEY_NICK, ditoa(uin));
- netlog("gg_getcontact(): Search for nick on uin: %d", uin);
+ netlog("getcontact(): Search for nick on uin: %d", uin);
}
}
@@ -1562,9 +1602,9 @@ HANDLE GGPROTO::getcontact(uin_t uin, int create, int inlist, TCHAR *szNick) {
PROTO_AVATAR_INFORMATIONT pai = {0};
- EnterCriticalSection(&sess_mutex);
+ gg_EnterCriticalSection(&sess_mutex, "getcontact", 32, "sess_mutex", 1);
gg_add_notify_ex(sess, uin, (char)(inlist ? GG_USER_NORMAL : GG_USER_OFFLINE));
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "getcontact", 32, 1, "sess_mutex", 1);
pai.cbSize = sizeof(pai);
pai.hContact = hContact;
@@ -1573,9 +1613,9 @@ HANDLE GGPROTO::getcontact(uin_t uin, int create, int inlist, TCHAR *szNick) // Change status of the contact with our own UIN (if got yourself added to the contact list)
if (db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0) == uin) {
char *szMsg;
- EnterCriticalSection(&modemsg_mutex);
+ gg_EnterCriticalSection(&modemsg_mutex, "getcontact", 33, "modemsg_mutex", 1);
szMsg = mir_strdup(getstatusmsg(m_iStatus));
- LeaveCriticalSection(&modemsg_mutex);
+ gg_LeaveCriticalSection(&modemsg_mutex, "getcontact", 33, 1, "modemsg_mutex", 1);
changecontactstatus(uin, status_m2gg(m_iStatus, szMsg != NULL), szMsg, 0, 0, 0, 0);
mir_free(szMsg);
}
@@ -1670,6 +1710,9 @@ int GGPROTO::status_gg2m(int status) void GGPROTO::changecontactstatus(uin_t uin, int status, const char *idescr, int time, uint32_t remote_ip, uint16_t remote_port, uint32_t version)
{
+#ifdef DEBUGMODE
+ netlog("changecontactstatus(): uin=%d status=%d", uin, status);
+#endif
HANDLE hContact = getcontact(uin, 0, 0, NULL);
// Check if contact is on list
@@ -1681,7 +1724,7 @@ void GGPROTO::changecontactstatus(uin_t uin, int status, const char *idescr, int // Check if there's description and if it's not empty
if (idescr && *idescr)
{
- netlog("gg_changecontactstatus(): Saving for %d status descr \"%s\".", uin, idescr);
+ netlog("changecontactstatus(): Saving for %d status descr \"%s\".", uin, idescr);
db_set_s(hContact, "CList", GG_KEY_STATUSDESCR, idescr);
}
else
diff --git a/protocols/Gadu-Gadu/src/dialogs.cpp b/protocols/Gadu-Gadu/src/dialogs.cpp index 476907f2e8..d34b8e54d1 100644 --- a/protocols/Gadu-Gadu/src/dialogs.cpp +++ b/protocols/Gadu-Gadu/src/dialogs.cpp @@ -458,9 +458,9 @@ static INT_PTR CALLBACK gg_genoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, db_set_b(NULL, gg->m_szModuleName, GG_KEY_SHOWLINKS, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_SHOWLINKS));
if (IsDlgButtonChecked(hwndDlg, IDC_SHOWLINKS))
status_flags |= GG_STATUS_FLAG_SPAM;
- EnterCriticalSection(&gg->sess_mutex);
+ gg->gg_EnterCriticalSection(&gg->sess_mutex, "gg_genoptsdlgproc", 34, "sess_mutex", 1);
gg_change_status_flags(gg->sess, status_flags);
- LeaveCriticalSection(&gg->sess_mutex);
+ gg->gg_LeaveCriticalSection(&gg->sess_mutex, "gg_genoptsdlgproc", 34, 1, "sess_mutex", 1);
db_set_b(NULL, gg->m_szModuleName, GG_KEY_ENABLEAVATARS, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_ENABLEAVATARS));
db_set_b(NULL, gg->m_szModuleName, GG_KEY_IMGMETHOD,
@@ -847,9 +847,9 @@ static INT_PTR CALLBACK gg_detailsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, // Run update
gg_pubdir50_seq_set(req, GG_SEQ_CHINFO);
- EnterCriticalSection(&gg->sess_mutex);
+ gg->gg_EnterCriticalSection(&gg->sess_mutex, "gg_detailsdlgproc", 35, "sess_mutex", 1);
gg_pubdir50(gg->sess, req);
- LeaveCriticalSection(&gg->sess_mutex);
+ gg->gg_LeaveCriticalSection(&gg->sess_mutex, "gg_genoptsdlgproc", 35, 1, "sess_mutex", 1);
dat->updating = TRUE;
gg_pubdir50_free(req);
diff --git a/protocols/Gadu-Gadu/src/filetransfer.cpp b/protocols/Gadu-Gadu/src/filetransfer.cpp index e7560e16a2..86eae9458c 100644 --- a/protocols/Gadu-Gadu/src/filetransfer.cpp +++ b/protocols/Gadu-Gadu/src/filetransfer.cpp @@ -35,7 +35,7 @@ void GGPROTO::dccstart() if (exitCode == STILL_ACTIVE)
{
#ifdef DEBUGMODE
- netlog("gg_dccstart(): DCC thread still active. Exiting...");
+ netlog("dccstart(): DCC thread still active. Exiting...");
#endif
// Signalize mainthread it's started
if (hEvent) SetEvent(hEvent);
@@ -45,12 +45,15 @@ void GGPROTO::dccstart() // Check if we wan't direct connections
if (!db_get_b(NULL, m_szModuleName, GG_KEY_DIRECTCONNS, GG_KEYDEF_DIRECTCONNS))
{
- netlog("gg_dccstart(): No direct connections setup.");
+ netlog("dccstart(): No direct connections setup.");
if (hEvent) SetEvent(hEvent);
return;
}
// Start thread
+#ifdef DEBUGMODE
+ netlog("dccstart(): forkthreadex 4 GGPROTO::dccmainthread");
+#endif
pth_dcc.hThread = forkthreadex(&GGPROTO::dccmainthread, NULL, &pth_dcc.dwThreadId);
}
@@ -60,7 +63,7 @@ void GGPROTO::dccconnect(uin_t uin) HANDLE hContact = getcontact(uin, 0, 0, NULL);
DWORD ip, myuin; WORD port;
- netlog("gg_dccconnect(): Connecting to uin %d.", uin);
+ netlog("dccconnect(): Connecting to uin %d.", uin);
// If unknown user or not on list ignore
if (!hContact) return;
@@ -77,9 +80,9 @@ void GGPROTO::dccconnect(uin_t uin) return;
// Add client dcc to watches
- EnterCriticalSection(&ft_mutex);
+ gg_EnterCriticalSection(&ft_mutex, "dccconnect", 36, "ft_mutex", 1);
list_add(&watches, dcc, 0);
- LeaveCriticalSection(&ft_mutex);
+ gg_LeaveCriticalSection(&ft_mutex, "dccconnect", 36, 1, "ft_mutex", 1);
}
//////////////////////////////////////////////////////////
@@ -93,21 +96,25 @@ struct ftfaildata void __cdecl GGPROTO::ftfailthread(void *param)
{
struct ftfaildata *ft = (struct ftfaildata *)param;
- SleepEx(100, FALSE);
- netlog("gg_ftfailthread(): Sending failed file transfer.");
+ netlog("ftfailthread(): started. Sending failed file transfer.");
+ gg_sleep(100, FALSE, "ftfailthread", 102, 1);
ProtoBroadcastAck(m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft->hProcess, 0);
free(ft);
+ netlog("ftfailthread(): end.");
}
HANDLE ftfail(GGPROTO *gg, HANDLE hContact)
{
ftfaildata *ft = (ftfaildata*)malloc(sizeof(struct ftfaildata));
#ifdef DEBUGMODE
- gg->netlog("gg_ftfail(): Failing file transfer...");
+ gg->netlog("ftfail(): Failing file transfer...");
#endif
srand(time(NULL));
ft->hProcess = (HANDLE)rand();
ft->hContact = hContact;
+#ifdef DEBUGMODE
+ gg->netlog("ftfail(): forkthread 5 GGPROTO::ftfailthread");
+#endif
gg->forkthread(&GGPROTO::ftfailthread, ft);
return ft->hProcess;
}
@@ -133,28 +140,34 @@ void __cdecl GGPROTO::dccmainthread(void*) // Zero up lists
watches = transfers = requests = l = NULL;
- netlog("gg_dccmainthread(): DCC Server Thread Starting");
+ netlog("dccmainthread(): started. DCC Server Thread Starting");
// Readup number
if (!(uin = db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0)))
{
- netlog("gg_dccmainthread(): No Gadu-Gadu number specified. Exiting.");
+ netlog("dccmainthread(): No Gadu-Gadu number specified. Exiting.");
if (hEvent) SetEvent(hEvent);
+#ifdef DEBUGMODE
+ netlog("dccmainthread(): end 1.");
+#endif
return;
}
// Create listen socket on config direct port
if (!(dcc = gg_dcc_socket_create(uin, (uint16_t)db_get_w(NULL, m_szModuleName, GG_KEY_DIRECTPORT, GG_KEYDEF_DIRECTPORT))))
{
- netlog("gg_dccmainthread(): Cannot create DCC listen socket. Exiting.");
+ netlog("dccmainthread(): Cannot create DCC listen socket. Exiting.");
// Signalize mainthread we haven't start
if (hEvent) SetEvent(hEvent);
+#ifdef DEBUGMODE
+ netlog("dccmainthread(): end 2.");
+#endif
return;
}
gg_dcc_port = dcc->port;
gg_dcc_ip = inet_addr("255.255.255.255");
- netlog("gg_dccmainthread(): Listening on port %d.", gg_dcc_port);
+ netlog("dccmainthread(): Listening on port %d.", gg_dcc_port);
// Signalize mainthread we started
if (hEvent) SetEvent(hEvent);
@@ -198,15 +211,15 @@ void __cdecl GGPROTO::dccmainthread(void*) if (ret == -1)
{
if (errno == EBADF)
- netlog("gg_dccmainthread(): Bad descriptor on select().");
+ netlog("dccmainthread(): Bad descriptor on select().");
else if (errno != EINTR)
- netlog("gg_dccmainthread(): Unknown error on select().");
+ netlog("dccmainthread(): Unknown error on select().");
continue;
}
// Process watches (carefull with l)
l = watches;
- EnterCriticalSection(&ft_mutex);
+ gg_EnterCriticalSection(&ft_mutex, "dccmainthread", 37, "ft_mutex", 1);
while (l)
{
struct gg_common *c = (gg_common*)l->data;
@@ -226,7 +239,7 @@ void __cdecl GGPROTO::dccmainthread(void*) // Connection broken/closed
if (!(e = gg_dcc_socket_watch_fd(dcc)))
{
- netlog("gg_dccmainthread(): Socket closed.");
+ netlog("dccmainthread(): Socket closed.");
// Remove socket and _close
list_remove(&watches, dcc, 0);
gg_dcc_socket_free(dcc);
@@ -235,7 +248,7 @@ void __cdecl GGPROTO::dccmainthread(void*) if (dcc == dcc) dcc = NULL;
continue;
}
- else netlog("gg_dccmainthread(): Event: %s", ggdebug_eventtype(e));
+ else netlog("dccmainthread(): Event: %s", ggdebug_eventtype(e));
switch(e->type)
{
@@ -274,7 +287,7 @@ void __cdecl GGPROTO::dccmainthread(void*) // Connection was successfuly ended
case GG_EVENT_DCC_DONE:
- netlog("gg_dccmainthread(): Client: %d, Transfer done ! Closing connection.", dcc->peer_uin);
+ netlog("dccmainthread(): Client: %d, Transfer done ! Closing connection.", dcc->peer_uin);
// Remove from watches
list_remove(&watches, dcc, 0);
// Close file & success
@@ -310,22 +323,22 @@ void __cdecl GGPROTO::dccmainthread(void*) switch (e->event.dcc_error)
{
case GG_ERROR_DCC_HANDSHAKE:
- netlog("gg_dccmainthread(): Client: %d, Handshake error.", dcc->peer_uin);
+ netlog("dccmainthread(): Client: %d, Handshake error.", dcc->peer_uin);
break;
case GG_ERROR_DCC_NET:
- netlog("gg_dccmainthread(): Client: %d, Network error.", dcc->peer_uin);
+ netlog("dccmainthread(): Client: %d, Network error.", dcc->peer_uin);
break;
case GG_ERROR_DCC_FILE:
- netlog("gg_dccmainthread(): Client: %d, File read/write error.", dcc->peer_uin);
+ netlog("dccmainthread(): Client: %d, File read/write error.", dcc->peer_uin);
break;
case GG_ERROR_DCC_EOF:
- netlog("gg_dccmainthread(): Client: %d, End of file/connection error.", dcc->peer_uin);
+ netlog("dccmainthread(): Client: %d, End of file/connection error.", dcc->peer_uin);
break;
case GG_ERROR_DCC_REFUSED:
- netlog("gg_dccmainthread(): Client: %d, Connection refused error.", dcc->peer_uin);
+ netlog("dccmainthread(): Client: %d, Connection refused error.", dcc->peer_uin);
break;
default:
- netlog("gg_dccmainthread(): Client: %d, Unknown error.", dcc->peer_uin);
+ netlog("dccmainthread(): Client: %d, Unknown error.", dcc->peer_uin);
}
// Don't do anything if it's main socket
if (dcc == dcc) break;
@@ -345,7 +358,7 @@ void __cdecl GGPROTO::dccmainthread(void*) // Need file acknowledgement
case GG_EVENT_DCC_NEED_FILE_ACK:
- netlog("gg_dccmainthread(): Client: %d, File ack filename \"%s\" size %d.", dcc->peer_uin,
+ netlog("dccmainthread(): Client: %d, File ack filename \"%s\" size %d.", dcc->peer_uin,
dcc->file_info.filename, dcc->file_info.size);
// Do not watch for transfer until user accept it
list_remove(&watches, dcc, 0);
@@ -376,7 +389,7 @@ void __cdecl GGPROTO::dccmainthread(void*) // Need client accept
case GG_EVENT_DCC_CLIENT_ACCEPT:
- netlog("gg_dccmainthread(): Client: %d, Client accept.", dcc->peer_uin);
+ netlog("dccmainthread(): Client: %d, Client accept.", dcc->peer_uin);
// Check if user is on the list and if it is my uin
if (getcontact(dcc->peer_uin, 0, 0, NULL) &&
db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, -1) == dcc->uin)
@@ -391,7 +404,7 @@ void __cdecl GGPROTO::dccmainthread(void*) case GG_EVENT_DCC_CALLBACK:
{
int found = 0;
- netlog("gg_dccmainthread(): Callback from client %d.", dcc->peer_uin);
+ netlog("dccmainthread(): Callback from client %d.", dcc->peer_uin);
// Seek for stored callback request
for (l = requests; l; l = l->next)
{
@@ -418,7 +431,7 @@ void __cdecl GGPROTO::dccmainthread(void*) list_add(&watches, req, 0);
// Free old dat
gg_free_dcc(dcc);
- netlog("gg_dccmainthread(): Found stored request to client %d, filename \"%s\" size %d, folder \"%s\".",
+ netlog("dccmainthread(): Found stored request to client %d, filename \"%s\" size %d, folder \"%s\".",
req->peer_uin, req->file_info.filename, req->file_info.size, req->folder);
break;
}
@@ -426,7 +439,7 @@ void __cdecl GGPROTO::dccmainthread(void*) if (!found)
{
- netlog("gg_dccmainthread(): Unknown request to client %d.", dcc->peer_uin);
+ netlog("dccmainthread(): Unknown request to client %d.", dcc->peer_uin);
// Kill unauthorized dcc
list_remove(&watches, dcc, 0);
gg_free_dcc(dcc); if (dcc == dcc) dcc = NULL;
@@ -452,13 +465,13 @@ void __cdecl GGPROTO::dccmainthread(void*) // Connection broken/closed
if (!(e = gg_dcc7_watch_fd(dcc7)))
{
- netlog("gg_dccmainthread(): Socket closed.");
+ netlog("dccmainthread(): Socket closed.");
// Remove socket and _close
list_remove(&watches, dcc7, 0);
gg_dcc7_free(dcc7);
continue;
}
- else netlog("gg_dccmainthread(): Event: %s", ggdebug_eventtype(e));
+ else netlog("dccmainthread(): Event: %s", ggdebug_eventtype(e));
switch(e->type)
{
@@ -491,7 +504,7 @@ void __cdecl GGPROTO::dccmainthread(void*) // Connection was successfuly ended
case GG_EVENT_DCC7_DONE:
- netlog("gg_dccmainthread(): Client: %d, Transfer done ! Closing connection.", dcc->peer_uin);
+ netlog("dccmainthread(): Client: %d, Transfer done ! Closing connection.", dcc->peer_uin);
// Remove from watches
list_remove(&watches, dcc7, 0);
// Close file & success
@@ -527,25 +540,25 @@ void __cdecl GGPROTO::dccmainthread(void*) switch (e->event.dcc7_error)
{
case GG_ERROR_DCC7_HANDSHAKE:
- netlog("gg_dccmainthread(): Client: %d, Handshake error.", dcc7->peer_uin);
+ netlog("dccmainthread(): Client: %d, Handshake error.", dcc7->peer_uin);
break;
case GG_ERROR_DCC7_NET:
- netlog("gg_dccmainthread(): Client: %d, Network error.", dcc7->peer_uin);
+ netlog("dccmainthread(): Client: %d, Network error.", dcc7->peer_uin);
break;
case GG_ERROR_DCC7_FILE:
- netlog("gg_dccmainthread(): Client: %d, File read/write error.", dcc7->peer_uin);
+ netlog("dccmainthread(): Client: %d, File read/write error.", dcc7->peer_uin);
break;
case GG_ERROR_DCC7_EOF:
- netlog("gg_dccmainthread(): Client: %d, End of file/connection error.", dcc7->peer_uin);
+ netlog("dccmainthread(): Client: %d, End of file/connection error.", dcc7->peer_uin);
break;
case GG_ERROR_DCC7_REFUSED:
- netlog("gg_dccmainthread(): Client: %d, Connection refused error.", dcc7->peer_uin);
+ netlog("dccmainthread(): Client: %d, Connection refused error.", dcc7->peer_uin);
break;
case GG_ERROR_DCC7_RELAY:
- netlog("gg_dccmainthread(): Client: %d, Relay connection error.", dcc7->peer_uin);
+ netlog("dccmainthread(): Client: %d, Relay connection error.", dcc7->peer_uin);
break;
default:
- netlog("gg_dccmainthread(): Client: %d, Unknown error.", dcc7->peer_uin);
+ netlog("dccmainthread(): Client: %d, Unknown error.", dcc7->peer_uin);
}
// Remove from watches
list_remove(&watches, dcc7, 0);
@@ -570,7 +583,7 @@ void __cdecl GGPROTO::dccmainthread(void*) break;
}
}
- LeaveCriticalSection(&ft_mutex);
+ gg_LeaveCriticalSection(&ft_mutex, "dccmainthread", 37, 1, "ft_mutex", 1);
}
// Close all dcc client sockets
@@ -620,7 +633,7 @@ void __cdecl GGPROTO::dccmainthread(void*) gg_dcc_port = 0;
gg_dcc_ip = 0;
- netlog("gg_dccmainthread(): DCC Server Thread Ending");
+ netlog("dccmainthread(): end. DCC Server Thread Ending");
}
HANDLE GGPROTO::dccfileallow(HANDLE hTransfer, const PROTOCHAR* szPath)
@@ -634,14 +647,14 @@ HANDLE GGPROTO::dccfileallow(HANDLE hTransfer, const PROTOCHAR* szPath) mir_free(path);
// Remove transfer from waiting list
- EnterCriticalSection(&ft_mutex);
+ gg_EnterCriticalSection(&ft_mutex, "dccfileallow", 38, "ft_mutex", 1);
list_remove(&transfers, dcc, 0);
- LeaveCriticalSection(&ft_mutex);
+ gg_LeaveCriticalSection(&ft_mutex, "dccfileallow", 38, 1, "ft_mutex", 1);
// Open file for appending and check if ok
if ((dcc->file_fd = _open(fileName, _O_WRONLY | _O_APPEND | _O_BINARY | _O_CREAT, _S_IREAD | _S_IWRITE)) == -1)
{
- netlog("gg_dccfileallow(): Failed to create file \"%s\".", fileName);
+ netlog("dccfileallow(): Failed to create file \"%s\".", fileName);
ProtoBroadcastAck(m_szModuleName, dcc->contact, ACKTYPE_FILE, ACKRESULT_FAILED, dcc, 0);
// Free transfer
gg_free_dcc(dcc);
@@ -652,11 +665,11 @@ HANDLE GGPROTO::dccfileallow(HANDLE hTransfer, const PROTOCHAR* szPath) dcc->offset = _lseek(dcc->file_fd, 0, SEEK_END);
// Add to watches and start transfer
- EnterCriticalSection(&ft_mutex);
+ gg_EnterCriticalSection(&ft_mutex, "dccfileallow", 39, "ft_mutex", 1);
list_add(&watches, dcc, 0);
- LeaveCriticalSection(&ft_mutex);
+ gg_LeaveCriticalSection(&ft_mutex, "dccfileallow", 39, 1, "ft_mutex", 1);
- netlog("gg_dccfileallow(): Receiving file \"%s\" from %d.", dcc->file_info.filename, dcc->peer_uin);
+ netlog("dccfileallow(): Receiving file \"%s\" from %d.", dcc->file_info.filename, dcc->peer_uin);
return hTransfer;
}
@@ -673,13 +686,13 @@ HANDLE GGPROTO::dcc7fileallow(HANDLE hTransfer, const PROTOCHAR* szPath) mir_free(path);
// Remove transfer from waiting list
- EnterCriticalSection(&ft_mutex);
+ gg_EnterCriticalSection(&ft_mutex, "dcc7fileallow", 40, "ft_mutex", 1);
iFtRemoveRes = list_remove(&transfers, dcc7, 0);
- LeaveCriticalSection(&ft_mutex);
+ gg_LeaveCriticalSection(&ft_mutex, "dcc7fileallow", 40, 1, "ft_mutex", 1);
if (iFtRemoveRes == -1)
{
- netlog("gg_dcc7fileallow(): File transfer denied.");
+ netlog("dcc7fileallow(): File transfer denied.");
ProtoBroadcastAck(m_szModuleName, dcc7->contact, ACKTYPE_FILE, ACKRESULT_DENIED, dcc7, 0);
// Free transfer
gg_dcc7_free(dcc7);
@@ -689,7 +702,7 @@ HANDLE GGPROTO::dcc7fileallow(HANDLE hTransfer, const PROTOCHAR* szPath) // Open file for appending and check if ok
if ((dcc7->file_fd = _open(fileName, _O_WRONLY | _O_APPEND | _O_BINARY | _O_CREAT, _S_IREAD | _S_IWRITE)) == -1)
{
- netlog("gg_dcc7fileallow(): Failed to create file \"%s\".", fileName);
+ netlog("dcc7fileallow(): Failed to create file \"%s\".", fileName);
gg_dcc7_reject(dcc7, GG_DCC7_REJECT_USER);
ProtoBroadcastAck(m_szModuleName, dcc7->contact, ACKTYPE_FILE, ACKRESULT_FAILED, dcc7, 0);
// Free transfer
@@ -702,11 +715,11 @@ HANDLE GGPROTO::dcc7fileallow(HANDLE hTransfer, const PROTOCHAR* szPath) gg_dcc7_accept(dcc7, dcc7->offset);
// Add to watches and start transfer
- EnterCriticalSection(&ft_mutex);
+ gg_EnterCriticalSection(&ft_mutex, "dcc7fileallow", 41, "ft_mutex", 1);
list_add(&watches, dcc7, 0);
- LeaveCriticalSection(&ft_mutex);
+ gg_LeaveCriticalSection(&ft_mutex, "dcc7fileallow", 41, 1, "ft_mutex", 1);
- netlog("gg_dcc7fileallow(): Receiving file \"%s\" from %d.", dcc7->filename, dcc7->peer_uin);
+ netlog("dcc7fileallow(): Receiving file \"%s\" from %d.", dcc7->filename, dcc7->peer_uin);
return hTransfer;
}
@@ -716,13 +729,13 @@ int GGPROTO::dccfiledeny(HANDLE hTransfer) struct gg_dcc *dcc = (struct gg_dcc *) hTransfer;
// Remove transfer from any list
- EnterCriticalSection(&ft_mutex);
+ gg_EnterCriticalSection(&ft_mutex, "dccfiledeny", 42, "ft_mutex", 1);
if (watches) list_remove(&watches, dcc, 0);
if (requests) list_remove(&requests, dcc, 0);
if (transfers) list_remove(&transfers, dcc, 0);
- LeaveCriticalSection(&ft_mutex);
+ gg_LeaveCriticalSection(&ft_mutex, "dccfiledeny", 42, 1, "ft_mutex", 1);
- netlog("gg_dccfiledeny(): Rejected file \"%s\" from/to %d.", dcc->file_info.filename, dcc->peer_uin);
+ netlog("dccfiledeny(): Rejected file \"%s\" from/to %d.", dcc->file_info.filename, dcc->peer_uin);
// Free transfer
gg_free_dcc(dcc);
@@ -737,12 +750,12 @@ int GGPROTO::dcc7filedeny(HANDLE hTransfer) gg_dcc7_reject(dcc7, GG_DCC7_REJECT_USER);
// Remove transfer from any list
- EnterCriticalSection(&ft_mutex);
+ gg_EnterCriticalSection(&ft_mutex, "dcc7filedeny", 43, "ft_mutex", 1);
if (watches) list_remove(&watches, dcc7, 0);
if (transfers) list_remove(&transfers, dcc7, 0);
- LeaveCriticalSection(&ft_mutex);
+ gg_LeaveCriticalSection(&ft_mutex, "dcc7filedeny", 43, 1, "ft_mutex", 1);
- netlog("gg_dcc7filedeny(): Rejected file \"%s\" from/to %d.", dcc7->filename, dcc7->peer_uin);
+ netlog("dcc7filedeny(): Rejected file \"%s\" from/to %d.", dcc7->filename, dcc7->peer_uin);
// Free transfer
gg_dcc7_free(dcc7);
@@ -755,11 +768,11 @@ int GGPROTO::dccfilecancel(HANDLE hTransfer) struct gg_dcc *dcc = (struct gg_dcc *) hTransfer;
// Remove transfer from any list
- EnterCriticalSection(&ft_mutex);
+ gg_EnterCriticalSection(&ft_mutex, "dccfilecancel", 44, "ft_mutex", 1);
if (watches) list_remove(&watches, dcc, 0);
if (requests) list_remove(&requests, dcc, 0);
if (transfers) list_remove(&transfers, dcc, 0);
- LeaveCriticalSection(&ft_mutex);
+ gg_LeaveCriticalSection(&ft_mutex, "dccfilecancel", 44, 1, "ft_mutex", 1);
// Send failed info
ProtoBroadcastAck(m_szModuleName, dcc->contact, ACKTYPE_FILE, ACKRESULT_FAILED, dcc, 0);
@@ -770,7 +783,7 @@ int GGPROTO::dccfilecancel(HANDLE hTransfer) dcc->file_fd = -1;
}
- netlog("gg_dccfilecancel(): Canceled file \"%s\" from/to %d.", dcc->file_info.filename, dcc->peer_uin);
+ netlog("dccfilecancel(): Canceled file \"%s\" from/to %d.", dcc->file_info.filename, dcc->peer_uin);
// Free transfer
gg_free_dcc(dcc);
@@ -786,10 +799,10 @@ int GGPROTO::dcc7filecancel(HANDLE hTransfer) gg_dcc7_abort(dcc7);
// Remove transfer from any list
- EnterCriticalSection(&ft_mutex);
+ gg_EnterCriticalSection(&ft_mutex, "dcc7filecancel", 45, "ft_mutex", 1);
if (watches) list_remove(&watches, dcc7, 0);
if (transfers) list_remove(&transfers, dcc7, 0);
- LeaveCriticalSection(&ft_mutex);
+ gg_LeaveCriticalSection(&ft_mutex, "dcc7filecancel", 45, 1, "ft_mutex", 1);
// Send failed info
ProtoBroadcastAck(m_szModuleName, dcc7->contact, ACKTYPE_FILE, ACKRESULT_FAILED, dcc7, 0);
@@ -800,7 +813,7 @@ int GGPROTO::dcc7filecancel(HANDLE hTransfer) dcc7->file_fd = -1;
}
- netlog("gg_dcc7filecancel(): Canceled file \"%s\" from/to %d.", dcc7->filename, dcc7->peer_uin);
+ netlog("dcc7filecancel(): Canceled file \"%s\" from/to %d.", dcc7->filename, dcc7->peer_uin);
// Free transfer
gg_dcc7_free(dcc7);
@@ -892,16 +905,16 @@ HANDLE GGPROTO::SendFile(HANDLE hContact, const PROTOCHAR* szDescription, PROTOC if ((ver & 0x00ffffff) >= 0x29 || !ver) {
struct gg_dcc7 *dcc7;
- EnterCriticalSection(&sess_mutex);
+ gg_EnterCriticalSection(&sess_mutex, "SendFile", 46, "sess_mutex", 1);
if (!(dcc7 = gg_dcc7_send_file(sess, uin, filename, NULL, NULL))) {
- LeaveCriticalSection(&sess_mutex);
- netlog("gg_sendfile(): Failed to send file \"%s\".", filename);
+ gg_LeaveCriticalSection(&sess_mutex, "SendFile", 46, 1, "sess_mutex", 1);
+ netlog("SendFile(): Failed to send file \"%s\".", filename);
mir_free(filename);
return ftfail(this, hContact);
}
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "SendFile", 46, 2, "sess_mutex", 1);
- netlog("gg_sendfile(): Sending file \"%s\" to %d.", filename, uin);
+ netlog("SendFile(): Sending file \"%s\" to %d.", filename, uin);
// Add dcc to watches
list_add(&watches, dcc7, 0);
@@ -923,7 +936,7 @@ HANDLE GGPROTO::SendFile(HANDLE hContact, const PROTOCHAR* szDescription, PROTOC // Return if bad connection info
if (!port || !uin || !myuin)
{
- netlog("gg_sendfile(): Bad contact uin or my uin. Exit.");
+ netlog("SendFile(): Bad contact uin or my uin. Exit.");
mir_free(filename);
return ftfail(this, hContact);
}
@@ -939,23 +952,23 @@ HANDLE GGPROTO::SendFile(HANDLE hContact, const PROTOCHAR* szDescription, PROTOC dcc->peer_uin = uin;
dcc->fd = -1;
dcc->type = GG_SESSION_DCC_SEND;
- netlog("gg_sendfile(): Requesting user to connect us and scheduling gg_dcc struct for a later use.");
- EnterCriticalSection(&sess_mutex);
+ netlog("SendFile(): Requesting user to connect us and scheduling gg_dcc struct for a later use.");
+ gg_EnterCriticalSection(&sess_mutex, "SendFile", 47, "sess_mutex", 1);
gg_dcc_request(sess, uin);
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "SendFile", 47, 1, "sess_mutex", 1);
list_add(&requests, dcc, 0);
}
// Write filename
if (gg_dcc_fill_file_info(dcc, filename) == -1)
{
- netlog("gg_sendfile(): Cannot open and file fileinfo \"%s\".", filename);
+ netlog("SendFile(): Cannot open and file fileinfo \"%s\".", filename);
gg_free_dcc(dcc);
mir_free(filename);
return ftfail(this, hContact);
}
- netlog("gg_sendfile(): Sending file \"%s\" to %d in %s mode.", filename, uin, (dcc->fd != -1) ? "active" : "passive");
+ netlog("SendFile(): Sending file \"%s\" to %d in %s mode.", filename, uin, (dcc->fd != -1) ? "active" : "passive");
// Add dcc to watches if not passive
if (dcc->fd != -1) list_add(&watches, dcc, 0);
diff --git a/protocols/Gadu-Gadu/src/gg.cpp b/protocols/Gadu-Gadu/src/gg.cpp index b75b439af0..401eecf43c 100644 --- a/protocols/Gadu-Gadu/src/gg.cpp +++ b/protocols/Gadu-Gadu/src/gg.cpp @@ -154,7 +154,7 @@ void GGPROTO::cleanuplastplugin(DWORD version) if (version < PLUGIN_MAKE_VERSION(0, 0, 1, 4))
{
#ifdef DEBUGMODE
- netlog("gg_cleanuplastplugin(%d): Cleaning junk Phone settings from < 0.0.1.4 ...", version);
+ netlog("cleanuplastplugin() version=%d Cleaning junk Phone settings from < 0.0.1.4 ...", version);
#endif
// Look for contact in DB
hContact = db_find_first();
@@ -175,7 +175,7 @@ void GGPROTO::cleanuplastplugin(DWORD version) if (version < PLUGIN_MAKE_VERSION(0, 0, 3, 5))
{
#ifdef DEBUGMODE
- netlog("gg_cleanuplastplugin(%d): Cleaning junk Nick settings from < 0.0.3.5 ...", version);
+ netlog("cleanuplastplugin(): version=%d Cleaning junk Nick settings from < 0.0.3.5 ...", version);
#endif
// Look for contact in DB
hContact = db_find_first();
@@ -479,6 +479,10 @@ const char *ggdebug_eventtype(gg_event *e) return ggdebug_eventype2string[i].text;
}
+//////////////////////////////////////////////////////////
+// Log funcion
+#define PREFIXLEN 6 //prefix present in DEBUGMODE contains GetCurrentThreadId()
+
#ifdef DEBUGMODE
void gg_debughandler(int level, const char *format, va_list ap)
{
@@ -487,7 +491,13 @@ void gg_debughandler(int level, const char *format, va_list ap) char *nl = strrchr(szFormat, '\n');
if (nl) *nl = 0;
- strncpy(szText, "[libgadu] \0", sizeof(szText));
+ strncpy(szText + PREFIXLEN, "[libgadu] \0", sizeof(szText) - PREFIXLEN);
+
+ char prefix[6];
+ mir_snprintf(prefix, PREFIXLEN, "%lu", GetCurrentThreadId());
+ size_t prefixLen = strlen(prefix);
+ if (prefixLen < PREFIXLEN) memset(prefix + prefixLen, ' ', PREFIXLEN - prefixLen);
+ memcpy(szText, prefix, PREFIXLEN);
mir_vsnprintf(szText + strlen(szText), sizeof(szText) - strlen(szText), szFormat, ap);
CallService(MS_NETLIB_LOG, (WPARAM) NULL, (LPARAM) szText);
@@ -495,17 +505,25 @@ void gg_debughandler(int level, const char *format, va_list ap) }
#endif
-//////////////////////////////////////////////////////////
-// Log funcion
int GGPROTO::netlog(const char *fmt, ...)
{
va_list va;
char szText[1024];
+ memset(szText, '\0', PREFIXLEN + 1);
+
+#ifdef DEBUGMODE
+ char prefix[6];
+ mir_snprintf(prefix, PREFIXLEN, "%lu", GetCurrentThreadId());
+ size_t prefixLen = strlen(prefix);
+ if (prefixLen < PREFIXLEN) memset(prefix + prefixLen, ' ', PREFIXLEN - prefixLen);
+ memcpy(szText, prefix, PREFIXLEN);
+#endif
va_start(va, fmt);
- mir_vsnprintf(szText, sizeof(szText), fmt, va);
+ mir_vsnprintf(szText + strlen(szText), sizeof(szText) - strlen(szText), fmt, va);
va_end(va);
+
return CallService(MS_NETLIB_LOG, (WPARAM)netlib, (LPARAM) szText);
}
@@ -517,6 +535,7 @@ BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD reason, LPVOID reserved) crc_gentable();
hInstance = hInst;
#ifdef DEBUGMODE
+ gg_debug_level = GG_DEBUG_FUNCTION;
gg_debug_handler = gg_debughandler;
#endif
return TRUE;
diff --git a/protocols/Gadu-Gadu/src/gg.h b/protocols/Gadu-Gadu/src/gg.h index 330f03c8cc..df2cc86b58 100644 --- a/protocols/Gadu-Gadu/src/gg.h +++ b/protocols/Gadu-Gadu/src/gg.h @@ -129,11 +129,6 @@ typedef struct char val[256];
} GGTOKEN;
-#if 0 /* #ifdef DEBUGMODE */
-#define EnterCriticalSection(lpCS) {netlog(gg,"EnterCriticalSection @ %s:%d", __FILE__, __LINE__); EnterCriticalSection(lpCS);}
-#define LeaveCriticalSection(lpCS) {netlog(gg,"LeaveCriticalSection @ %s:%d", __FILE__, __LINE__); LeaveCriticalSection(lpCS);}
-#endif
-
// Wrappers of the old interface
#define GGDEF_PROTO "GG" // Default Proto
diff --git a/protocols/Gadu-Gadu/src/gg_proto.cpp b/protocols/Gadu-Gadu/src/gg_proto.cpp index 1659f0178d..c75f3e70ac 100644 --- a/protocols/Gadu-Gadu/src/gg_proto.cpp +++ b/protocols/Gadu-Gadu/src/gg_proto.cpp @@ -86,7 +86,7 @@ GGPROTO::GGPROTO(const char* pszProtoName, const TCHAR* tszUserName) GGPROTO::~GGPROTO()
{
#ifdef DEBUGMODE
- netlog("gg_proto_uninit(): destroying protocol interface");
+ netlog("~GGPROTO(): destroying protocol interface");
#endif
// Destroy modules
@@ -108,6 +108,9 @@ GGPROTO::~GGPROTO() DeleteCriticalSection(&modemsg_mutex);
DeleteCriticalSection(&avatar_mutex);
DeleteCriticalSection(&sessions_mutex);
+#ifdef DEBUGMODE
+ netlog("~GGPROTO(): DeleteCriticalSections. OK");
+#endif
// Free status messages
if (modemsg.online) mir_free(modemsg.online);
@@ -144,6 +147,9 @@ int GGPROTO::SendAwayMsg(HANDLE hContact, HANDLE hProcess, const char *msg) { HANDLE GGPROTO::AddToList(int flags, PROTOSEARCHRESULT *psr)
{
+#ifdef DEBUGMODE
+ netlog("AddToList(): id=%s");
+#endif
GGSEARCHRESULT *sr = (GGSEARCHRESULT *)psr;
uin_t uin;
@@ -210,9 +216,10 @@ HICON GGPROTO::GetIcon(int iconIndex) void __cdecl GGPROTO::cmdgetinfothread(void *hContact)
{
- SleepEx(100, FALSE);
- netlog("gg_cmdgetinfothread(): Failed info retreival.");
+ netlog("cmdgetinfothread(): started. Failed info retreival.");
+ gg_sleep(100, FALSE, "cmdgetinfothread", 103, 1);
ProtoBroadcastAck(m_szModuleName, hContact, ACKTYPE_GETINFO, ACKRESULT_FAILED, (HANDLE) 1, 0);
+ netlog("cmdgetinfothread(): end.");
}
int GGPROTO::GetInfo(HANDLE hContact, int infoType)
@@ -224,6 +231,9 @@ int GGPROTO::GetInfo(HANDLE hContact, int infoType) {
if (!(req = gg_pubdir50_new(GG_PUBDIR50_SEARCH)))
{
+#ifdef DEBUGMODE
+ netlog("GetInfo(): forkthread 6 GGPROTO::cmdgetinfothread");
+#endif
forkthread(&GGPROTO::cmdgetinfothread, hContact);
return 1;
}
@@ -232,17 +242,20 @@ int GGPROTO::GetInfo(HANDLE hContact, int infoType) gg_pubdir50_add(req, GG_PUBDIR50_UIN, ditoa((uin_t)db_get_dw(hContact, m_szModuleName, GG_KEY_UIN, 0)));
gg_pubdir50_seq_set(req, GG_SEQ_INFO);
- netlog("gg_getinfo(): Requesting user info.", req->seq);
+ netlog("GetInfo(): Requesting user info.", req->seq);
if (isonline())
{
- EnterCriticalSection(&sess_mutex);
+ gg_EnterCriticalSection(&sess_mutex, "GetInfo", 48, "sess_mutex", 1);
if (!gg_pubdir50(sess, req))
{
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "GetInfo", 48, 1, "sess_mutex", 1);
+#ifdef DEBUGMODE
+ netlog("GetInfo(): forkthread 7 GGPROTO::cmdgetinfothread");
+#endif
forkthread(&GGPROTO::cmdgetinfothread, hContact);
return 1;
}
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "GetInfo", 48, 2, "sess_mutex", 1);
}
}
// Own contact info
@@ -250,6 +263,9 @@ int GGPROTO::GetInfo(HANDLE hContact, int infoType) {
if (!(req = gg_pubdir50_new(GG_PUBDIR50_READ)))
{
+#ifdef DEBUGMODE
+ netlog("GetInfo(): forkthread 8 GGPROTO::cmdgetinfothread");
+#endif
forkthread(&GGPROTO::cmdgetinfothread, hContact);
return 1;
}
@@ -257,20 +273,23 @@ int GGPROTO::GetInfo(HANDLE hContact, int infoType) // Add seq
gg_pubdir50_seq_set(req, GG_SEQ_CHINFO);
- netlog("gg_getinfo(): Requesting owner info.", req->seq);
+ netlog("GetInfo(): Requesting owner info.", req->seq);
if (isonline())
{
- EnterCriticalSection(&sess_mutex);
+ gg_EnterCriticalSection(&sess_mutex, "GetInfo", 49, "sess_mutex", 1);
if (!gg_pubdir50(sess, req))
{
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "GetInfo", 49, 1, "sess_mutex", 1);
+#ifdef DEBUGMODE
+ netlog("GetInfo(): forkthread 9 GGPROTO::cmdgetinfothread");
+#endif
forkthread(&GGPROTO::cmdgetinfothread, hContact);
return 1;
}
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "GetInfo", 49, 2, "sess_mutex", 1);
}
}
- netlog("gg_getinfo(): Seq %d.", req->seq);
+ netlog("GetInfo(): Seq %d.", req->seq);
gg_pubdir50_free(req);
return 1;
@@ -281,9 +300,12 @@ int GGPROTO::GetInfo(HANDLE hContact, int infoType) void __cdecl GGPROTO::searchthread(void *)
{
- SleepEx(100, FALSE);
- netlog("gg_searchthread(): Failed search.");
+ netlog("searchthread(): started. Failed search.");
+ gg_sleep(100, FALSE, "searchthread", 104, 1);
ProtoBroadcastAck(m_szModuleName, NULL, ACKTYPE_SEARCH, ACKRESULT_FAILED, (HANDLE)1, 0);
+#ifdef DEBUGMODE
+ netlog("searchthread(): end.");
+#endif
}
HANDLE GGPROTO::SearchBasic(const PROTOCHAR *id)
@@ -293,6 +315,9 @@ HANDLE GGPROTO::SearchBasic(const PROTOCHAR *id) gg_pubdir50_t req;
if (!(req = gg_pubdir50_new(GG_PUBDIR50_SEARCH))) {
+#ifdef DEBUGMODE
+ netlog("SearchBasic(): forkthread 10 GGPROTO::searchthread");
+#endif
forkthread(&GGPROTO::searchthread, NULL);
return (HANDLE)1;
}
@@ -305,15 +330,18 @@ HANDLE GGPROTO::SearchBasic(const PROTOCHAR *id) mir_free(ida);
- EnterCriticalSection(&sess_mutex);
+ gg_EnterCriticalSection(&sess_mutex, "SearchBasic", 50, "sess_mutex", 1);
if (!gg_pubdir50(sess, req))
{
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "SearchBasic", 50, 1, "sess_mutex", 1);
+#ifdef DEBUGMODE
+ netlog("SearchBasic(): forkthread 11 GGPROTO::searchthread");
+#endif
forkthread(&GGPROTO::searchthread, NULL);
return (HANDLE)1;
}
- LeaveCriticalSection(&sess_mutex);
- netlog("gg_basicsearch(): Seq %d.", req->seq);
+ gg_LeaveCriticalSection(&sess_mutex, "SearchBasic", 50, 2, "sess_mutex", 1);
+ netlog("SearchBasic(): Seq %d.", req->seq);
gg_pubdir50_free(req);
return (HANDLE)1;
@@ -337,6 +365,9 @@ HANDLE GGPROTO::SearchByName(const PROTOCHAR *nick, const PROTOCHAR *firstName, if (!(req = gg_pubdir50_new(GG_PUBDIR50_SEARCH)))
{
+#ifdef DEBUGMODE
+ netlog("SearchByName(): forkthread 12 GGPROTO::searchthread");
+#endif
forkthread(&GGPROTO::searchthread, NULL);
return (HANDLE)1;
}
@@ -378,16 +409,18 @@ HANDLE GGPROTO::SearchByName(const PROTOCHAR *nick, const PROTOCHAR *firstName, last_crc = crc;
gg_pubdir50_seq_set(req, GG_SEQ_SEARCH);
-
- EnterCriticalSection(&sess_mutex);
+ gg_EnterCriticalSection(&sess_mutex, "SearchByName", 51, "sess_mutex", 1);
if (!gg_pubdir50(sess, req))
{
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "SearchByName", 51, 1, "sess_mutex", 1);
+#ifdef DEBUGMODE
+ netlog("SearchByName(): forkthread 13 GGPROTO::searchthread");
+#endif
forkthread(&GGPROTO::searchthread, NULL);
return (HANDLE)1;
}
- LeaveCriticalSection(&sess_mutex);
- netlog("gg_searchbyname(): Seq %d.", req->seq);
+ gg_LeaveCriticalSection(&sess_mutex, "SearchByName", 51, 2, "sess_mutex", 1);
+ netlog("SearchByName(): Seq %d.", req->seq);
gg_pubdir50_free(req);
return (HANDLE)1;
@@ -407,6 +440,9 @@ HWND GGPROTO::SearchAdvanced(HWND hwndDlg) if (!(req = gg_pubdir50_new(GG_PUBDIR50_SEARCH)))
{
+#ifdef DEBUGMODE
+ netlog("SearchAdvanced(): forkthread 14 GGPROTO::searchthread");
+#endif
forkthread(&GGPROTO::searchthread, NULL);
return (HWND)1;
}
@@ -508,16 +544,19 @@ HWND GGPROTO::SearchAdvanced(HWND hwndDlg) if (isonline())
{
- EnterCriticalSection(&sess_mutex);
+ gg_EnterCriticalSection(&sess_mutex, "SearchAdvanced", 52, "sess_mutex", 1);
if (!gg_pubdir50(sess, req))
{
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "SearchAdvanced", 52, 1, "sess_mutex", 1);
+#ifdef DEBUGMODE
+ netlog("SearchAdvanced(): forkthread 15 GGPROTO::searchthread");
+#endif
forkthread(&GGPROTO::searchthread, NULL);
return (HWND)1;
}
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "SearchAdvanced", 52, 2, "sess_mutex", 1);
}
- netlog("gg_searchbyadvanced(): Seq %d.", req->seq);
+ netlog("SearchAdvanced(): Seq %d.", req->seq);
gg_pubdir50_free(req);
return (HWND)1;
@@ -572,7 +611,7 @@ typedef struct void __cdecl GGPROTO::sendackthread(void *ack)
{
- SleepEx(100, FALSE);
+ gg_sleep(100, FALSE, "sendackthread", 105, 1);
ProtoBroadcastAck(m_szModuleName, ((GG_SEQ_ACK *)ack)->hContact,
ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE) ((GG_SEQ_ACK *)ack)->seq, 0);
mir_free(ack);
@@ -585,9 +624,9 @@ int GGPROTO::SendMsg(HANDLE hContact, int flags, const char *msg) if (msg && isonline() && (uin = (uin_t)db_get_dw(hContact, m_szModuleName, GG_KEY_UIN, 0)))
{
int seq;
- EnterCriticalSection(&sess_mutex);
+ gg_EnterCriticalSection(&sess_mutex, "SendMsg", 53, "sess_mutex", 1);
seq = gg_send_message(sess, GG_CLASS_CHAT, uin, (BYTE*)msg);
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "SendMsg", 53, 1, "sess_mutex", 1);
if (!db_get_b(NULL, m_szModuleName, GG_KEY_MSGACK, GG_KEYDEF_MSGACK))
{
// Auto-ack message without waiting for server ack
@@ -596,6 +635,9 @@ int GGPROTO::SendMsg(HANDLE hContact, int flags, const char *msg) {
ack->seq = seq;
ack->hContact = hContact;
+#ifdef DEBUGMODE
+ netlog("SendMsg(): forkthread 16 GGPROTO::sendackthread");
+#endif
forkthread(&GGPROTO::sendackthread, ack);
}
}
@@ -621,15 +663,15 @@ int GGPROTO::SetStatus(int iNewStatus) {
int nNewStatus = gg_normalizestatus(iNewStatus);
- EnterCriticalSection(&modemsg_mutex);
+ gg_EnterCriticalSection(&modemsg_mutex, "SetStatus", 54, "modemsg_mutex", 1);
m_iDesiredStatus = nNewStatus;
- LeaveCriticalSection(&modemsg_mutex);
+ gg_LeaveCriticalSection(&modemsg_mutex, "SetStatus", 54, 1, "modemsg_mutex", 1);
// If waiting for connection retry attempt then signal to stop that
if (hConnStopEvent) SetEvent(hConnStopEvent);
if (m_iStatus == nNewStatus) return 0;
- netlog("gg_setstatus(): PS_SETSTATUS(%d) normalized to %d.", iNewStatus, nNewStatus);
+ netlog("SetStatus(): PS_SETSTATUS(%d) normalized to %d.", iNewStatus, nNewStatus);
refreshstatus(nNewStatus);
return 0;
@@ -642,19 +684,24 @@ void __cdecl GGPROTO::getawaymsgthread(void *hContact) {
DBVARIANT dbv;
- SleepEx(100, FALSE);
+ netlog("getawaymsgthread(): started");
+ gg_sleep(100, FALSE, "getawaymsgthread", 106, 1);
if (!db_get_s(hContact, "CList", GG_KEY_STATUSDESCR, &dbv, DBVT_TCHAR))
{
ProtoBroadcastAck(m_szProtoName, hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE) 1, (LPARAM) dbv.ptszVal);
- netlog("gg_getawaymsg(): Reading away msg <" TCHAR_STR_PARAM ">.", dbv.ptszVal);
+ netlog("getawaymsgthread(): Reading away msg <" TCHAR_STR_PARAM ">.", dbv.ptszVal);
DBFreeVariant(&dbv);
- }
- else
+ } else {
ProtoBroadcastAck(m_szProtoName, hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE) 1, (LPARAM) NULL);
+ }
+ netlog("getawaymsgthread(): end");
}
HANDLE GGPROTO::GetAwayMsg(HANDLE hContact)
{
+#ifdef DEBUGMODE
+ netlog("GetAwayMsg(): forkthread 17 GGPROTO::getawaymsgthread");
+#endif
forkthread(&GGPROTO::getawaymsgthread, hContact);
return (HANDLE)1;
}
@@ -668,9 +715,9 @@ int GGPROTO::SetAwayMsg(int iStatus, const PROTOCHAR *msgt) char **szMsg;
char *msg = mir_t2a(msgt);
- netlog("gg_setawaymsg(): PS_SETAWAYMSG(%d, \"%s\").", iStatus, msg);
+ netlog("SetAwayMsg(): PS_SETAWAYMSG(%d, \"%s\").", iStatus, msg);
- EnterCriticalSection(&modemsg_mutex);
+ gg_EnterCriticalSection(&modemsg_mutex, "SetAwayMsg", 55, "modemsg_mutex", 1);
// Select proper msg
switch(status)
{
@@ -690,7 +737,7 @@ int GGPROTO::SetAwayMsg(int iStatus, const PROTOCHAR *msgt) szMsg = &modemsg.invisible;
break;
default:
- LeaveCriticalSection(&modemsg_mutex);
+ gg_LeaveCriticalSection(&modemsg_mutex, "SetAwayMsg", 55, 1, "modemsg_mutex", 1);
mir_free(msg);
return 1;
}
@@ -701,8 +748,8 @@ int GGPROTO::SetAwayMsg(int iStatus, const PROTOCHAR *msgt) {
if (status == m_iDesiredStatus && m_iDesiredStatus == m_iStatus)
{
- netlog("gg_setawaymsg(): Message hasn't been changed, return.");
- LeaveCriticalSection(&modemsg_mutex);
+ netlog("SetAwayMsg(): Message hasn't been changed, return.");
+ gg_LeaveCriticalSection(&modemsg_mutex, "SetAwayMsg", 55, 2, "modemsg_mutex", 1);
mir_free(msg);
return 0;
}
@@ -713,10 +760,10 @@ int GGPROTO::SetAwayMsg(int iStatus, const PROTOCHAR *msgt) mir_free(*szMsg);
*szMsg = msg && *msg ? mir_strdup(msg) : NULL;
#ifdef DEBUGMODE
- netlog("gg_setawaymsg(): Message changed.");
+ netlog("SetAwayMsg(): Message changed.");
#endif
}
- LeaveCriticalSection(&modemsg_mutex);
+ gg_LeaveCriticalSection(&modemsg_mutex, "SetAwayMsg", 55, 3, "modemsg_mutex", 1);
// Change the status if it was desired by PS_SETSTATUS
if (status == m_iDesiredStatus)
@@ -736,9 +783,9 @@ int GGPROTO::UserIsTyping(HANDLE hContact, int type) if (!uin || !isonline()) return 0;
if (type == PROTOTYPE_SELFTYPING_ON || type == PROTOTYPE_SELFTYPING_OFF) {
- EnterCriticalSection(&sess_mutex);
+ gg_EnterCriticalSection(&sess_mutex, "UserIsTyping", 56, "sess_mutex", 1);
gg_typing_notification(sess, uin, (type == PROTOTYPE_SELFTYPING_ON));
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "UserIsTyping", 56, 1, "sess_mutex", 1);
}
return 0;
@@ -772,7 +819,14 @@ int GGPROTO::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam) uninitavatarrequestthread();
// Stop main connection session thread
+#ifdef DEBUGMODE
+ netlog("OnEvent(): EV_PROTO_ONEXIT: Waiting pth_sess thread.");
+#endif
threadwait(&pth_sess);
+#ifdef DEBUGMODE
+ netlog("OnEvent(): EV_PROTO_ONEXIT: Waiting pth_sess thread - OK");
+#endif
+
img_shutdown();
sessions_closedlg();
break;
diff --git a/protocols/Gadu-Gadu/src/gg_proto.h b/protocols/Gadu-Gadu/src/gg_proto.h index 8765392328..615fea1976 100644 --- a/protocols/Gadu-Gadu/src/gg_proto.h +++ b/protocols/Gadu-Gadu/src/gg_proto.h @@ -111,6 +111,10 @@ struct GGPROTO : public PROTO_INTERFACE, public MZeroedObject HANDLE forkthreadex(GGThreadFunc pFunc, void *param, UINT *threadId);
void threadwait(GGTHREAD *thread);
+ void gg_EnterCriticalSection(CRITICAL_SECTION* mutex, char* callingFunction, int sectionNumber, char* mutexName, int logging);
+ void gg_LeaveCriticalSection(CRITICAL_SECTION* mutex, char* callingFunction, int sectionNumber, int returnNumber, char* mutexName, int logging);
+ void gg_sleep(DWORD miliseconds, BOOL alterable, char* callingFunction, int sleepNumber, int logging);
+
/* Global GG functions */
void notifyuser(HANDLE hContact, int refresh);
void setalloffline();
@@ -292,4 +296,36 @@ typedef struct GGPROTO *gg;
} GGUSERUTILDLGDATA;
+
+inline void GGPROTO::gg_EnterCriticalSection(CRITICAL_SECTION* mutex, char* callingFunction, int sectionNumber, char* mutexName, int logging)
+{
+#ifdef DEBUGMODE
+ int logAfter = 0;
+ if(logging == 1 && mutex->LockCount != -1) {
+ logAfter = 1;
+ netlog("%s(): %i before EnterCriticalSection %s LockCount=%ld RecursionCount=%ld OwningThread=%ld", callingFunction, sectionNumber, mutexName, mutex->LockCount, mutex->RecursionCount, mutex->OwningThread);
+ }
+#endif
+ EnterCriticalSection(mutex);
+#ifdef DEBUGMODE
+ if(logging == 1 && logAfter == 1) netlog("%s(): %i after EnterCriticalSection %s LockCount=%ld RecursionCount=%ld OwningThread=%ld", callingFunction, sectionNumber, mutexName, mutex->LockCount, mutex->RecursionCount, mutex->OwningThread);
+#endif
+}
+
+inline void GGPROTO::gg_LeaveCriticalSection(CRITICAL_SECTION* mutex, char* callingFunction, int sectionNumber, int returnNumber, char* mutexName, int logging) /*0-never, 1-debug, 2-all*/
+{
+#ifdef DEBUGMODE
+ if(logging == 1) netlog("%s(): %i.%i LeaveCriticalSection %s", callingFunction, sectionNumber, returnNumber, mutexName);
+#endif
+ LeaveCriticalSection(mutex);
+}
+
+inline void GGPROTO::gg_sleep(DWORD miliseconds, BOOL alterable, char* callingFunction, int sleepNumber, int logging){
+ SleepEx(miliseconds, alterable);
+#ifdef DEBUGMODE
+ if(logging == 1) netlog("%s(): %i after SleepEx(%ld,%u)", callingFunction, sleepNumber, miliseconds, alterable);
+#endif
+}
+
+
#endif
diff --git a/protocols/Gadu-Gadu/src/groupchat.cpp b/protocols/Gadu-Gadu/src/groupchat.cpp index da85d86399..0117ce8805 100644 --- a/protocols/Gadu-Gadu/src/groupchat.cpp +++ b/protocols/Gadu-Gadu/src/groupchat.cpp @@ -48,10 +48,10 @@ int GGPROTO::gc_init() gc_enabled = TRUE;
// create & hook event
mir_snprintf(service, 64, GG_GC_GETCHAT, m_szModuleName);
- netlog("gg_gc_init(): Registered with groupchat plugin.");
+ netlog("gc_init(): Registered with groupchat plugin.");
}
else
- netlog("gg_gc_init(): Cannot register with groupchat plugin !!!");
+ netlog("gc_init(): Cannot register with groupchat plugin !!!");
return 1;
}
@@ -140,7 +140,7 @@ int GGPROTO::gc_event(WPARAM wParam, LPARAM lParam) if (gch->pDest->iType == SESSION_TERMINATE)
{
HANDLE hContact = NULL;
- netlog("gg_gc_event(): Terminating chat %x, id %s from chat window...", chat, gch->pDest->pszID);
+ netlog("gc_event(): Terminating chat %x, id %s from chat window...", chat, gch->pDest->pszID);
// Destroy chat entry
free(chat->recipients);
list_remove(&chats, chat, 1);
@@ -190,13 +190,13 @@ int GGPROTO::gc_event(WPARAM wParam, LPARAM lParam) gcevent.time = time(NULL);
gcevent.bIsMe = 1;
gcevent.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
- netlog("gg_gc_event(): Sending conference message to room %s, \"%s\".", gch->pDest->pszID, pszText);
+ netlog("gc_event(): Sending conference message to room %s, \"%s\".", gch->pDest->pszID, pszText);
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent);
if (pszValT != NULL) mir_free(pszValT);;
- EnterCriticalSection(&sess_mutex);
+ gg_EnterCriticalSection(&sess_mutex, "gc_event", 57, "sess_mutex", 1);
gg_send_message_confer(sess, GG_CLASS_CHAT, chat->recipients_count, chat->recipients, (BYTE*)pszText);
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "gc_event", 57, 1, "sess_mutex", 1);
mir_free(pszText);
return 1;
@@ -210,7 +210,7 @@ int GGPROTO::gc_event(WPARAM wParam, LPARAM lParam) CallService(MS_MSG_SENDMESSAGE, (WPARAM)hContact, 0);
}
char* pszText = mir_t2a(gch->ptszText);
- netlog("gg_gc_event(): Unhandled event %d, chat %x, uin %d, text \"%s\".", gch->pDest->iType, chat, uin, pszText);
+ netlog("gc_event(): Unhandled event %d, chat %x, uin %d, text \"%s\".", gch->pDest->iType, chat, uin, pszText);
mir_free(pszText);
return 0;
@@ -236,7 +236,7 @@ char* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count) GCDEST gcdest = {m_szModuleName, 0, GC_EVENT_ADDGROUP};
GCEVENT gcevent = {sizeof(GCEVENT), &gcdest};
- netlog("gg_gc_getchat(): Count %d.", recipients_count);
+ netlog("gc_getchat(): Count %d.", recipients_count);
if (!recipients) return NULL;
// Look for existing chat
@@ -262,9 +262,9 @@ char* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count) if (found == recipients_count)
{
if (chat->ignore)
- netlog("gg_gc_getchat(): Ignoring existing id %s, size %d.", chat->id, chat->recipients_count);
+ netlog("gc_getchat(): Ignoring existing id %s, size %d.", chat->id, chat->recipients_count);
else
- netlog("gg_gc_getchat(): Returning existing id %s, size %d.", chat->id, chat->recipients_count);
+ netlog("gc_getchat(): Returning existing id %s, size %d.", chat->id, chat->recipients_count);
return !(chat->ignore) ? chat->id : NULL;
}
}
@@ -309,7 +309,7 @@ char* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count) for(i = 0; i < recipients_count; i++)
chat->recipients[i] = recipients[i];
if (sender) chat->recipients[i] = sender;
- netlog("gg_gc_getchat(): Ignoring new chat %s, count %d.", chat->id, chat->recipients_count);
+ netlog("gc_getchat(): Ignoring new chat %s, count %d.", chat->id, chat->recipients_count);
list_add(&chats, chat, 0);
return NULL;
}
@@ -336,7 +336,7 @@ char* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count) // Create new room
if (CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM) &gcwindow))
{
- netlog("gg_gc_getchat(): Cannot create new chat window %s.", chat->id);
+ netlog("gc_getchat(): Cannot create new chat window %s.", chat->id);
free(name);
free(chat);
return NULL;
@@ -364,9 +364,9 @@ char* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count) else gcevent.ptszNick = TranslateT("Me");
gcevent.bIsMe = 1;
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent);
- netlog("gg_gc_getchat(): Myself %s: %S (%S) to the list...", gcevent.pszUID, gcevent.ptszNick, gcevent.ptszStatus);
+ netlog("gc_getchat(): Myself %s: %S (%S) to the list...", gcevent.pszUID, gcevent.ptszNick, gcevent.ptszStatus);
}
- else netlog("gg_gc_getchat(): Myself adding failed with uin %d !!!", uin);
+ else netlog("gc_getchat(): Myself adding failed with uin %d !!!", uin);
// Copy recipient list
chat->recipients_count = recipients_count + (sender ? 1 : 0);
@@ -385,14 +385,14 @@ char* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count) gcevent.ptszNick = TranslateT("'Unknown'");
gcevent.bIsMe = 0;
gcevent.dwFlags = GC_TCHAR;
- netlog("gg_gc_getchat(): Added %s: %S (%S) to the list...", gcevent.pszUID, gcevent.ptszNick, gcevent.pszStatus);
+ netlog("gc_getchat(): Added %s: %S (%S) to the list...", gcevent.pszUID, gcevent.ptszNick, gcevent.pszStatus);
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gcevent);
}
gcdest.iType = GC_EVENT_CONTROL;
CallServiceSync(MS_GC_EVENT, SESSION_INITDONE, (LPARAM)&gcevent);
CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, (LPARAM)&gcevent);
- netlog("gg_gc_getchat(): Returning new chat window %s, count %d.", chat->id, chat->recipients_count);
+ netlog("gc_getchat(): Returning new chat window %s, count %d.", chat->id, chat->recipients_count);
list_add(&chats, chat, 0);
return chat->id;
}
@@ -488,7 +488,7 @@ static INT_PTR CALLBACK gg_gc_openconfdlg(HWND hwndDlg, UINT message, WPARAM wPa char* chat;
uin_t* participants = (uin_t*)calloc(count, sizeof(uin_t));
HANDLE hItem, hContact = db_find_first();
- gg->netlog("gg_gc_getchat(): Opening new conference for %d contacts.", count);
+ gg->netlog("gg_gc_openconfdlg(): WM_COMMAND IDOK Opening new conference for %d contacts.", count);
while (hContact && i < count)
{
hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
@@ -649,7 +649,7 @@ int GGPROTO::gc_changenick(HANDLE hContact, char *pszNick) uin_t uin = db_get_dw(hContact, m_szModuleName, GG_KEY_UIN, 0);
if (!uin || !pszNick) return 0;
- netlog("gg_gc_changenick(): Nickname for uin %d changed to %s.", uin, pszNick);
+ netlog("gc_changenick(): Nickname for uin %d changed to %s.", uin, pszNick);
// Lookup for chats having this nick
for(l = chats; l; l = l->next) {
GGGC *chat = (GGGC *)l->data;
@@ -669,7 +669,7 @@ int GGPROTO::gc_changenick(HANDLE hContact, char *pszNick) gcd.pszID = chat->id;
gce.pszUID = id;
gce.pszText = pszNick;
- netlog("gg_gc_changenick(): Found room %s with uin %d, sending nick change %s.", chat->id, uin, id);
+ netlog("gc_changenick(): Found room %s with uin %d, sending nick change %s.", chat->id, uin, id);
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
break;
diff --git a/protocols/Gadu-Gadu/src/image.cpp b/protocols/Gadu-Gadu/src/image.cpp index 2567838406..9a6b934054 100644 --- a/protocols/Gadu-Gadu/src/image.cpp +++ b/protocols/Gadu-Gadu/src/image.cpp @@ -97,7 +97,7 @@ int GGPROTO::img_shutdown() {
list_t l;
#ifdef DEBUGMODE
- netlog("gg_img_shutdown(): Closing all dialogs...");
+ netlog("img_shutdown(): Closing all dialogs...");
#endif
// Rather destroy window instead of just removing structures
for (l = imagedlgs; l;)
@@ -111,10 +111,10 @@ int GGPROTO::img_shutdown() {
// Post message async, since it maybe be different thread
if (!PostMessage(dat->hWnd, WM_CLOSE, 0, 0))
- netlog("gg_img_shutdown(): Image dlg %x cannot be released !!", dat->hWnd);
+ netlog("img_shutdown(): Image dlg %x cannot be released !!", dat->hWnd);
}
else
- netlog("gg_img_shutdown(): Image dlg %x not exists, but structure does !!", dat->hWnd);
+ netlog("img_shutdown(): Image dlg %x not exists, but structure does !!", dat->hWnd);
}
}
@@ -403,7 +403,7 @@ static INT_PTR CALLBACK gg_img_dlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP // Send event if someone's waiting
if (dat->hEvent) SetEvent(dat->hEvent);
- else dat->gg->netlog("gg_img_dlgproc(): Creation event not found, but someone might be waiting.");
+ else dat->gg->netlog("gg_img_dlgproc(): WM_INITDIALOG Creation event not found, but someone might be waiting.");
// Making buttons flat
SendDlgItemMessage(hwndDlg, IDC_IMG_PREV, BUTTONSETASFLATBTN, TRUE, 0);
@@ -504,7 +504,7 @@ static INT_PTR CALLBACK gg_img_dlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP if (!img)
{
- dat->gg->netlog("gg_img_dlgproc(): Image was not found on the list. Cannot paint the window.");
+ dat->gg->netlog("gg_img_dlgproc(): WM_PAINT Image was not found on the list. Cannot paint the window.");
return FALSE;
}
@@ -536,9 +536,9 @@ static INT_PTR CALLBACK gg_img_dlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP ReleaseIconEx("delete", FALSE);
ReleaseIconEx("save", FALSE);
WindowFreeIcon(hwndDlg);
- EnterCriticalSection(&gg->img_mutex);
+ gg->gg_EnterCriticalSection(&gg->img_mutex, "gg_img_dlgproc", 58, "img_mutex", 1);
list_remove(&gg->imagedlgs, dat, 1);
- LeaveCriticalSection(&gg->img_mutex);
+ gg->gg_LeaveCriticalSection(&gg->img_mutex, "gg_img_dlgproc", 58, 1, "img_mutex", 1);
}
return TRUE;
@@ -580,7 +580,7 @@ static INT_PTR CALLBACK gg_img_dlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP img = img->lpNext;
if (!img)
{
- dat->gg->netlog("gg_img_dlgproc(): Image was not found on the list. Cannot delete it from the list.");
+ dat->gg->netlog("gg_img_dlgproc(): IDC_IMG_DELETE Image was not found on the list. Cannot delete it from the list.");
return FALSE;
}
del = img->lpNext;
@@ -606,7 +606,7 @@ static INT_PTR CALLBACK gg_img_dlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP img = img->lpNext;
if (!img)
{
- dat->gg->netlog("gg_img_dlgproc(): Image was not found on the list. Cannot launch saving.");
+ dat->gg->netlog("gg_img_dlgproc(): IDC_IMG_SAVE Image was not found on the list. Cannot launch saving.");
return FALSE;
}
gg_img_saveimage(hwndDlg, img);
@@ -642,9 +642,9 @@ static INT_PTR CALLBACK gg_img_dlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP len = sizeof(struct gg_msg_richtext_format) + sizeof(struct gg_msg_richtext_image);
((struct gg_msg_richtext*)format)->length = len;
- EnterCriticalSection(&gg->sess_mutex);
+ gg->gg_EnterCriticalSection(&gg->sess_mutex, "gg_img_dlgproc", 59, "sess_mutex", 1);
gg_send_message_richtext(gg->sess, GG_CLASS_CHAT, (uin_t)uin, (unsigned char*)msg, format, len + sizeof(struct gg_msg_richtext));
- LeaveCriticalSection(&gg->sess_mutex);
+ gg->gg_LeaveCriticalSection(&gg->sess_mutex, "gg_img_dlgproc", 59, 1, "sess_mutex", 1);
// Protect dat from releasing
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)0);
@@ -724,9 +724,14 @@ void __cdecl GGPROTO::img_dlgcallthread(void *param) {
HWND hMIWnd = 0; //(HWND) CallService(MS_CLUI_GETHWND, 0, 0);
+ netlog("img_dlgcallthread(): started.");
GGIMAGEDLGDATA *dat = (GGIMAGEDLGDATA *)param;
DialogBoxParam(hInstance, dat->bReceiving ? MAKEINTRESOURCE(IDD_IMAGE_RECV) : MAKEINTRESOURCE(IDD_IMAGE_SEND),
hMIWnd, gg_img_dlgproc, (LPARAM) dat);
+#ifdef DEBUGMODE
+ netlog("img_dlgcallthread(): end.");
+#endif
+
}
////////////////////////////////////////////////////////////////////////////
@@ -740,6 +745,9 @@ GGIMAGEDLGDATA *gg_img_recvdlg(GGPROTO *gg, HANDLE hContact) dat->bReceiving = TRUE;
dat->gg = gg;
ResetEvent(dat->hEvent);
+#ifdef DEBUGMODE
+ gg->netlog("gg_img_recvdlg(): forkthread 18 GGPROTO::img_dlgcallthread");
+#endif
gg->forkthread(&GGPROTO::img_dlgcallthread, dat);
return dat;
}
@@ -855,11 +863,11 @@ int GGPROTO::img_displayasmsg(HANDLE hContact, void *img) pre.timestamp = time(NULL);
pre.szMessage = image_msg;
CallService(MS_PROTO_CHAINRECV, 0, (LPARAM) &ccs);
- netlog("gg_img_displayasmsg: Image saved to %s.", szPath);
+ netlog("img_displayasmsg(): Image saved to %s.", szPath);
}
else
{
- netlog("gg_img_displayasmsg: Cannot save image to %s.", szPath);
+ netlog("img_displayasmsg(): Cannot save image to %s.", szPath);
}
return 0;
@@ -892,7 +900,7 @@ int GGPROTO::img_display(HANDLE hContact, void *img) if (!img) return FALSE;
// Look for already open dialog
- EnterCriticalSection(&img_mutex);
+ gg_EnterCriticalSection(&img_mutex, "img_display", 60, "img_mutex", 1);
while (l)
{
dat = (GGIMAGEDLGDATA *)l->data;
@@ -914,7 +922,7 @@ int GGPROTO::img_display(HANDLE hContact, void *img) list_add(&imagedlgs, dat, 0);
}
- LeaveCriticalSection(&img_mutex);
+ gg_LeaveCriticalSection(&img_mutex, "img_display", 60, 1, "img_mutex", 1);
SendMessage(dat->hWnd, WM_ADDIMAGE, 0, (LPARAM)img);
if (/*db_get_b(NULL, "Chat", "FlashWindowHighlight", 0) != 0 && */
@@ -969,7 +977,7 @@ void* GGPROTO::img_loadpicture(gg_event* e, TCHAR *szFileName) FILE *fp = _tfopen(szFileName, _T("rb"));
if (!fp) {
free(dat);
- netlog("gg_img_loadpicture(): fopen(\"%s\", \"rb\") failed.", szFileName);
+ netlog("img_loadpicture(): fopen(\"%s\", \"rb\") failed.", szFileName);
return NULL;
}
fseek(fp, 0, SEEK_END);
@@ -978,7 +986,7 @@ void* GGPROTO::img_loadpicture(gg_event* e, TCHAR *szFileName) {
fclose(fp);
free(dat);
- netlog("gg_img_loadpicture(): Zero file size \"%s\" failed.", szFileName);
+ netlog("img_loadpicture(): Zero file size \"%s\" failed.", szFileName);
return NULL;
}
// Maximum acceptable image size
@@ -986,7 +994,7 @@ void* GGPROTO::img_loadpicture(gg_event* e, TCHAR *szFileName) {
fclose(fp);
free(dat);
- netlog("gg_img_loadpicture(): Image size of \"%s\" exceeds 255 KB.", szFileName);
+ netlog("img_loadpicture(): Image size of \"%s\" exceeds 255 KB.", szFileName);
MessageBox(NULL, TranslateT("Image exceeds maximum allowed size of 255 KB."), m_tszUserName, MB_OK | MB_ICONEXCLAMATION);
return NULL;
}
@@ -997,7 +1005,7 @@ void* GGPROTO::img_loadpicture(gg_event* e, TCHAR *szFileName) free(dat->lpData);
fclose(fp);
free(dat);
- netlog("gg_img_loadpicture(): Reading file \"%s\" failed.", szFileName);
+ netlog("img_loadpicture(): Reading file \"%s\" failed.", szFileName);
return NULL;
}
fclose(fp);
@@ -1047,7 +1055,7 @@ void* GGPROTO::img_loadpicture(gg_event* e, TCHAR *szFileName) // If everything is fine return the handle
if (dat->hBitmap) return dat;
- netlog("gg_img_loadpicture(): MS_IMG_LOAD(MEM) failed.");
+ netlog("img_loadpicture(): MS_IMG_LOAD(MEM) failed.");
if (dat)
{
if (dat->lpData)
@@ -1066,7 +1074,7 @@ INT_PTR GGPROTO::img_recvimage(WPARAM wParam, LPARAM lParam) CLISTEVENT *cle = (CLISTEVENT *)lParam;
GGIMAGEENTRY *img = (GGIMAGEENTRY *)cle->lParam;
- netlog("gg_img_recvimage(%x, %x): Popup new image.", wParam, lParam);
+ netlog("img_recvimage(%x, %x): Popup new image.", wParam, lParam);
if (!img) return FALSE;
img_display(cle->hContact, img);
@@ -1088,7 +1096,7 @@ int gg_img_remove(GGIMAGEDLGDATA *dat) if (!dat) return FALSE;
gg = dat->gg;
- EnterCriticalSection(&gg->img_mutex);
+ gg->gg_EnterCriticalSection(&gg->img_mutex, "gg_img_remove", 61, "img_mutex", 1);
// Remove the structure
img = dat->lpImages;
@@ -1102,7 +1110,7 @@ int gg_img_remove(GGIMAGEDLGDATA *dat) // Remove from list
list_remove(&gg->imagedlgs, dat, 1);
- LeaveCriticalSection(&gg->img_mutex);
+ gg->gg_LeaveCriticalSection(&gg->img_mutex, "gg_img_remove", 61, 1, "img_mutex", 1);
return TRUE;
}
@@ -1115,7 +1123,7 @@ GGIMAGEDLGDATA* gg_img_find(GGPROTO *gg, uin_t uin, uint32_t crc32) list_t l = gg->imagedlgs;
GGIMAGEDLGDATA *dat;
- EnterCriticalSection(&gg->img_mutex);
+ gg->gg_EnterCriticalSection(&gg->img_mutex, "gg_img_find", 62, "img_mutex", 1);
while (l)
{
uin_t c_uin;
@@ -1127,13 +1135,13 @@ GGIMAGEDLGDATA* gg_img_find(GGPROTO *gg, uin_t uin, uint32_t crc32) if (!dat->bReceiving && dat->lpImages && dat->lpImages->crc32 == crc32 && c_uin == uin)
{
- LeaveCriticalSection(&gg->img_mutex);
+ gg->gg_LeaveCriticalSection(&gg->img_mutex, "gg_img_find", 62, 1, "img_mutex", 1);
return dat;
}
l = l->next;
}
- LeaveCriticalSection(&gg->img_mutex);
+ gg->gg_LeaveCriticalSection(&gg->img_mutex, "gg_img_find", 62, 2, "img_mutex", 1);
gg->netlog("gg_img_find(): Image not found on the list. It might be released before calling this function.");
return NULL;
@@ -1149,11 +1157,11 @@ BOOL GGPROTO::img_sendonrequest(gg_event* e) if (!this || !dat || !isonline())
return FALSE;
- char* lpszFileNameA = mir_t2a(dat->lpImages->lpszFileName);
- EnterCriticalSection(&sess_mutex);
+ char* lpszFileNameA = mir_t2a(dat->lpImages->lpszFileName);
+ gg_EnterCriticalSection(&sess_mutex, "img_sendonrequest", 63, "sess_mutex", 1);
gg_image_reply(sess, e->event.image_request.sender, lpszFileNameA, dat->lpImages->lpData, dat->lpImages->nSize);
- LeaveCriticalSection(&sess_mutex);
- mir_free(lpszFileNameA);
+ gg_LeaveCriticalSection(&sess_mutex, "img_sendonrequest", 63, 1, "sess_mutex", 1);
+ mir_free(lpszFileNameA);
gg_img_remove(dat);
@@ -1168,7 +1176,7 @@ INT_PTR GGPROTO::img_sendimg(WPARAM wParam, LPARAM lParam) HANDLE hContact = (HANDLE)wParam;
GGIMAGEDLGDATA *dat = NULL;
- EnterCriticalSection(&img_mutex);
+ gg_EnterCriticalSection(&img_mutex, "img_sendimg", 64, "img_mutex", 1);
if (!dat)
{
dat = (GGIMAGEDLGDATA *)calloc(1, sizeof(GGIMAGEDLGDATA));
@@ -1178,6 +1186,9 @@ INT_PTR GGPROTO::img_sendimg(WPARAM wParam, LPARAM lParam) ResetEvent(dat->hEvent);
// Create new dialog
+#ifdef DEBUGMODE
+ netlog("img_sendimg(): forkthread 19 GGPROTO::img_dlgcallthread");
+#endif
forkthread(&GGPROTO::img_dlgcallthread, dat);
while (WaitForSingleObjectEx(dat->hEvent, INFINITE, TRUE) != WAIT_OBJECT_0);
@@ -1189,7 +1200,7 @@ INT_PTR GGPROTO::img_sendimg(WPARAM wParam, LPARAM lParam) // Request choose dialog
SendMessage(dat->hWnd, WM_CHOOSEIMG, 0, 0);
- LeaveCriticalSection(&img_mutex);
+ gg_LeaveCriticalSection(&img_mutex, "img_sendimg", 64, 1, "img_mutex", 1);
return 0;
}
diff --git a/protocols/Gadu-Gadu/src/import.cpp b/protocols/Gadu-Gadu/src/import.cpp index 7fcb8b0df8..3ccc95c7fe 100644 --- a/protocols/Gadu-Gadu/src/import.cpp +++ b/protocols/Gadu-Gadu/src/import.cpp @@ -284,7 +284,7 @@ void GGPROTO::parsecontacts(char *contacts) {
HANDLE hContact = getcontact(uin, 1, 1, _A2T(strNick));
#ifdef DEBUGMODE
- netlog("gg_parsecontacts(): Found contact %d with nickname \"%s\".", uin, strNick);
+ netlog("parsecontacts(): Found contact %d with nickname \"%s\".", uin, strNick);
#endif
// Write group
if (hContact && strGroup)
@@ -341,16 +341,16 @@ INT_PTR GGPROTO::import_server(WPARAM wParam, LPARAM lParam) return 0;
// Making contacts list
- EnterCriticalSection(&sess_mutex);
+ gg_EnterCriticalSection(&sess_mutex, "import_server", 65, "sess_mutex", 1);
if (gg_userlist_request(sess, GG_USERLIST_GET, NULL) == -1)
{
TCHAR error[128];
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "import_server", 65, 1, "sess_mutex", 1);
mir_sntprintf(error, SIZEOF(error), TranslateT("List cannot be imported because of error:\n\t%s"), _tcserror(errno));
MessageBox(NULL, error, m_tszUserName, MB_OK | MB_ICONSTOP);
- netlog("gg_import_server(): Cannot import list because of \"%s\".", strerror(errno));
+ netlog("import_server(): Cannot import list because of \"%s\".", strerror(errno));
}
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "import_server", 65, 2, "sess_mutex", 1);
free(password);
return 0;
@@ -388,16 +388,16 @@ INT_PTR GGPROTO::remove_server(WPARAM wParam, LPARAM lParam) return 0;
// Making contacts list
- EnterCriticalSection(&sess_mutex);
+ gg_EnterCriticalSection(&sess_mutex, "remove_server", 66, "sess_mutex", 1);
if (gg_userlist_request(sess, GG_USERLIST_PUT, NULL) == -1)
{
TCHAR error[128];
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "remove_server", 66, 1, "sess_mutex", 1);
mir_sntprintf(error, SIZEOF(error), TranslateT("List cannot be removeed because of error:\n\t%s"), _tcserror(errno));
MessageBox(NULL, error, m_tszUserName, MB_OK | MB_ICONSTOP);
- netlog("gg_remove_server(): Cannot remove list because of \"%s\".", strerror(errno));
+ netlog("remove_server(): Cannot remove list because of \"%s\".", strerror(errno));
}
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "remove_server", 66, 2, "sess_mutex", 1);
// Set list removal
is_list_remove = TRUE;
@@ -446,7 +446,7 @@ INT_PTR GGPROTO::import_text(WPARAM wParam, LPARAM lParam) ofn.lpstrDefExt = _T("txt");
#ifdef DEBUGMODE
- netlog("gg_import_text()");
+ netlog("import_text()");
#endif
if (!GetOpenFileName(&ofn)) return 0;
@@ -468,7 +468,7 @@ INT_PTR GGPROTO::import_text(WPARAM wParam, LPARAM lParam) TCHAR error[128];
mir_sntprintf(error, SIZEOF(error), TranslateT("List cannot be imported from file \"%s\" because of error:\n\t%s"), str, _tcserror(errno));
MessageBox(NULL, error, m_tszUserName, MB_OK | MB_ICONSTOP);
- netlog("gg_import_text(): Cannot import list from file \"%S\" because of \"%s\".", str, strerror(errno));
+ netlog("import_text(): Cannot import list from file \"%S\" because of \"%s\".", str, strerror(errno));
}
return 0;
@@ -512,7 +512,7 @@ INT_PTR GGPROTO::export_text(WPARAM wParam, LPARAM lParam) ofn.lpstrDefExt = _T("txt");
#ifdef DEBUGMODE
- netlog("gg_export_text(%s).", str);
+ netlog("export_text(%s).", str);
#endif
if (!GetSaveFileName(&ofn)) return 0;
@@ -529,7 +529,7 @@ INT_PTR GGPROTO::export_text(WPARAM wParam, LPARAM lParam) TCHAR error[128];
mir_sntprintf(error, SIZEOF(error), TranslateT("List cannot be exported to file \"%s\" because of error:\n\t%s"), str, _tcserror(errno));
MessageBox(NULL, error, m_tszUserName, MB_OK | MB_ICONSTOP);
- netlog("gg_import_text(): Cannot export list to file \"%s\" because of \"%s\".", str, strerror(errno));
+ netlog("export_text(): Cannot export list to file \"%s\" because of \"%s\".", str, strerror(errno));
}
return 0;
@@ -570,19 +570,19 @@ INT_PTR GGPROTO::export_server(WPARAM wParam, LPARAM lParam) contacts = gg_makecontacts(this, 1);
#ifdef DEBUGMODE
- netlog("gg_userlist_request(%s).", contacts);
+ netlog("export_server(): gg_userlist_request(%s).", contacts);
#endif
- EnterCriticalSection(&sess_mutex);
+ gg_EnterCriticalSection(&sess_mutex, "export_server", 67, "sess_mutex", 1);
if (gg_userlist_request(sess, GG_USERLIST_PUT, contacts) == -1)
{
TCHAR error[128];
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "export_server", 67, 1, "sess_mutex", 1);
mir_sntprintf(error, SIZEOF(error), TranslateT("List cannot be exported because of error:\n\t%s"), _tcserror(errno));
MessageBox(NULL, error, m_tszUserName, MB_OK | MB_ICONSTOP);
- netlog("gg_export_server(): Cannot export list because of \"%s\".", strerror(errno));
+ netlog("export_server(): Cannot export list because of \"%s\".", strerror(errno));
}
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "export_server", 67, 2, "sess_mutex", 1);
// Set list removal
is_list_remove = FALSE;
diff --git a/protocols/Gadu-Gadu/src/keepalive.cpp b/protocols/Gadu-Gadu/src/keepalive.cpp index 02b661c222..d7b0dbc685 100644 --- a/protocols/Gadu-Gadu/src/keepalive.cpp +++ b/protocols/Gadu-Gadu/src/keepalive.cpp @@ -41,11 +41,11 @@ static VOID CALLBACK gg_keepalive(HWND hwnd, UINT message, UINT_PTR idEvent, DWO if (gg->isonline())
{
#ifdef DEBUGMODE
- gg->netlog("Sending keep-alive");
+ gg->netlog("gg_keepalive(): Sending keep-alive");
#endif
- EnterCriticalSection(&gg->sess_mutex);
+ gg->gg_EnterCriticalSection(&gg->sess_mutex, "gg_keepalive", 68, "sess_mutex", 1);
gg_ping(gg->sess);
- LeaveCriticalSection(&gg->sess_mutex);
+ gg->gg_LeaveCriticalSection(&gg->sess_mutex, "gg_keepalive", 68, 1, "sess_mutex", 1);
}
}
}
@@ -59,7 +59,7 @@ void GGPROTO::keepalive_init() if (i < MAX_TIMERS)
{
#ifdef DEBUGMODE
- netlog("gg_keepalive_init(): Initializing Timer %d", i);
+ netlog("keepalive_init(): Initializing Timer %d", i);
#endif
timer = SetTimer(NULL, 0, 1000 * 30, gg_keepalive);
g_timers[i] = this;
@@ -70,7 +70,7 @@ void GGPROTO::keepalive_init() void GGPROTO::keepalive_destroy()
{
#ifdef DEBUGMODE
- netlog("gg_destroykeepalive(): Killing Timer");
+ netlog("keepalive_destroy(): Killing Timer");
#endif
if (timer)
{
@@ -83,10 +83,10 @@ void GGPROTO::keepalive_destroy() }
timer = 0;
#ifdef DEBUGMODE
- netlog("gg_destroykeepalive(): Killed Timer %d", i);
+ netlog("keepalive_destroy(): Killed Timer %d", i);
#endif
}
#ifdef DEBUGMODE
- netlog("gg_destroykeepalive(): End");
+ netlog("keepalive_destroy(): End");
#endif
}
diff --git a/protocols/Gadu-Gadu/src/oauth.cpp b/protocols/Gadu-Gadu/src/oauth.cpp index 43983edb6d..007e364507 100644 --- a/protocols/Gadu-Gadu/src/oauth.cpp +++ b/protocols/Gadu-Gadu/src/oauth.cpp @@ -403,7 +403,7 @@ int GGPROTO::oauth_receivetoken() }
// 1. Obtaining an Unauthorized Request Token
- netlog("gg_oauth_receivetoken(): Obtaining an Unauthorized Request Token...");
+ netlog("oauth_receivetoken(): Obtaining an Unauthorized Request Token...");
strcpy(szUrl, "http://api.gadu-gadu.pl/request_token");
str = oauth_auth_header("POST", szUrl, HMACSHA1, uin, password, NULL, NULL);
@@ -447,13 +447,13 @@ int GGPROTO::oauth_receivetoken() mir_free(tag);
mir_free(xmlAction);
}
- else netlog("gg_oauth_receivetoken(): Invalid response code from HTTP request");
+ else netlog("oauth_receivetoken(): Invalid response code from HTTP request");
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp);
}
- else netlog("gg_oauth_receivetoken(): No response from HTTP request");
+ else netlog("oauth_receivetoken(): No response from HTTP request");
// 2. Obtaining User Authorization
- netlog("gg_oauth_receivetoken(): Obtaining User Authorization...");
+ netlog("oauth_receivetoken(): Obtaining User Authorization...");
mir_free(str);
str = oauth_uri_escape("http://www.mojageneracja.pl");
@@ -477,10 +477,10 @@ int GGPROTO::oauth_receivetoken() resp = (NETLIBHTTPREQUEST *)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)netlib, (LPARAM)&req);
if (resp) CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp);
- else netlog("gg_oauth_receivetoken(): No response from HTTP request");
+ else netlog("oauth_receivetoken(): No response from HTTP request");
// 3. Obtaining an Access Token
- netlog("gg_oauth_receivetoken(): Obtaining an Access Token...");
+ netlog("oauth_receivetoken(): Obtaining an Access Token...");
strcpy(szUrl, "http://api.gadu-gadu.pl/access_token");
mir_free(str);
str = oauth_auth_header("POST", szUrl, HMACSHA1, uin, password, token, token_secret);
@@ -526,11 +526,11 @@ int GGPROTO::oauth_receivetoken() mir_free(tag);
mir_free(xmlAction);
}
- else netlog("gg_oauth_receivetoken(): Invalid response code from HTTP request");
+ else netlog("oauth_receivetoken(): Invalid response code from HTTP request");
Netlib_CloseHandle(resp->nlc);
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp);
}
- else netlog("gg_oauth_receivetoken(): No response from HTTP request");
+ else netlog("oauth_receivetoken(): No response from HTTP request");
mir_free(password);
mir_free(str);
@@ -539,13 +539,13 @@ int GGPROTO::oauth_receivetoken() db_set_s(NULL, m_szModuleName, GG_KEY_TOKEN, token);
CallService(MS_DB_CRYPT_ENCODESTRING, (WPARAM)(int)strlen(token_secret) + 1, (LPARAM) token_secret);
db_set_s(NULL, m_szModuleName, GG_KEY_TOKENSECRET, token_secret);
- netlog("gg_oauth_receivetoken(): Access Token obtained successfully.");
+ netlog("oauth_receivetoken(): Access Token obtained successfully.");
res = 1;
}
else {
db_unset(NULL, m_szModuleName, GG_KEY_TOKEN);
db_unset(NULL, m_szModuleName, GG_KEY_TOKENSECRET);
- netlog("gg_oauth_receivetoken(): Failed to obtain Access Token.");
+ netlog("oauth_receivetoken(): Failed to obtain Access Token.");
}
mir_free(token);
mir_free(token_secret);
diff --git a/protocols/Gadu-Gadu/src/ownerinfo.cpp b/protocols/Gadu-Gadu/src/ownerinfo.cpp index 6c37cdb180..a0549f8316 100644 --- a/protocols/Gadu-Gadu/src/ownerinfo.cpp +++ b/protocols/Gadu-Gadu/src/ownerinfo.cpp @@ -36,36 +36,42 @@ void __cdecl GGPROTO::remindpasswordthread(void *param) GG_REMIND_PASS *rp = (GG_REMIND_PASS *)param;
GGTOKEN token;
-#ifdef DEBUGMODE
- netlog("gg_remindpasswordthread(): Starting.");
-#endif
+ netlog("remindpasswordthread(): Started.");
if (!rp || !rp->email || !rp->uin || !strlen(rp->email))
{
if (rp) free(rp);
+#ifdef DEBUGMODE
+ netlog("remindpasswordthread(): End. err1");
+#endif
return;
}
// Get token
- if (!gettoken(&token)) return;
+ if (!gettoken(&token)){
+#ifdef DEBUGMODE
+ netlog("remindpasswordthread(): End. err2");
+#endif
+ return;
+ }
if (!(h = gg_remind_passwd3(rp->uin, rp->email, token.id, token.val, 0)))
{
TCHAR error[128];
mir_sntprintf(error, SIZEOF(error), TranslateT("Password could not be reminded because of error:\n\t%s"), _tcserror(errno));
MessageBox(NULL, error, m_tszUserName, MB_OK | MB_ICONSTOP);
- netlog("gg_remindpasswordthread(): Password could not be reminded because of \"%s\".", strerror(errno));
+ netlog("remindpasswordthread(): Password could not be reminded because of \"%s\".", strerror(errno));
}
else
{
gg_pubdir_free(h);
- netlog("gg_remindpasswordthread(): Password remind successful.");
+ netlog("remindpasswordthread(): Password remind successful.");
MessageBox(NULL, TranslateT("Password was sent to your e-mail."), m_tszUserName, MB_OK | MB_ICONINFORMATION);
}
+ if (rp) free(rp);
#ifdef DEBUGMODE
- netlog("gg_remindpasswordthread(): End.");
+ netlog("remindpasswordthread(): End.");
#endif
- if (rp) free(rp);
}
void GGPROTO::remindpassword(uin_t uin, const char *email)
@@ -74,5 +80,8 @@ void GGPROTO::remindpassword(uin_t uin, const char *email) rp->uin = uin;
rp->email = email;
+#ifdef DEBUGMODE
+ netlog("remindpassword(): forkthreadex 20 GGPROTO::remindpasswordthread");
+#endif
forkthread(&GGPROTO::remindpasswordthread, rp);
}
diff --git a/protocols/Gadu-Gadu/src/services.cpp b/protocols/Gadu-Gadu/src/services.cpp index a172d10609..11c8a25ac1 100644 --- a/protocols/Gadu-Gadu/src/services.cpp +++ b/protocols/Gadu-Gadu/src/services.cpp @@ -89,31 +89,35 @@ int GGPROTO::refreshstatus(int status) if (exitCode == STILL_ACTIVE)
return TRUE;
#ifdef DEBUGMODE
- netlog("gg_refreshstatus(): Going to connect...");
+ netlog("refreshstatus(): Waiting pth_sess thread. Going to connect...");
#endif
threadwait(&pth_sess);
+#ifdef DEBUGMODE
+ netlog("refreshstatus(): Waiting pth_sess thread - OK");
+ netlog("refreshstatus(): forkthreadex 21 GGPROTO::mainthread");
+#endif
pth_sess.hThread = forkthreadex(&GGPROTO::mainthread, NULL, &pth_sess.dwThreadId);
}
else
{
char *szMsg = NULL;
// Select proper msg
- EnterCriticalSection(&modemsg_mutex);
+ gg_EnterCriticalSection(&modemsg_mutex, "refreshstatus", 69, "modemsg_mutex", 1);
szMsg = mir_strdup(getstatusmsg(status));
- LeaveCriticalSection(&modemsg_mutex);
+ gg_LeaveCriticalSection(&modemsg_mutex, "refreshstatus", 69, 1, "modemsg_mutex", 1);
if (szMsg)
{
- netlog("gg_refreshstatus(): Setting status and away message.");
- EnterCriticalSection(&sess_mutex);
+ netlog("refreshstatus(): Setting status and away message.");
+ gg_EnterCriticalSection(&sess_mutex, "refreshstatus", 70, "sess_mutex", 1);
gg_change_status_descr(sess, status_m2gg(status, szMsg != NULL), szMsg);
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "refreshstatus", 70, 1, "sess_mutex", 1);
}
else
{
- netlog("gg_refreshstatus(): Setting just status.");
- EnterCriticalSection(&sess_mutex);
+ netlog("refreshstatus(): Setting just status.");
+ gg_EnterCriticalSection(&sess_mutex, "refreshstatus", 71, "sess_mutex", 1);
gg_change_status(sess, status_m2gg(status, 0));
- LeaveCriticalSection(&sess_mutex);
+ gg_LeaveCriticalSection(&sess_mutex, "refreshstatus", 71, 1, "sess_mutex", 1);
}
// Change status of the contact with our own UIN (if got yourself added to the contact list)
changecontactstatus( db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0), status_m2gg(status, szMsg != NULL), szMsg, 0, 0, 0, 0);
@@ -174,7 +178,7 @@ INT_PTR GGPROTO::getavatarinfo(WPARAM wParam, LPARAM lParam) DBVARIANT dbv;
uin_t uin = (uin_t)db_get_dw(pai->hContact, m_szModuleName, GG_KEY_UIN, 0);
- netlog("gg_getavatarinfo(): Requesting avatar information for %d.", uin);
+ netlog("getavatarinfo(): Requesting avatar information for %d.", uin);
pai->filename[0] = 0;
pai->format = PA_FORMAT_UNKNOWN;
@@ -212,7 +216,7 @@ INT_PTR GGPROTO::getavatarinfo(WPARAM wParam, LPARAM lParam) result = GAIR_SUCCESS;
}
else if ((wParam & GAIF_FORCE) != 0) {
- netlog("gg_getavatarinfo(): Contact %d changed avatar.", uin);
+ netlog("getavatarinfo(): Contact %d changed avatar.", uin);
_tremove(pai->filename);
db_set_s(pai->hContact, m_szModuleName, GG_KEY_AVATARHASH, AvatarHash);
getAvatar(pai->hContact, AvatarURL);
@@ -221,7 +225,7 @@ INT_PTR GGPROTO::getavatarinfo(WPARAM wParam, LPARAM lParam) }
else if ((wParam & GAIF_FORCE) != 0) {
if (AvatarHash == NULL && AvatarSavedHash != NULL) {
- netlog("gg_getavatarinfo(): Contact %d deleted avatar.", uin);
+ netlog("getavatarinfo(): Contact %d deleted avatar.", uin);
getAvatarFilename(pai->hContact, pai->filename, sizeof(pai->filename));
_tremove(pai->filename);
db_unset(pai->hContact, m_szModuleName, GG_KEY_AVATARHASH);
@@ -229,7 +233,7 @@ INT_PTR GGPROTO::getavatarinfo(WPARAM wParam, LPARAM lParam) db_unset(pai->hContact, m_szModuleName, GG_KEY_AVATARTYPE);
}
else if (AvatarHash != NULL && AvatarSavedHash == NULL) {
- netlog("gg_getavatarinfo(): Contact %d set avatar.", uin);
+ netlog("getavatarinfo(): Contact %d set avatar.", uin);
db_set_s(pai->hContact, m_szModuleName, GG_KEY_AVATARHASH, AvatarHash);
getAvatar(pai->hContact, AvatarURL);
result = GAIR_WAITFOR;
@@ -251,7 +255,7 @@ INT_PTR GGPROTO::getmyavatar(WPARAM wParam, LPARAM lParam) TCHAR *szFilename = (TCHAR*)wParam;
int len = (int)lParam;
- netlog("gg_getmyavatar(): Requesting user avatar.");
+ netlog("getmyavatar(): Requesting user avatar.");
if (szFilename == NULL || len <= 0)
return -1;
@@ -283,7 +287,7 @@ INT_PTR GGPROTO::setmyavatar(WPARAM wParam, LPARAM lParam) TCHAR szMyFilename[MAX_PATH];
getAvatarFilename(NULL, szMyFilename, SIZEOF(szMyFilename));
if ( _tcscmp(szFilename, szMyFilename) && !CopyFile(szFilename, szMyFilename, FALSE)) {
- netlog("gg_setmyavatar(): Failed to set user avatar. File %s could not be created/overwritten.", szMyFilename);
+ netlog("setmyavatar(): Failed to set user avatar. File %s could not be created/overwritten.", szMyFilename);
return -1;
}
@@ -299,11 +303,11 @@ INT_PTR GGPROTO::getmyawaymsg(WPARAM wParam, LPARAM lParam) INT_PTR res = 0;
char *szMsg;
- EnterCriticalSection(&modemsg_mutex);
+ gg_EnterCriticalSection(&modemsg_mutex, "refreshstatus", 72, "modemsg_mutex", 1);
szMsg = getstatusmsg(wParam ? gg_normalizestatus(wParam) : m_iStatus);
if (isonline() && szMsg)
res = (lParam & SGMA_UNICODE) ? (INT_PTR)mir_a2u(szMsg) : (INT_PTR)mir_strdup(szMsg);
- LeaveCriticalSection(&modemsg_mutex);
+ gg_LeaveCriticalSection(&modemsg_mutex, "refreshstatus", 72, 1, "modemsg_mutex", 1);
return res;
}
diff --git a/protocols/Gadu-Gadu/src/sessions.cpp b/protocols/Gadu-Gadu/src/sessions.cpp index 6f047cd783..2888b5136f 100644 --- a/protocols/Gadu-Gadu/src/sessions.cpp +++ b/protocols/Gadu-Gadu/src/sessions.cpp @@ -91,7 +91,7 @@ static void gg_listsessions(GGPROTO* gg, HWND hwndDlg) if (!hList) return;
- EnterCriticalSection(&gg->sessions_mutex);
+ gg->gg_EnterCriticalSection(&gg->sessions_mutex, "gg_listsessions", 73, "sessions_mutex", 1);
for (l = gg->sessions; l; l = l->next)
{
struct gg_multilogon_session* sess = (struct gg_multilogon_session*)l->data;
@@ -103,7 +103,7 @@ static void gg_listsessions(GGPROTO* gg, HWND hwndDlg) strftime(loginTime, sizeof(loginTime), "%d-%m-%Y %H:%M:%S", localtime(&sess->logon_time));
gg_insertlistitem(hList, &sess->id, sess->name, ip, loginTime);
}
- LeaveCriticalSection(&gg->sessions_mutex);
+ gg->gg_LeaveCriticalSection(&gg->sessions_mutex, "gg_listsessions", 73, 1, "sessions_mutex", 1);
EnableWindow(GetDlgItem(hwndDlg, IDC_SIGNOUTALL), ListView_GetItemCount(hList) > 0);
}
@@ -214,9 +214,9 @@ static INT_PTR CALLBACK gg_sessions_viewdlg(HWND hwndDlg, UINT message, WPARAM w {
lvi.iItem = i;
ListView_GetItem(hList, &lvi);
- EnterCriticalSection(&gg->sess_mutex);
+ gg->gg_EnterCriticalSection(&gg->sess_mutex, "gg_sessions_viewdlg", 74, "sess_mutex", 1);
gg_multilogon_disconnect(gg->sess, *((gg_multilogon_id_t*)lvi.lParam));
- LeaveCriticalSection(&gg->sess_mutex);
+ gg->gg_LeaveCriticalSection(&gg->sess_mutex, "gg_sessions_viewdlg", 74, 1, "sess_mutex", 1);
}
break;
}
@@ -289,9 +289,9 @@ static INT_PTR CALLBACK gg_sessions_viewdlg(HWND hwndDlg, UINT message, WPARAM w lvi.mask = LVIF_PARAM;
lvi.iItem = nm->iItem;
ListView_GetItem(nm->hdr.hwndFrom, &lvi);
- EnterCriticalSection(&gg->sess_mutex);
+ gg->gg_EnterCriticalSection(&gg->sess_mutex, "gg_sessions_viewdlg", 75, "sess_mutex", 1);
gg_multilogon_disconnect(gg->sess, *((gg_multilogon_id_t*)lvi.lParam));
- LeaveCriticalSection(&gg->sess_mutex);
+ gg->gg_LeaveCriticalSection(&gg->sess_mutex, "gg_sessions_viewdlg", 75, 1, "sess_mutex", 1);
}
break;
}
diff --git a/protocols/Gadu-Gadu/src/userutils.cpp b/protocols/Gadu-Gadu/src/userutils.cpp index 599a8691b6..ff5e21088b 100644 --- a/protocols/Gadu-Gadu/src/userutils.cpp +++ b/protocols/Gadu-Gadu/src/userutils.cpp @@ -178,7 +178,7 @@ void *gg_dochemail(GGPROTO *gg, uin_t uin, char *password, char *email, char *ne GGTOKEN token;
#ifdef DEBUGMODE
- gg->netlog("gg_doemail(): Starting.");
+ gg->netlog("gg_dochemail(): Starting.");
#endif
if (!uin || !email || !newEmail) return NULL;
@@ -191,18 +191,18 @@ void *gg_dochemail(GGPROTO *gg, uin_t uin, char *password, char *email, char *ne mir_sntprintf(error, SIZEOF(error), TranslateT("Your e-mail cannot be changed because of error:\n\t%s"),
(h && !s) ? http_error_string(h ? h->error : 0) : (s ? TranslateT("Bad old e-mail or password") : _tcserror(errno)));
MessageBox(NULL, error, gg->m_tszUserName, MB_OK | MB_ICONSTOP);
- gg->netlog("gg_dochpass(): Cannot change e-mail because of \"%s\".", strerror(errno));
+ gg->netlog("gg_dochemail(): Cannot change e-mail because of \"%s\".", strerror(errno));
}
else
{
gg_pubdir_free(h);
db_set_s(NULL, gg->m_szModuleName, GG_KEY_EMAIL, newEmail);
- gg->netlog("gg_doemail(): E-mail change succesful.");
+ gg->netlog("gg_dochemail(): E-mail change succesful.");
MessageBox(NULL, TranslateT("Your e-mail has been changed."), gg->m_tszUserName, MB_OK | MB_ICONINFORMATION);
}
#ifdef DEBUGMODE
- gg->netlog("gg_doemail(): End.");
+ gg->netlog("gg_dochemail(): End.");
#endif
return NULL;
|