* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zserver.c,v $
- * Revision 1.29 1995-12-04 14:22:32 adam
+ * Revision 1.30 1995-12-07 17:38:48 adam
+ * Work locking mechanisms for concurrent updates/commit.
+ *
+ * Revision 1.29 1995/12/04 14:22:32 adam
* Extra arg to recType_byName.
* Started work on new regular expression parsed input to
* structured records.
ZServerInfo server_info;
+static int register_check (ZServerInfo *zi)
+{
+ int state = zebraServerLockGetState();
+
+ switch (state)
+ {
+ case 'c':
+ state = 1;
+ break;
+ default:
+ state = 0;
+ }
+ if (zi->registerState == state)
+ return 0;
+
+ zi->registerState = state;
+ if (server_info.records)
+ {
+ dict_close (server_info.wordDict);
+ is_close (server_info.wordIsam);
+ rec_close (&server_info.records);
+ }
+ /* enable commit if state is 1 */
+ server_info.records = rec_open (0);
+ if (!(server_info.wordDict = dict_open (FNAME_WORD_DICT, 40, 0)))
+ return -1;
+ if (!(server_info.wordIsam = is_open (FNAME_WORD_ISAM, key_compare, 0,
+ sizeof (struct it_key))))
+ return -1;
+ return 0;
+}
+
bend_initresult *bend_init (bend_initrequest *q)
{
static bend_initresult r;
exit (1);
}
}
+ zebraServerLock ();
data1_tabpath = res_get(common_resource, "profilePath");
server_info.sets = NULL;
-
+ server_info.registerState = -1; /* trigger open of registers! */
+#if 1
+ server_info.records = NULL;
+ server_info.wordDict = NULL;
+ server_info.wordIsam = NULL;
+#else
server_info.records = rec_open (0);
if (!(server_info.wordDict = dict_open (FNAME_WORD_DICT, 40, 0)))
{
r.errstring = "is_open fail: word isam";
return &r;
}
+#endif
server_info.odr = odr_createmem (ODR_ENCODE);
return &r;
}
r.errstring = 0;
r.hits = 0;
-
+ register_check (&server_info);
odr_reset (server_info.odr);
server_info.errCode = 0;
server_info.errString = NULL;
int positions[2];
ZServerSetSysno *records;
+ register_check (&server_info);
+
r.errstring = 0;
r.last_in_set = 0;
r.basename = "base";
bend_deleteresult *bend_delete (void *handle, bend_deleterequest *q, int *num)
{
+ register_check (&server_info);
return 0;
}
static bend_scanresult r;
int status;
+ register_check (&server_info);
odr_reset (server_info.odr);
server_info.errCode = 0;
server_info.errString = 0;
void bend_close (void *handle)
{
- dict_close (server_info.wordDict);
- is_close (server_info.wordIsam);
- rec_close (&server_info.records);
+ if (server_info.records)
+ {
+ dict_close (server_info.wordDict);
+ is_close (server_info.wordIsam);
+ rec_close (&server_info.records);
+ }
+ zebraServerUnlock ();
return;
}