diff options
author | Tim Potter <tpot@samba.org> | 2002-02-25 23:42:22 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 2002-02-25 23:42:22 +0000 |
commit | 98a377aacbb5fc7c8b3ae62828b02f7cae5ad845 (patch) | |
tree | 75afa5219ce968cef001af6a0e8e41ffec54e4f5 | |
parent | 3637c0f409d31259316778e7334a53c2db5de1bf (diff) | |
download | samba-98a377aacbb5fc7c8b3ae62828b02f7cae5ad845.tar.gz samba-98a377aacbb5fc7c8b3ae62828b02f7cae5ad845.tar.xz samba-98a377aacbb5fc7c8b3ae62828b02f7cae5ad845.zip |
Merge of printing performance fixes from appliance.
-rw-r--r-- | source/include/printing.h | 2 | ||||
-rw-r--r-- | source/printing/printing.c | 12 | ||||
-rw-r--r-- | source/rpc_server/srv_spoolss_nt.c | 50 |
3 files changed, 39 insertions, 25 deletions
diff --git a/source/include/printing.h b/source/include/printing.h index ee0b25d63fd..40fe964a193 100644 --- a/source/include/printing.h +++ b/source/include/printing.h @@ -39,7 +39,7 @@ struct printjob { fstring filename; /* the filename used to spool the file */ fstring jobname; /* the job name given to us by the client */ fstring user; /* the user who started the job */ - fstring qname; /* name of the print queue the job was sent to */ + int snum; /* service number of printer for this job */ }; /* Information for print interfaces */ diff --git a/source/printing/printing.c b/source/printing/printing.c index a1aa2ce76ed..7e4bd539f62 100644 --- a/source/printing/printing.c +++ b/source/printing/printing.c @@ -168,7 +168,7 @@ static void print_unix_job(int snum, print_queue_struct *q) fstrcpy(pj.filename, ""); fstrcpy(pj.jobname, q->file); fstrcpy(pj.user, q->user); - fstrcpy(pj.qname, lp_servicename(snum)); + pj.snum = snum; print_job_store(jobid, &pj); } @@ -190,7 +190,7 @@ static int traverse_fn_delete(TDB_CONTEXT *t, TDB_DATA key, TDB_DATA data, void memcpy(&jobid, key.dptr, sizeof(jobid)); memcpy(&pjob, data.dptr, sizeof(pjob)); - if (strcmp(lp_servicename(ts->snum), pjob.qname)) { + if (ts->snum != pjob.snum) { /* this isn't for the queue we are looking at */ ts->total_jobs++; return 0; @@ -497,7 +497,7 @@ int print_job_snum(int jobid) struct printjob *pjob = print_job_find(jobid); if (!pjob) return -1; - return lp_servicenumber(pjob->qname); + return pjob->snum; } /**************************************************************************** @@ -918,7 +918,7 @@ int print_job_start(struct current_user *user, int snum, char *jobname) fstrcpy(pjob.user, unix_to_dos(uidtoname(user->uid),False)); } - fstrcpy(pjob.qname, lp_servicename(snum)); + pjob.snum = snum; /* lock the database */ tdb_lock_bystring(tdb, "INFO/nextjob"); @@ -1072,7 +1072,7 @@ static int traverse_fn_queue(TDB_CONTEXT *t, TDB_DATA key, TDB_DATA data, void * memcpy(&pjob, data.dptr, sizeof(pjob)); /* maybe it isn't for this queue */ - if (ts->snum != print_queue_snum(pjob.qname)) return 0; + if (ts->snum != pjob.snum) return 0; if (ts->qcount >= ts->maxcount) return 0; @@ -1107,7 +1107,7 @@ static int traverse_count_fn_queue(TDB_CONTEXT *t, TDB_DATA key, TDB_DATA data, memcpy(&pjob, data.dptr, sizeof(pjob)); /* maybe it isn't for this queue */ - if (ts->snum != print_queue_snum(pjob.qname)) return 0; + if (ts->snum != pjob.snum) return 0; ts->count++; diff --git a/source/rpc_server/srv_spoolss_nt.c b/source/rpc_server/srv_spoolss_nt.c index 50d5624101a..24b43f2ffb4 100644 --- a/source/rpc_server/srv_spoolss_nt.c +++ b/source/rpc_server/srv_spoolss_nt.c @@ -4884,7 +4884,8 @@ static void fill_job_info_1(JOB_INFO_1 *job_info, print_queue_struct *queue, ****************************************************************************/ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, int position, int snum, - NT_PRINTER_INFO_LEVEL *ntprinter) + NT_PRINTER_INFO_LEVEL *ntprinter, + DEVICEMODE *devmode) { pstring temp_name; pstring chaine; @@ -4922,9 +4923,7 @@ static BOOL fill_job_info_2(JOB_INFO_2 *job_info, print_queue_struct *queue, job_info->timeelapsed=0; job_info->pagesprinted=0; - if((job_info->devmode = construct_dev_mode(snum)) == NULL) { - return False; - } + job_info->devmode = devmode; return (True); } @@ -4983,24 +4982,33 @@ static WERROR enumjobs_level2(print_queue_struct *queue, int snum, uint32 *needed, uint32 *returned) { NT_PRINTER_INFO_LEVEL *ntprinter = NULL; - JOB_INFO_2 *info; + JOB_INFO_2 *info = NULL; int i; WERROR result; + DEVICEMODE *devmode = NULL; info=(JOB_INFO_2 *)malloc(*returned*sizeof(JOB_INFO_2)); if (info==NULL) { *returned=0; - return WERR_NOMEM; + result = WERR_NOMEM; + goto done; } result = get_a_printer(&ntprinter, 2, lp_servicename(snum)); if (!W_ERROR_IS_OK(result)) { *returned = 0; - return result; + goto done; } + if (!(devmode = construct_dev_mode(snum))) { + *returned = 0; + result = WERR_NOMEM; + goto done; + } + for (i=0; i<*returned; i++) - fill_job_info_2(&(info[i]), &queue[i], i, snum, ntprinter); + fill_job_info_2( + &info[i], &queue[i], i, snum, ntprinter, devmode); free_a_printer(&ntprinter, 2); SAFE_FREE(queue); @@ -5009,27 +5017,32 @@ static WERROR enumjobs_level2(print_queue_struct *queue, int snum, for (i=0; i<*returned; i++) (*needed) += spoolss_size_job_info_2(&info[i]); + if (*needed > offered) { + *returned=0; + result = WERR_INSUFFICIENT_BUFFER; + goto done; + } + if (!alloc_buffer_size(buffer, *needed)) { SAFE_FREE(info); - return WERR_INSUFFICIENT_BUFFER; + result = WERR_INSUFFICIENT_BUFFER; + goto done; } /* fill the buffer with the structures */ for (i=0; i<*returned; i++) smb_io_job_info_2("", buffer, &info[i], 0); - /* clear memory */ - for (i = 0; i < *returned; i++) - free_job_info_2(&info[i]); + result = WERR_OK; + done: + free_a_printer(&ntprinter, 2); + free_devmode(devmode); + SAFE_FREE(queue); SAFE_FREE(info); - if (*needed > offered) { - *returned=0; - return WERR_INSUFFICIENT_BUFFER; - } + return result; - return WERR_OK; } /**************************************************************************** @@ -6934,6 +6947,7 @@ static WERROR getjob_level_2(print_queue_struct *queue, int count, int snum, uin JOB_INFO_2 *info_2; NT_PRINTER_INFO_LEVEL *ntprinter = NULL; WERROR ret; + DEVICEMODE *devmode = NULL; info_2=(JOB_INFO_2 *)malloc(sizeof(JOB_INFO_2)); @@ -6962,7 +6976,7 @@ static WERROR getjob_level_2(print_queue_struct *queue, int count, int snum, uin return ret; } - fill_job_info_2(info_2, &(queue[i-1]), i, snum, ntprinter); + fill_job_info_2(info_2, &(queue[i-1]), i, snum, ntprinter, devmode); free_a_printer(&ntprinter, 2); SAFE_FREE(queue); |