From: David Disseldorp Date: Mon, 30 Jan 2012 12:35:21 +0000 (+0100) Subject: s3-printing: remove print_parse_jobid() calls from printing.c X-Git-Url: http://git.samba.org/?a=commitdiff_plain;ds=sidebyside;h=597fc84702b04861a7c2e71c7d2f45e81199ebb8;p=ddiss%2Fsamba.git s3-printing: remove print_parse_jobid() calls from printing.c In all cases the spoolss layer job id can be determinded from the printing subsystem allocated job identifier (sysjob). --- diff --git a/source3/printing/printing.c b/source3/printing/printing.c index 70ee2bc6bdc..7a182a84677 100644 --- a/source3/printing/printing.c +++ b/source3/printing/printing.c @@ -506,6 +506,18 @@ static int unixjob_traverse_fn(TDB_CONTEXT *the_tdb, TDB_DATA key, return 0; } +static uint32 sysjob_to_jobid_pdb(struct tdb_print_db *pdb, int sysjob) +{ + struct unixjob_traverse_state state; + + state.sysjob = sysjob; + state.sysjob_to_jobid_value = (uint32)-1; + + tdb_traverse(pdb->tdb, unixjob_traverse_fn, &state); + + return state.sysjob_to_jobid_value; +} + /**************************************************************************** This is a *horribly expensive call as we have to iterate through all the current printer tdb's. Don't do this often ! JRA. @@ -938,10 +950,8 @@ static int traverse_fn_delete(TDB_CONTEXT *t, TDB_DATA key, TDB_DATA data, void if (!pjob.smbjob) { /* remove a unix job if it isn't in the system queue any more */ - for (i=0;iqcount;i++) { - uint32 u_jobid = (ts->queue[i].sysjob + UNIX_JOB_START); - if (jobid == u_jobid) + if (ts->queue[i].sysjob == pjob.sysjob) break; } if (i == ts->qcount) { @@ -973,16 +983,12 @@ static int traverse_fn_delete(TDB_CONTEXT *t, TDB_DATA key, TDB_DATA data, void /* this check only makes sense for jobs submitted from Windows clients */ - if ( pjob.smbjob ) { + if (pjob.smbjob) { for (i=0;iqcount;i++) { - uint32 curr_jobid; - if ( pjob.status == LPQ_DELETED ) continue; - curr_jobid = print_parse_jobid(ts->queue[i].fs_file); - - if (jobid == curr_jobid) { + if (ts->queue[i].sysjob == pjob.sysjob) { /* try to clean up any jobs that need to be deleted */ @@ -1037,11 +1043,8 @@ static int traverse_fn_delete(TDB_CONTEXT *t, TDB_DATA key, TDB_DATA data, void return 0; } - /* Save the pjob attributes we will store. - FIXME!!! This is the only place where queue->job - represents the SMB jobid --jerry */ - - ts->queue[i].sysjob = jobid; + /* Save the pjob attributes we will store. */ + ts->queue[i].sysjob = pjob.sysjob; ts->queue[i].size = pjob.size; ts->queue[i].page_count = pjob.page_count; ts->queue[i].status = pjob.status; @@ -1326,11 +1329,11 @@ done: main work for updating the lpq cache for a printer queue ****************************************************************************/ -static void print_queue_update_internal( struct tevent_context *ev, - struct messaging_context *msg_ctx, - const char *sharename, - struct printif *current_printif, - char *lpq_command, char *lprm_command ) +static void print_queue_update_internal(struct tevent_context *ev, + struct messaging_context *msg_ctx, + const char *sharename, + struct printif *current_printif, + char *lpq_command, char *lprm_command) { int i, qcount; print_queue_struct *queue = NULL; @@ -1388,8 +1391,7 @@ static void print_queue_update_internal( struct tevent_context *ev, jcdata = get_jobs_added_data(pdb); for (i=0; isysjob = queue[i].sysjob; /* don't reset the status on jobs to be deleted */