d.dptr = (void *)pjob;
d.dsize = sizeof(*pjob);
- return (0 == tdb_store(tdb, print_key(jobid), d, TDB_REPLACE));
+ return (tdb_store(tdb, print_key(jobid), d, TDB_REPLACE) == 0);
}
/****************************************************************************
ret = smbrun(syscmd,outfile,False);
DEBUG(3,("Running the command `%s' gave %d\n",syscmd,ret));
+
return ret;
}
slprintf(tmp_file, sizeof(tmp_file), "%s/smblpq.%d", path, local_pid);
unlink(tmp_file);
- print_run_command(snum, cmd, tmp_file,
- NULL);
+ print_run_command(snum, cmd, tmp_file, NULL);
numlines = 0;
qlines = file_lines_load(tmp_file, &numlines);
}
file_lines_free(qlines);
+ DEBUG(3, ("%d job%s in queue for %s\n", qcount, (qcount != 1) ?
+ "s" : "", lp_servicename(snum)));
+
+ /* Lock the queue for the database update */
+
+ slprintf(keystr, sizeof(keystr) - 1, "LOCK/%s", lp_servicename(snum));
+ tdb_lock_bystring(tdb, keystr);
+
/*
any job in the internal database that is marked as spooled
and doesn't exist in the system queue is considered finished
key.dsize = strlen(keystr);
tdb_store(tdb, key, data, TDB_REPLACE);
+ /* Unlock for database update */
+
+ slprintf(keystr, sizeof(keystr) - 1, "LOCK/%s", lp_servicename(snum));
+ tdb_unlock_bystring(tdb, keystr);
+
/*
* Update the cache time again. We want to do this call
* as little as possible...
{
fstring key;
time_t t2, t = time(NULL);
+
slprintf(key, sizeof(key), "CACHE/%s", lp_servicename(snum));
t2 = tdb_fetch_int(tdb, key);
if (t2 == ((time_t)-1) || (t - t2) >= lp_lpqcachetime()) {
+ DEBUG(3, ("print cache expired\n"));
return True;
}
return False;