Prevent deadlock if fs_stateSave panics
authorAndrew Deason <adeason@sinenomine.net>
Mon, 22 Feb 2010 17:56:07 +0000 (11:56 -0600)
committerDerrick Brashear <shadow@dementia.org>
Mon, 22 Feb 2010 18:35:52 +0000 (10:35 -0800)
commit1e744d5e56106093924869924fffde3a9093d140
tree3b2f8b8015ee5f0b6367007b2c46db72477e1c46
parentb8c3c6add90ea3face9a16ff04a1024be3d8f32d
Prevent deadlock if fs_stateSave panics

fs_stateSave can call ShutDownAndCore(PANIC) if it detects host list
corruption. Right now this will deadlock the shutdown thread, since
we're still holding a read lock on the FS state when we do so, and
ShutDownAndCore will attempt to acquire a write lock. Do two things to
make this a bit better:

 -- Unlock the FS state before calling fs_stateSave, sine we're no
 longer looking at the FS state (the 'state' in fs_stateSave refers to
 the host list and callback lists, not the state locked by
 FS_STATE_*LOCK)

 -- If ShutDownAndCore detects that it was called inside of
 ShutDownAndCore, skip shutting down the volume and host packages, since
 they have already been shut down

Change-Id: I24a994ff85a6d866a5800b777c0cf5ab2ba466e4
Reviewed-on: http://gerrit.openafs.org/1362
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
src/viced/viced.c