When I came across the bug where nwam_events_init() causes a core if NWAM
isn't running:

  http://defect.opensolaris.org/bz/show_bug.cgi?id=9352

this brought up another question about how the UI should be handling the
connection to nwamd.

Right now we do something like:

  if ( nwam_events_init() == NWAM_SUCCESS )
    nwam_init = TRUE;
  else
    nwam_init = FALSE
  endif

  start event handling thread anyway.


And the event thread is something like

  while ( not_done )
    if ( nwam_event_wait() != SUCCESS )
      report error
      nwam_events_fini() // cleanup
      // reconnect?
      if ( nwam_events_init() == NWAM_SUCCESS)
        continue
      else
        sleep for a sec
      endif
    else
      handle event
    endif
  endwhile

The main aim of all of this is to :

1) connect to nwam
2) if not there, then wait
3) if connected to nwam and it goes away,
   try reconnect, or wait and try again if fails.

The main use of this is for the panel presence element, which is run on
user-login. It's not acceptable to simply say "oh NWAM isn't running, so exit"
since if nwam is later started the UI would never show up without a logout/in
of the desktop.

In the 0.5 version of nwam_event_wait(), if it found that NWAM wasn't running,
would block until it started.

So I'm wondering if we're doing the right thing now for Phase 1, and if not,
can you make suggestions as to how best to handle this use-case.

I've taken a look at the "nwamadm interact -v" implementation, and it seems to
only work if the nwam service is online, otherwise it exits. If nwam is
shutdown, it calls nwam_event_wait() which seems to block, but this all
assumes that the nwam_events_init() succeeded to begin with, which it might
not if nwam is never started.

So looking at that it would seem we should be checking for the nwam service
being on-line before using the nwam API at all, is that correct? If so, it
would be good if the NWAM service name was defined in libnwam.h...

Thanks,

Darren.



Reply via email to