summaryrefslogtreecommitdiff
path: root/source3/printing
diff options
context:
space:
mode:
authorDavid Disseldorp <ddiss@samba.org>2012-01-26 15:28:34 +0100
committerDavid Disseldorp <ddiss@samba.org>2012-06-26 16:10:39 +0200
commita2d880ddcda4c0f5227945b644f8abe6af4a276d (patch)
tree3408f1c53ffda3bfa05d456617652249d14b5051 /source3/printing
parent33f08906c66fd28383d9ffad6f3916086a9f517d (diff)
downloadsamba-a2d880ddcda4c0f5227945b644f8abe6af4a276d.tar.gz
samba-a2d880ddcda4c0f5227945b644f8abe6af4a276d.tar.bz2
samba-a2d880ddcda4c0f5227945b644f8abe6af4a276d.zip
s3-printing: store print jobid as part of struct printjob
Printing code in some places relies upon the spool-file format to retrieve the print jobid. By storing the jobid as part of struct printjob, and hence in the printing TDB, we can move away from this ugly behaviour.
Diffstat (limited to 'source3/printing')
-rw-r--r--source3/printing/printing.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index 0d943a38df..7f742167cc 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -380,18 +380,20 @@ done:
unpack a pjob from a tdb buffer
***********************************************************************/
-static int unpack_pjob( uint8 *buf, int buflen, struct printjob *pjob )
+static int unpack_pjob(uint8 *buf, int buflen, struct printjob *pjob)
{
int len = 0;
int used;
- uint32 pjpid, pjsysjob, pjfd, pjstarttime, pjstatus;
+ uint32 pjpid, pjjobid, pjsysjob, pjfd, pjstarttime, pjstatus;
uint32 pjsize, pjpage_count, pjspooled, pjsmbjob;
- if ( !buf || !pjob )
+ if (!buf || !pjob) {
return -1;
+ }
- len += tdb_unpack(buf+len, buflen-len, "dddddddddfffff",
+ len += tdb_unpack(buf+len, buflen-len, "ddddddddddfffff",
&pjpid,
+ &pjjobid,
&pjsysjob,
&pjfd,
&pjstarttime,
@@ -406,8 +408,9 @@ static int unpack_pjob( uint8 *buf, int buflen, struct printjob *pjob )
pjob->clientmachine,
pjob->queuename);
- if ( len == -1 )
+ if (len == -1) {
return -1;
+ }
used = unpack_devicemode(NULL, buf+len, buflen-len, &pjob->devmode);
if (used == -1) {
@@ -417,6 +420,7 @@ static int unpack_pjob( uint8 *buf, int buflen, struct printjob *pjob )
len += used;
pjob->pid = pjpid;
+ pjob->jobid = pjjobid;
pjob->sysjob = pjsysjob;
pjob->fd = pjfd;
pjob->starttime = pjstarttime;
@@ -470,6 +474,7 @@ static struct printjob *print_job_find(const char *sharename, uint32 jobid)
DEBUG(10,("print_job_find: returning system job %d for jobid %u.\n",
(int)pjob.sysjob, (unsigned int)jobid ));
+ SMB_ASSERT(pjob.jobid == jobid);
return &pjob;
}
@@ -496,9 +501,7 @@ static int unixjob_traverse_fn(TDB_CONTEXT *the_tdb, TDB_DATA key,
return 0;
if (state->sysjob == pjob->sysjob) {
- uint32 jobid = IVAL(key.dptr,0);
-
- state->sysjob_to_jobid_value = jobid;
+ state->sysjob_to_jobid_value = pjob->jobid;
return 1;
}
@@ -744,8 +747,9 @@ static bool pjob_store(struct tevent_context *ev,
do {
len = 0;
buflen = newlen;
- len += tdb_pack(buf+len, buflen-len, "dddddddddfffff",
+ len += tdb_pack(buf+len, buflen-len, "ddddddddddfffff",
(uint32)pjob->pid,
+ (uint32)pjob->jobid,
(uint32)pjob->sysjob,
(uint32)pjob->fd,
(uint32)pjob->starttime,
@@ -882,6 +886,7 @@ static void print_unix_job(struct tevent_context *ev,
ZERO_STRUCT(pj);
pj.pid = (pid_t)-1;
+ pj.jobid = jobid;
pj.sysjob = q->job;
pj.fd = -1;
pj.starttime = old_pj ? old_pj->starttime : q->time;
@@ -928,11 +933,10 @@ static int traverse_fn_delete(TDB_CONTEXT *t, TDB_DATA key, TDB_DATA data, void
if ( key.dsize != sizeof(jobid) )
return 0;
- jobid = IVAL(key.dptr, 0);
- if ( unpack_pjob( data.dptr, data.dsize, &pjob ) == -1 )
+ if (unpack_pjob(data.dptr, data.dsize, &pjob) == -1)
return 0;
talloc_free(pjob.devmode);
-
+ jobid = pjob.jobid;
if (!pjob.smbjob) {
/* remove a unix job if it isn't in the system queue any more */
@@ -2721,6 +2725,7 @@ WERROR print_job_start(const struct auth_session_info *server_info,
ZERO_STRUCT(pjob);
pjob.pid = getpid();
+ pjob.jobid = jobid;
pjob.sysjob = -1;
pjob.fd = -1;
pjob.starttime = time(NULL);