if (tdb_error(pdb->tdb) != TDB_ERR_NOEXIST) {
DEBUG(0, ("allocate_print_jobid: failed to fetch INFO/nextjob for print queue %s\n",
sharename));
+ tdb_unlock_bystring(pdb->tdb, "INFO/nextjob");
return False;
}
+ DEBUG(10,("allocate_print_jobid: no existing jobid in %s\n", sharename));
jobid = 0;
}
+ DEBUG(10,("allocate_print_jobid: read jobid %u from %s\n", jobid, sharename));
+
jobid = NEXT_JOBID(jobid);
if (tdb_store_int32(pdb->tdb, "INFO/nextjob", jobid)==-1) {
/* We've finished with the INFO/nextjob lock. */
tdb_unlock_bystring(pdb->tdb, "INFO/nextjob");
- if (!print_job_exists(sharename, jobid))
+ if (!print_job_exists(sharename, jobid)) {
break;
+ }
+ DEBUG(10,("allocate_print_jobid: found jobid %u in %s\n", jobid, sharename));
}
if (i > 2) {
#include "includes.h"
-#define PRINT_TDB "/tmp/vlp.tdb"
#define PRINT_FIRSTJOB "100"
static TDB_CONTEXT *tdb;
int main(int argc, char **argv)
{
/* Parameter check */
+ char *printdb_path = NULL;
if (argc == 1) {
usage();
/* Initialise */
- if (!(tdb = tdb_open(PRINT_TDB, 0, 0, O_RDWR | O_CREAT,
+#if 0
+ printdb_path = "/tmp/vlp.tdb";
+#else
+ if (asprintf(&printdb_path, "%svlp.tdb",
+ cache_path("printing/"))) {
+ return 1;
+ }
+#endif
+
+ if (!(tdb = tdb_open(printdb_path, 0, 0, O_RDWR | O_CREAT,
0666))) {
- printf("%s: unable to open %s\n", argv[0], PRINT_TDB);
+ printf("%s: unable to open %s\n", argv[0], printdb_path);
return 1;
}
/* Ensure we are modes 666 */
- chmod(PRINT_TDB, 0666);
+ chmod(printdb_path, 0666);
/* Do commands */