diff options
author | David Disseldorp <ddiss@samba.org> | 2012-01-26 15:28:34 +0100 |
---|---|---|
committer | David Disseldorp <ddiss@samba.org> | 2012-06-26 16:10:39 +0200 |
commit | a2d880ddcda4c0f5227945b644f8abe6af4a276d (patch) | |
tree | 3408f1c53ffda3bfa05d456617652249d14b5051 | |
parent | 33f08906c66fd28383d9ffad6f3916086a9f517d (diff) | |
download | samba-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.
-rw-r--r-- | source3/include/printing.h | 3 | ||||
-rw-r--r-- | source3/printing/printing.c | 29 |
2 files changed, 19 insertions, 13 deletions
diff --git a/source3/include/printing.h b/source3/include/printing.h index cfdf3a4a8c..aa28b78fdd 100644 --- a/source3/include/printing.h +++ b/source3/include/printing.h @@ -69,6 +69,7 @@ typedef struct { /* Information for print jobs */ struct printjob { pid_t pid; /* which process launched the job */ + uint32_t jobid; /* the spoolss print job identifier */ int sysjob; /* the system (lp) job number */ int fd; /* file descriptor of open file if open */ time_t starttime; /* when the job started spooling */ @@ -124,7 +125,7 @@ extern struct printif iprint_printif; #ifndef PRINT_SPOOL_PREFIX #define PRINT_SPOOL_PREFIX "smbprn." #endif -#define PRINT_DATABASE_VERSION 7 +#define PRINT_DATABASE_VERSION 8 #ifdef AIX #define DEFAULT_PRINTING PRINT_AIX 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); |