Improve debug output for ISpoof

We now generate a DEBUG() message for all errors during ISpoof. Also, the
message from *status "ISpoof could not be written" now includes the expanded
ISpoofFile that we tried writing to.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2221 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2010-12-30 21:11:40 +00:00
parent afa16df2bc
commit 128af8e893

10
znc.cpp
View File

@@ -137,8 +137,8 @@ bool CZNC::ConnectUser(CUser *pUser) {
return false; return false;
if (!WriteISpoof(pUser)) { if (!WriteISpoof(pUser)) {
DEBUG("ISpoof could not be written"); DEBUG("ISpoof [" + m_sISpoofFile + "] could not be written");
pUser->PutStatus("ISpoof could not be written, retrying..."); pUser->PutStatus("ISpoof [" + m_sISpoofFile + "] could not be written, retrying...");
return true; return true;
} }
@@ -258,6 +258,7 @@ bool CZNC::WriteISpoof(CUser* pUser) {
if (!m_sISpoofFile.empty()) { if (!m_sISpoofFile.empty()) {
m_pISpoofLockFile = new CFile; m_pISpoofLockFile = new CFile;
if (!m_pISpoofLockFile->TryExLock(m_sISpoofFile, O_RDWR | O_CREAT)) { if (!m_pISpoofLockFile->TryExLock(m_sISpoofFile, O_RDWR | O_CREAT)) {
DEBUG("Couldn't open and lock ISpoofFile: " << strerror(errno));
delete m_pISpoofLockFile; delete m_pISpoofLockFile;
m_pISpoofLockFile = NULL; m_pISpoofLockFile = NULL;
return false; return false;
@@ -269,6 +270,7 @@ bool CZNC::WriteISpoof(CUser* pUser) {
m_sOrigISpoof = buf; m_sOrigISpoof = buf;
if (!m_pISpoofLockFile->Seek(0) || !m_pISpoofLockFile->Truncate()) { if (!m_pISpoofLockFile->Seek(0) || !m_pISpoofLockFile->Truncate()) {
DEBUG("Couldn't truncate the ISpoofFile: " << strerror(errno));
delete m_pISpoofLockFile; delete m_pISpoofLockFile;
m_pISpoofLockFile = NULL; m_pISpoofLockFile = NULL;
return false; return false;
@@ -281,6 +283,7 @@ bool CZNC::WriteISpoof(CUser* pUser) {
if (sData == m_sISpoofFormat) { if (sData == m_sISpoofFormat) {
sData.Replace("%", pUser->GetIdent()); sData.Replace("%", pUser->GetIdent());
} }
DEBUG("Writing [" + sData + "] to ISpoofFile [" + m_sISpoofFile + "]");
m_pISpoofLockFile->Write(sData + "\n"); m_pISpoofLockFile->Write(sData + "\n");
} }
return true; return true;
@@ -292,7 +295,10 @@ void CZNC::ReleaseISpoof() {
if (!m_sISpoofFile.empty()) { if (!m_sISpoofFile.empty()) {
if (m_pISpoofLockFile->Seek(0) && m_pISpoofLockFile->Truncate()) { if (m_pISpoofLockFile->Seek(0) && m_pISpoofLockFile->Truncate()) {
DEBUG("Writing [" + m_sOrigISpoof + "] to ISpoofFile [" + m_sISpoofFile + "]");
m_pISpoofLockFile->Write(m_sOrigISpoof); m_pISpoofLockFile->Write(m_sOrigISpoof);
} else {
DEBUG("Error while restoring ISpoof: " << strerror(errno));
} }
m_sOrigISpoof = ""; m_sOrigISpoof = "";