Closed Bug 104020 Opened 24 years ago Closed 23 years ago

Need to send out notification when SetOffline has completed

Categories

(Core :: Networking, defect, P2)

defect

Tracking

()

VERIFIED FIXED
mozilla1.0

People

(Reporter: ccarlen, Assigned: Bienvenu)

References

Details

Attachments

(4 files, 1 obsolete file)

This came from bug 101329. When shutting down the current profile, we need to know when all network activity has indeed been stopped. Currently, necko notifies observers with the "network:offline-status-changed" topic as it begins(?) to go offline. What's needed is another notification, say "network:offline-complete" when necko knows that all transactions have really stopped. If we need two stages of notification, maybe the topic for Observe() should be "network:offline-status" in both cases and either "beginning" or "completed" as the someData param.
Blocks: 104021
-> 0.9.6
Status: NEW → ASSIGNED
Priority: -- → P2
Target Milestone: --- → mozilla0.9.6
Blocks: 101329
Attached patch v1.0 patchSplinter Review
the patch for this was simpler then i thought. shutting down the DNS and socket transport services happens synchronously (and without blocking for any real length of time). this means that we can solve this bug by simply delaying offline notification until after the services are shutdown.
cc'ing gagan and dougt for reviews.
That makes things simpler. If SetOffline() is truly synchronous, the profile mgr does not have to register as a listener to be notified when the shutdown happens - it can just call Offline(PR_TRUE) as the first step of a profile switch. Better than that, IOService could register as a profile change observer and do this itself. The advantage is that then we don't need a do_GetService() call in the profile mgr which may create an instance of IOService before really nescesary. If this sounds like the way to go, I'll make a patch for this and bug 104021.
conrad: nsSocketTransportService::Shutdown calls Join on the worker thread, so it cannot return until the worker thread terminates, and without a worker thread there can't be any more "async" socket activity. so, i'm fairly certain that this is the right thing. i'll try out your patch tomorrow.
Comment on attachment 56661 [details] [diff] [review] v1.0 patch We may have to add a new notification if clients want to know about going offline prior to sts/dns shutdown.
Attachment #56661 - Flags: superreview+
dougt: but the observer notification would be asynchronous. thus, by the time the observers received notification, we'd likely already be offline. so, i don't see the point of sending out a "now we're going offline" notification.
Comment on attachment 56682 [details] [diff] [review] previous patch + goes offline automatically >Index: nsIOService.cpp > nsIOService::nsIOService() >- : mOffline(PR_FALSE) >+ : mOffline(PR_FALSE), >+ mProfileChangeWentOffline(PR_FALSE) how about mOfflineForProfileChange instead? >- >+ >+ // Register for profile change notifications >+ nsCOMPtr<nsIObserverService> observerService = >+ do_GetService("@mozilla.org/observer-service;1", &rv); why capture rv if it's not going to be used? otherwise, sr=darin
Attachment #56682 - Flags: superreview+
Comment on attachment 56682 [details] [diff] [review] previous patch + goes offline automatically make to two bools: PRBool mOffline; PRBool mProfileChangeWentOffline; PRBoolPacked. then r=me
Attachment #56682 - Flags: review+
-> ccarlen for checkin
Assignee: darin → ccarlen
Status: ASSIGNED → NEW
Thanks. I'll make the suggested changes. While we're at it, can you guys review the companion bug 104021. This won't have any effect without that one.
Checked in - with reviewers suggestions.
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
This breaks mail/news - I aleady fixed this once - we need to get notified before we go offline so we can a bit of processing to clean up our connections. Now, I crash going offline if I have more than one imap folder open.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
The crash is because the sockettransport is holding onto a deleted lock. The crash is easy to reproduce - just open two imap folders and then go offline. I believe this change also is responsible for http://bugzilla.mozilla.org/show_bug.cgi?id=119592 So I think we need some more general solution to this problem.
Here's the crash stack trace: PR_Lock(PRLock * 0xfeeefeee) line 235 + 3 bytes nsAutoLock::nsAutoLock(PRLock * 0xfeeefeee) line 150 + 13 bytes nsSocketBS::GetTransport(nsSocketTransport * * 0x0012c0d4) line 2142 nsSocketBS::ReleaseSocket(PRFileDesc * 0x048ad590) line 2125 nsSocketBOS::Write(nsSocketBOS * const 0x04674b04, const char * 0x048af490, unsigned int 0x00000009, unsigned int * 0x0012c158) line 2344 nsImapProtocol::TellThreadToDie(nsImapProtocol * const 0x030181b8, int 0x00000001) line 883 + 50 bytes nsImapIncomingServer::CloseCachedConnections(nsImapIncomingServer * const 0x04056c38) line 986 nsMsgAccountManager::closeCachedConnections(nsHashKey * 0x04057570, void * 0x04056c38, void * 0x00000000) line 1103 _hashEnumerate(PLHashEntry * 0x040575c8, int 0x00000005, void * 0x0012c214) line 198 + 26 bytes PL_HashTableEnumerateEntries(PLHashTable * 0x02f354e8, int (PLHashEntry *, int, void *)* 0x10029620 _hashEnumerate(PLHashEntry *, int, void *), void * 0x0012c214) line 429 + 15 bytes nsHashtable::Enumerate(int (nsHashKey *, void *, void *)* 0x037b8c00 nsMsgAccountManager::closeCachedConnections(nsHashKey *, void *, void *), void * 0x00000000) line 361 + 21 bytes nsMsgAccountManager::CloseCachedConnections(nsMsgAccountManager * const 0x02f35488) line 1465 nsMsgAccountManager::Observe(nsMsgAccountManager * const 0x02f3548c, nsISupports * 0x01849a58, const char * 0x01bc2e2c, const unsigned short * 0x01bc2e1c) line 254 nsObserverService::NotifyObservers(nsObserverService * const 0x0144b190, nsISupports * 0x01849a58, const char * 0x01bc2e2c, const unsigned short * 0x01bc2e1c) line 213 nsIOService::SetOffline(nsIOService * const 0x01849a58, int 0x00000001) line 844 + 63 bytes nsMsgOfflineManager::SetOnlineState(int 0x00000000) line 367 + 33 bytes nsMsgOfflineManager::SynchronizeForOffline(nsMsgOfflineManager * const 0x04884f18, int 0x00000000, int 0x00000000, int 0x00000000, int 0x00000001, nsIMsgWindow * 0x0404b788) line 354 + 10 bytes XPTC_InvokeByIndex(nsISupports * 0x04884f18, unsigned int 0x00000008, unsigned int 0x00000005, nsXPTCVariant * 0x0012c63c) line 106
So, the problem is the one brought up in comment 9 and thought not to be a problem in comment 10. Since it is a problem, would mailnews be happy if a notification was sent out before going offline in addition to after?
Conrad, yes, that was the way it worked, and we were fine with that :-)
We need both the "before" and the "after" notification. mailnews can observe the "before." PSM will observe the "after."
Status: REOPENED → ASSIGNED
Target Milestone: mozilla0.9.6 → mozilla1.0
Attached patch proposed fix (obsolete) — Splinter Review
I added a new notification about-to-go-offline. I'll attach a patch to the mailnews code that listens for this notification.
change mailnews code to listen for new notification.
can I get an r and sr from Conrad and Darin, thx!
Doh! I was just about to post a similar patch! (CVS chugging away) Thanks for making a patch but, if you were going to do that, you should have taken the bug and I wouldn't have wasted time making the same patch.
sorry, it just took a minute and I did it on an impulse :-)
Comment on attachment 73054 [details] [diff] [review] mailnews part of proposed fix sr=sspitzer
Attachment #73054 - Flags: superreview+
Comment on attachment 73053 [details] [diff] [review] proposed fix make that sr=sspitzer, I'll leave the r= to ccarlen.
Attachment #73053 - Flags: review+ → superreview+
Comment on attachment 73053 [details] [diff] [review] proposed fix >+ // this allows users to attempt a little cleanup before dns and socket transport are shut down. >+ (void)observerService->NotifyObservers(NS_STATIC_CAST(nsIIOService *, this), >+ "network:offline-about-to-go-offline", >+ NS_LITERAL_STRING("offline").get()); One little thing: now there's 2 occurances of NS_LITERAL_STRING("offline") in this block. Use 1 NS_NAMED_LITERAL_STRING(offlineString, "offline") That macro actually generates code on some platforms. With that, r=ccarlen > // be sure to try and shutdown both (even if the first fails) > if (mDNSService) > rv1 = mDNSService->Shutdown(); // shutdown dns service first, because it has callbacks for socket transport
Cool, I didn't know about that - yet another thing I can torture people with in sr's! :-)
Attachment #73053 - Attachment is obsolete: true
Attachment #73054 - Attachment description: proposed fix → mailnews part of proposed fix
Comment on attachment 73069 [details] [diff] [review] patch to nsIOService using NS_NAMED_LITERAL_STRING r=ccarlen
Attachment #73069 - Flags: review+
Comment on attachment 73054 [details] [diff] [review] mailnews part of proposed fix r=ccarlen
Attachment #73054 - Flags: review+
Comment on attachment 73069 [details] [diff] [review] patch to nsIOService using NS_NAMED_LITERAL_STRING sr=sspitzer
Attachment #73069 - Flags: superreview+
Comment on attachment 73054 [details] [diff] [review] mailnews part of proposed fix a=asa (on behalf of drivers) for checkin to the 1.0 trunk
Attachment #73054 - Flags: approval+
Comment on attachment 73069 [details] [diff] [review] patch to nsIOService using NS_NAMED_LITERAL_STRING a=asa (on behalf of drivers) for checkin to the 1.0 trunk
Attachment #73069 - Flags: approval+
-> bienvenu
Assignee: ccarlen → bienvenu
Status: ASSIGNED → NEW
fix checked in - I'm changing qa contact to stephend since he's seen the crash described here in comment 18 http://bugzilla.mozilla.org/show_bug.cgi?id=104020#c18 and can tell if it's fixed.
Status: NEW → RESOLVED
Closed: 24 years ago23 years ago
QA Contact: benc → stephend
Resolution: --- → FIXED
I tried the testcase in http://bugzilla.mozilla.org/show_bug.cgi?id=104020#c17 without any problem. Builds: Mac OS X 10.1.3 - 2002-03-14-08 RedHat 7.2 - 2002-03-14-08 Windows 2000 - 2002-03-14-03 Also, I queried talkback and got: http://climate/reports/searchstacksignature.cfm?stacksig=PR_Lock 2002021308 MozillaTrunk Linux 2.4.9-21 Verified FIXED (talkback's output isn't particularly useful for this bug, but I included it nonetheless).
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: