From fcdc48f1a7ccc5a21fbd3dc5a4ac0caf6858b58f Mon Sep 17 00:00:00 2001 From: Nathan Whitehorn Date: Sat, 30 Oct 2004 17:19:06 +0000 Subject: [PATCH] Fixed a nasty bug I introduced when I fixed IMAP that made it impossible to send mail. Apparently I don't send that much.... it's been in there for a good week or so. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9663 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/add-ons/mail_daemon/ChainRunner.h | 2 +- .../inbound_filters/r5_filter/Jamfile | 2 +- .../inbound_protocols/imap/imap_client.cpp | 18 +++++++-------- .../inbound_protocols/pop3/pop3.cpp | 6 ++--- src/kits/mail/ChainRunner.cpp | 20 +++++++++------- src/kits/mail/Jamfile | 23 +++++++++++++++++++ src/kits/mail/MailMessage.cpp | 15 +++++++----- 7 files changed, 58 insertions(+), 28 deletions(-) diff --git a/headers/os/add-ons/mail_daemon/ChainRunner.h b/headers/os/add-ons/mail_daemon/ChainRunner.h index 41c1f83bad..9c8eb72005 100644 --- a/headers/os/add-ons/mail_daemon/ChainRunner.h +++ b/headers/os/add-ons/mail_daemon/ChainRunner.h @@ -49,7 +49,7 @@ class BMailChainRunner : public BLooper { // a filter returns MD_ALL_PASSES_DONE and before everything // is unloaded and sent home. - void Stop(); + void Stop(bool immediately = false); void ReportProgress(int bytes, int messages, const char *message = NULL); void ResetProgress(const char *message = NULL); diff --git a/src/add-ons/mail_daemon/inbound_filters/r5_filter/Jamfile b/src/add-ons/mail_daemon/inbound_filters/r5_filter/Jamfile index f8903a0d3e..1b19422026 100644 --- a/src/add-ons/mail_daemon/inbound_filters/r5_filter/Jamfile +++ b/src/add-ons/mail_daemon/inbound_filters/r5_filter/Jamfile @@ -11,4 +11,4 @@ LinkSharedOSLibs R5\ Daemon\ Filter : Package haiku-maildaemon-cvs : R5\ Daemon\ Filter : - boot home config add-ons mail_daemon inbound_filters ; + boot beos system add-ons mail_daemon inbound_filters ; diff --git a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_client.cpp b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_client.cpp index fd1554a6b2..ce09c0a49c 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/imap/imap_client.cpp +++ b/src/add-ons/mail_daemon/inbound_protocols/imap/imap_client.cpp @@ -163,7 +163,7 @@ IMAP4Client::IMAP4Client(BMessage *settings, BMailChainRunner *run) : BRemoteMai closesocket(net); #endif net = -1; - runner->Stop(); + runner->Stop(true); return; } @@ -200,7 +200,7 @@ IMAP4Client::IMAP4Client(BMessage *settings, BMailChainRunner *run) : BRemoteMai error << ":" << port; error << '.'; runner->ShowError(error.String()); - runner->Stop(); + runner->Stop(true); return; } } else { @@ -211,7 +211,7 @@ IMAP4Client::IMAP4Client(BMessage *settings, BMailChainRunner *run) : BRemoteMai error << ". (" << strerror(errno) << ')'; runner->ShowError(error.String()); net = -1; - runner->Stop(); + runner->Stop(true); return; } @@ -242,7 +242,7 @@ IMAP4Client::IMAP4Client(BMessage *settings, BMailChainRunner *run) : BRemoteMai #else closesocket(net); #endif - runner->Stop(); + runner->Stop(true); return; } } @@ -272,7 +272,7 @@ IMAP4Client::IMAP4Client(BMessage *settings, BMailChainRunner *run) : BRemoteMai response << ')'; runner->ShowError(response.String()); err = B_ERROR; - runner->Stop(); + runner->Stop(true); return; } @@ -986,7 +986,7 @@ IMAP4Client::ReceiveLine(BString &out) closesocket(net); #endif net = -1; - runner->Stop(); + runner->Stop(true); runner->ShowError(error.String()); return -1; } @@ -996,7 +996,7 @@ IMAP4Client::ReceiveLine(BString &out) } }else{ // Log an error somewhere instead - runner->Stop(); + runner->Stop(true); runner->ShowError("IMAP Timeout."); return B_TIMED_OUT; } @@ -1070,7 +1070,7 @@ int IMAP4Client::GetResponse(BString &tag, NestedString *parsed_response, bool r closesocket(net); #endif net = -1; - runner->Stop(); + runner->Stop(true); runner->ShowError(error.String()); return -1; } @@ -1173,7 +1173,7 @@ int IMAP4Client::GetResponse(BString &tag, NestedString *parsed_response, bool r } }else{ // Log an error somewhere instead - runner->Stop(); + runner->Stop(true); runner->ShowError("IMAP Timeout."); return B_TIMED_OUT; } diff --git a/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp b/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp index e6f033cfe6..f326241831 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp +++ b/src/add-ons/mail_daemon/inbound_protocols/pop3/pop3.cpp @@ -160,7 +160,7 @@ POP3Protocol::Open(const char *server, int port, int) #else closesocket(net); #endif - runner->Stop(); + runner->Stop(true); return B_ERROR; } @@ -391,7 +391,7 @@ status_t POP3Protocol::RetrieveInternal(const char *command, int32 message, if (result == 0) { // No data available, even after waiting a minute. fLog = "POP3 timeout - no data received after a long wait."; - runner->Stop(); + runner->Stop(true); return B_ERROR; } if (amountToReceive > bufSize - 1 - amountInBuffer) @@ -597,7 +597,7 @@ POP3Protocol::ReceiveLine(BString &line) } } else { fLog = "POP3 socket timeout."; - runner->Stop(); + runner->Stop(true); } return len; } diff --git a/src/kits/mail/ChainRunner.cpp b/src/kits/mail/ChainRunner.cpp index d48b637bb0..3a0da08bcd 100644 --- a/src/kits/mail/ChainRunner.cpp +++ b/src/kits/mail/ChainRunner.cpp @@ -538,15 +538,19 @@ BMailChainRunner::get_messages(BStringList *list) void -BMailChainRunner::Stop() +BMailChainRunner::Stop(bool kill) { - BMessageQueue *looper_queue = MessageQueue(); - looper_queue->Lock(); - BMessage *msg; - while (msg = looper_queue->NextMessage()) delete msg; //-- Ensure STOP makes the front of the queue - - PostMessage(B_QUIT_REQUESTED); - looper_queue->Unlock(); + if (kill) { + BMessageQueue *looper_queue = MessageQueue(); + looper_queue->Lock(); + BMessage *msg; + while (msg = looper_queue->NextMessage()) delete msg; //-- Ensure STOP makes the front of the queue + + PostMessage(B_QUIT_REQUESTED); + looper_queue->Unlock(); + } else { + PostMessage(B_QUIT_REQUESTED); + } } diff --git a/src/kits/mail/Jamfile b/src/kits/mail/Jamfile index 0287a0d695..4daa3d9d23 100644 --- a/src/kits/mail/Jamfile +++ b/src/kits/mail/Jamfile @@ -8,6 +8,12 @@ if $(CHECK_MALLOC) { SubDirC++Flags -D_NO_INLINE_ASM -fcheck-memory-usage ; } +if $(TARGET_PLATFORM) = r5 { + SubDirC++Flags -DBUILDING_R5_LIBNET ; +} else { + SubDirC++Flags -DBONE ; +} + SubDirC++Flags -D_BUILDING_mail=1 -DUSE_NASTY_SYNC_THREAD_HACK=1 ; SharedLibrary mail : @@ -45,6 +51,23 @@ LinkSharedOSLibs libmail.so : stdc++.r4 ; +if $(TARGET_PLATFORM) = r5 { + LinkSharedOSLibs libmail.so : + be + textencoding + tracker + stdc++.r4 + ; +} else { + LinkSharedOSLibs libmail.so : + be + textencoding + tracker + stdc++.r4 + socket + ; +} + MakeLocate libmail.so : $(OBOS_STLIB_DIR) ; RelSymLink libmail.so : libmail.so ; diff --git a/src/kits/mail/MailMessage.cpp b/src/kits/mail/MailMessage.cpp index 08863f3e68..27d9918d72 100644 --- a/src/kits/mail/MailMessage.cpp +++ b/src/kits/mail/MailMessage.cpp @@ -25,12 +25,15 @@ #include #ifdef BONE - #ifdef _KERNEL_MODE - #undef _KERNEL_MODE - #include - #define _KERNEL_MODE 1 - #endif - #include + #include + #define BONE_SERIAL_PPP_GET_STATUS 0xbe230501 + #define BSPPP_CONNECTED 4 + typedef struct { + char if_name[32]; + int connection_status; + status_t last_error; + int connect_speed; + } bsppp_status_t; #include #endif