-static int register_lock (ZServerInfo *zi)
-{
- time_t lastChange;
- int state = zebra_server_lock_get_state(zi, &lastChange);
-
- switch (state)
- {
- case 'c':
- state = 1;
- break;
- default:
- state = 0;
- }
- zebra_server_lock (zi, state);
-#if USE_TIMES
- times (&zi->tms1);
-#endif
- if (zi->registerState == state)
- {
- if (zi->registerChange >= lastChange)
- return 0;
- logf (LOG_LOG, "Register completely updated since last access");
- }
- else if (zi->registerState == -1)
- logf (LOG_LOG, "Reading register using state %d pid=%ld", state,
- (long) getpid());
- else
- logf (LOG_LOG, "Register has changed state from %d to %d",
- zi->registerState, state);
- zi->registerChange = lastChange;
- if (zi->records)
- {
- zebTargetInfo_close (zi->zti, 0);
- dict_close (zi->dict);
- if (zi->isam)
- is_close (zi->isam);
- if (zi->isamc)
- isc_close (zi->isamc);
- rec_close (&zi->records);
- }
- bf_cache (zi->bfs, state ? res_get (zi->res, "shadow") : NULL);
- zi->registerState = state;
- zi->records = rec_open (zi->bfs, 0);
- if (!(zi->dict = dict_open (zi->bfs, FNAME_DICT, 40, 0)))
- return -1;
- zi->isam = NULL;
- zi->isamc = NULL;
- if (res_get_match (zi->res, "isam", "c", NULL))
- {
- if (!(zi->isamc = isc_open (zi->bfs, FNAME_ISAMC,
- 0, key_isamc_m(zi->res))))
- return -1;
-
- }
- else
- {
- if (!(zi->isam = is_open (zi->bfs, FNAME_ISAM, key_compare, 0,
- sizeof (struct it_key), zi->res)))
- return -1;
- }
- zi->zti = zebTargetInfo_open (zi->records, 0);
- init_charmap (zi->res);
- return 0;
-}
-
-static void register_unlock (ZServerInfo *zi)
-{
- static int waitSec = -1;
-
-#if USE_TIMES
- times (&zi->tms2);
- logf (LOG_LOG, "user/system: %ld/%ld",
- (long) (zi->tms2.tms_utime - zi->tms1.tms_utime),
- (long) (zi->tms2.tms_stime - zi->tms1.tms_stime));
-#endif
- if (waitSec == -1)
- {
- char *s = res_get (zi->res, "debugRequestWait");
- if (s)
- waitSec = atoi (s);
- else
- waitSec = 0;
- }
-#ifdef WINDOWS
-#else
- if (waitSec > 0)
- sleep (waitSec);
-#endif
- if (zi->registerState != -1)
- zebra_server_unlock (zi, zi->registerState);
-}