* Sebastian Hammer, Adam Dickmeiss
*
* $Log: zserver.c,v $
- * Revision 1.31 1995-12-08 16:22:56 adam
+ * Revision 1.33 1996-01-17 14:57:56 adam
+ * Prototype changed for reader functions in extract/retrieve. File
+ * is identified by 'void *' instead of 'int.
+ *
+ * Revision 1.32 1995/12/11 09:12:58 adam
+ * The rec_get function returns NULL if record doesn't exist - will
+ * happen in the server if the result set records have been deleted since
+ * the creation of the set (i.e. the search).
+ * The server saves a result temporarily if it is 'volatile', i.e. the
+ * set is register dependent.
+ *
+ * Revision 1.31 1995/12/08 16:22:56 adam
* Work on update while servers are running. Three lock files introduced.
* The servers reload their registers when necessary, but they don't
* reestablish result sets yet.
return 0;
}
-static int register_unlock (ZServerInfo *zi)
+static void register_unlock (ZServerInfo *zi)
{
+ static int waitSec = -1;
+
+ if (waitSec == -1)
+ {
+ char *s = res_get (common_resource, "debugRequestWait");
+ if (s)
+ waitSec = atoi (s);
+ else
+ waitSec = 0;
+ }
+ if (waitSec > 0)
+ sleep (waitSec);
if (zi->registerState != -1)
zebraServerUnlock (zi->registerState);
}
return &r;
}
-static int record_ext_read (int fd, char *buf, size_t count)
+static int record_ext_read (void *fh, char *buf, size_t count)
{
- return read (fd, buf, count);
+ return read (*((int*) fh), buf, count);
}
static int record_int_pos;
static char *record_int_buf;
static int record_int_len;
-static int record_int_read (int fd, char *buf, size_t count)
+static int record_int_read (void *fh, char *buf, size_t count)
{
int l = record_int_len - record_int_pos;
if (l <= 0)
Record rec;
char *fname, *file_type;
RecType rt;
+ int fd = -1;
struct recRetrieveCtrl retrieveCtrl;
char subType[128];
rec = rec_get (zi->records, sysno);
+ if (!rec)
+ {
+ char *msg = "Record is deleted\n";
+ *output_format = VAL_SUTRS;
+ *rec_bufp = msg;
+ *rec_lenp = strlen (msg);
+ return 0;
+ }
file_type = rec->info[recInfo_fileType];
fname = rec->info[recInfo_filename];
}
else
{
- if ((retrieveCtrl.fd = open (fname, O_RDONLY)) == -1)
+ if ((fd = open (fname, O_RDONLY)) == -1)
{
- char *msg = "Record doesn't exist";
+ char *msg = "Record doesn't exist\n";
logf (LOG_WARN|LOG_ERRNO, "Retrieve: Open record file %s", fname);
*output_format = VAL_SUTRS;
*rec_bufp = msg;
rec_rm (&rec);
return 0; /* or 14: System error in presenting records */
}
+ retrieveCtrl.fh = &fd;
retrieveCtrl.readf = record_ext_read;
}
retrieveCtrl.subType = subType;
*output_format = retrieveCtrl.output_format;
*rec_bufp = retrieveCtrl.rec_buf;
*rec_lenp = retrieveCtrl.rec_len;
- close (retrieveCtrl.fd);
+ if (fd != -1)
+ close (fd);
rec_rm (&rec);
return retrieveCtrl.diagnostic;