# HG changeset patch # User Keerthi Kondaka # Date 1278465723 25200 # Node ID e64b5ecb0036ca02b27bade966c93b0123f3b1e8 # Parent 6c0cc5cfe9a2707cdc3fe3a0db0c30cd3c742ab1 6946115 lpstat -o return bad-argument error even when jobID is valid diff -r 6c0cc5cfe9a2 -r e64b5ecb0036 usr/src/lib/print/libpapi-lpd/common/lpd-query.c --- a/usr/src/lib/print/libpapi-lpd/common/lpd-query.c Tue Jul 06 18:04:43 2010 -0700 +++ b/usr/src/lib/print/libpapi-lpd/common/lpd-query.c Tue Jul 06 18:22:03 2010 -0700 @@ -20,9 +20,7 @@ */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - * + * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. */ /* $Id: lpd-query.c 155 2006-04-26 02:34:54Z ktou $ */ @@ -404,11 +402,16 @@ { int fd; - if (svc->cache != NULL) /* this should be time based */ + if (svc == NULL) return; - if (svc == NULL) - return; + if (svc->cache != NULL) { /* this should be time based */ + if (svc->cache->jobs == NULL) { + free(svc->cache); + svc->cache = NULL; + } else + return; + } if ((fd = lpd_open(svc, 'q', NULL, 15)) < 0) return; @@ -451,6 +454,17 @@ } } + /* + * cache jobs is free()-ed in + * libpapi-dynamic/common/printer.c - + * papiPrinterListJobs() cache printer is + * free()-ed by the caller of + * lpd_find_printer_info Invalidate the + * cache by freeing the cache. + */ + free(svc->cache); + svc->cache = NULL; + return (result); } @@ -460,7 +474,7 @@ papi_status_t result = PAPI_BAD_ARGUMENT; job_t **jobs; - if (lpd_find_jobs_info(svc, &jobs) != PAPI_OK) { + if ((lpd_find_jobs_info(svc, &jobs) == PAPI_OK) && (jobs != NULL)) { int i; *job = NULL;