Re: SSL -> joining sockets and files

From: Date: Thu, 01 Mar 2001 12:12:55 +0000
Subject: Re: SSL -> joining sockets and files
Groups: php.dev 
Request: Send a blank email to php-dev+get-47712@lists.php.net to get a copy of this message
On 2001-03-01 05:14:18, Andi Gutmans <andi@zend.com> wrote: > This sounds pretty good. I'll try and look at the code this weekend. Some > of the code is really ugly especially the legacy code. > When you say there are places which need a FILE * do you mean they just > need to check the id and check that it's a FILE * or do they convert > descriptors to FILE * (can't remember if that's possible or not :). A bit of both. the fopen_wrapper_for_zend (or whatever it's called) use fdopen in this way, but mostly the code can be changed to use the file abstraction. Using fdopen might be problematic when SSL is concerned, unless we use fopencookie to provide a FILE *. Some extensions might need to pass a FILE * to library functions, so perhaps we should add a php_file_cast_to_FILE() function. It might work something like this: // and also a similar version for sockets typedef struct _php_file_FILE { php_file ops; FILE * file; } php_file_FILE; FILE * php_file_cast_to_FILE(php_file * file) { // if it can be expressed as a FILE, pass it back if (file->type & PHP_FILE_IS_FILE) return ((php_file_FILE*)file)->file; // if it is a socketd, use fdopen if (file->type & PHP_FILE_IS_SOCKET) return fdopen(((php_file_socket*)file)->socket); #if HAVE_FOPEN_COOKIE // Create a generic fopen cookie that uses our abstraction ... code omitted for brevity ... #endif return NULL; } For systems without fopencookie, you will still only be able to use regular FILE or socketds in this way, but with fopencookie present, you can pretty much do anything you want. Also, we can isolate the fopencookie code to just this one place and the rest of the codebase will be more portable. A problem with the above it that in the case of fdopen we don't record that we handed out a FILE *. We can solve that by keeping the reference stashed somewhere in the php_file. Another problem that might arise is if the code uses a mixture of stdio and php abstraction functions and the FILE has buffering turned on. So, if we have created a FILE using fdopen or fopencookie, maybe we should switch the operations to use the stdio versions on that FILE? --Wez.

« previous php.dev (#47712) next »