Re: PDF_close problem
| From: | Rasmus Lerdorf | Date: | Thu, 01 Jan 1970 00:00:00 +0000 |
| Subject: | Re: PDF_close problem | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-3340@lists.php.net to get a copy of this message | ||
> Maybe I'm completely confused, but the change to pdf_close() which
> you made didn't remove the file pointer
> from PHP's list of open files, it removes the pdf document.
>
> if(!pdf || type!=PDF_GLOBAL(le_pdf)) {
> php3_error(E_WARNING,"Unable to find file identifier %d",id);
> RETURN_FALSE;
> }
> PDF_close(pdf);
> php3_list_delete(id);
>
> This means the file is close (somewhere in PDF_close()) but the file
> pointer is still in the list.
How am I removing the pdf document. In pdf_open() you have:
/* {{{ proto int pdf_open(int filedesc, int info) */
...
if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &file, &info) == FAILURE) {
WRONG_PARAM_COUNT;
}
...
id=file->value.lval;
fp = php3_list_find(id,&type);
ahhh...
I see the problem. You are using the 'id' variable a second time here:
id=info->value.lval;
pdf_info = php3_list_find(id,&type);
and then returning this id. Reusing variables for two different things is
probably not a good idea.
We have a problem then. pdf_close() definitely needs to remove the entry
from the list of open files since it does close the file. But,
pdf_close() has no idea how to find this entry because there is no
relationship between pdfdoc and fd.
I think the solution is to either fopen() the file right in pdf_open() and
associate fd and pdfdoc directly as a single entity, or perhaps a better
solution would be to store the fd id in the pdfdoc struct somehow.
I agree that my fix is bogus and should be fixed further. I'll let you
play with it.
-Rasmus
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net