Re: Testing network availability



Hi all!

Am 23.05.17 00:58 schrieb(en) Peter Bloomfield:
The git "master" branch has some new code, for more careful checking of when a POP3 host can be reached. This 
should avert some warnings about failure to connect to POP3 hosts. Please report any issues with it!

As a follow-up to this patch, I implemented the same feature for outgoing smtp connections, using Peter's new 
functions.

Basically, when a specific smtp server is not reachable, a warning is shown, and the messages are left in the outbox.  
Unlike after an error, the messages are /not/ tagged.  Therefore, simply choosing "Send queued mail" will 
send the messages if possible, or just leave them (untagged) in the outbox if the server is still unreachable.  I did 
not implement some kind of timer to send queued messages automatically.

In libbalsa/send.c I noticed that the sending_threads global variable is used in an unsafe way as it is 
accessed from multiple threads without always using a mutex.  The simple fix is to use atomic operations.  
I'm not sure if the mutex send_messages_lock is actually needed, but it doesn't hurt IMO. BTW, I also ref the 
outbox and smtp_server objects before calling libbalsa_server_test_can_reach() which is somewhat 
extra-paranoid, but shouldn't be an issue, too.

In Peter's implementation, the function libbalsa_server_test_can_reach_full() will always report an unreachable server 
if the host contains a port number ("host:port") which is typical for SMTP.  I also fixed this issue.

Finally, I removed the debug flag from the sending stuff, as debugging in libnetclient is controlled by the 
G_MESSAGES_DEBUG environment variable.

Opinions?

Cheers,
Albrecht.

---
Patch details:
- libbalsa/send.c: use atomic operations for the sending state; check if the smtp server is reachable before sending; simplify 
some API's; replace the term "MTA" in user dialogues by "SMTP server" which is more common
- libbalsa/send.h: export simplified API
- libbalsa/server.c: ignore port in server host string
- src/balsa-message.c, src/balsa-mime-widget-message.c, balsa-mime-widget-vcalendar.c, src/main-window.c, 
src/sendmsg-window.c: use simplified API

Attachment: smtp-check-network.diff
Description: Text Data

Attachment: pgpjJdnAkfA0O.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]