gstein 01/01/26 01:05:58
Modified: modules/generators mod_cgid.c
file_io/os2 open.c
file_io/unix open.c
file_io/win32 open.c
Log:
apr_put_os_file() expected the caller to have an existing file or init to
NULL. using an existing file doesn't normally work: where would you get a
blank file to shove an FD into? expecting the user to assign to NULL is
error-prone (mod_isapi didn't).
*) always create and return a new file from apr_put_os_file()
*) reimplement apr_open_stderr() in terms of apr_put_os_file()
[ except for win32... some issues there ]
*) remove some (obsolete) inits to NULL
Revision Changes Path
1.62 +2 -2 httpd-2.0/modules/generators/mod_cgid.c
Index: mod_cgid.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/generators/mod_cgid.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -u -r1.61 -r1.62
--- mod_cgid.c 2001/01/19 07:04:20 1.61
+++ mod_cgid.c 2001/01/26 09:05:40 1.62
@@ -443,7 +443,7 @@
request_rec *r;
apr_procattr_t *procattr = NULL;
apr_proc_t *procnew = NULL;
- apr_file_t *inout = NULL;
+ apr_file_t *inout;
len = sizeof(unix_addr);
@@ -743,7 +743,7 @@
int sd;
char **env;
struct sockaddr_un unix_addr;
- apr_file_t *tempsock = NULL;
+ apr_file_t *tempsock;
apr_size_t nbytes;
if(strcmp(r->handler,CGI_MAGIC_TYPE) && strcmp(r->handler,"cgi-script"))
1.36 +5 -17 apr/file_io/os2/open.c
Index: open.c
===================================================================
RCS file: /home/cvs/apr/file_io/os2/open.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -u -r1.35 -r1.36
--- open.c 2001/01/24 08:26:20 1.35
+++ open.c 2001/01/26 09:05:44 1.36
@@ -220,10 +220,9 @@
apr_status_t apr_put_os_file(apr_file_t **file, apr_os_file_t *thefile,
apr_pool_t *cont)
{
apr_os_file_t *dafile = thefile;
- if ((*file) == NULL) {
- (*file) = (apr_file_t *)apr_palloc(cont, sizeof(apr_file_t));
- (*file)->cntxt = cont;
- }
+
+ (*file) = apr_palloc(cont, sizeof(apr_file_t));
+ (*file)->cntxt = cont;
(*file)->filedes = *dafile;
(*file)->isopen = TRUE;
(*file)->buffered = FALSE;
@@ -247,20 +246,9 @@
apr_status_t apr_open_stderr(apr_file_t **thefile, apr_pool_t *cont)
{
- (*thefile) = apr_palloc(cont, sizeof(apr_file_t));
- if ((*thefile) == NULL) {
- return APR_ENOMEM;
- }
- (*thefile)->cntxt = cont;
- (*thefile)->filedes = 2;
- (*thefile)->fname = NULL;
- (*thefile)->isopen = TRUE;
- (*thefile)->buffered = FALSE;
- (*thefile)->eof_hit = FALSE;
- (*thefile)->flags = 0;
- (*thefile)->pipe = FALSE;
+ int fd = 2;
- return APR_SUCCESS;
+ return apr_put_os_file(thefile, &fd, cont);
}
APR_POOL_IMPLEMENT_ACCESSOR_X(file, cntxt);
1.69 +4 -18 apr/file_io/unix/open.c
Index: open.c
===================================================================
RCS file: /home/cvs/apr/file_io/unix/open.c,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -u -r1.68 -r1.69
--- open.c 2001/01/24 08:26:20 1.68
+++ open.c 2001/01/26 09:05:48 1.69
@@ -217,10 +217,8 @@
{
int *dafile = thefile;
- if ((*file) == NULL) {
- (*file) = apr_pcalloc(cont, sizeof(apr_file_t));
- (*file)->cntxt = cont;
- }
+ (*file) = apr_pcalloc(cont, sizeof(apr_file_t));
+ (*file)->cntxt = cont;
(*file)->eof_hit = 0;
(*file)->buffered = 0;
(*file)->blocking = BLK_UNKNOWN; /* in case it is a pipe */
@@ -249,23 +247,11 @@
return APR_SUCCESS;
}
-/* apr_open_stderr() could just call apr_put_os_file() with
- * STDERR_FILENO for the descriptor...
- */
apr_status_t apr_open_stderr(apr_file_t **thefile, apr_pool_t *cont)
{
- (*thefile) = apr_pcalloc(cont, sizeof(apr_file_t));
- if ((*thefile) == NULL) {
- return APR_ENOMEM;
- }
- (*thefile)->filedes = STDERR_FILENO;
- (*thefile)->cntxt = cont;
- (*thefile)->buffered = 0;
- (*thefile)->blocking = BLK_UNKNOWN;
- (*thefile)->fname = NULL;
- (*thefile)->eof_hit = 0;
+ int fd = STDERR_FILENO;
- return APR_SUCCESS;
+ return apr_put_os_file(thefile, &fd, cont);
}
APR_POOL_IMPLEMENT_ACCESSOR_X(file, cntxt);
1.67 +7 -7 apr/file_io/win32/open.c
Index: open.c
===================================================================
RCS file: /home/cvs/apr/file_io/win32/open.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -u -r1.66 -r1.67
--- open.c 2001/01/25 20:29:39 1.66
+++ open.c 2001/01/26 09:05:55 1.67
@@ -400,13 +400,8 @@
apr_os_file_t *thefile,
apr_pool_t *cont)
{
- if ((*file) == NULL) {
- if (cont == NULL) {
- return APR_ENOPOOL;
- }
- (*file) = (apr_file_t *)apr_pcalloc(cont, sizeof(apr_file_t));
- (*file)->cntxt = cont;
- }
+ (*file) = apr_pcalloc(cont, sizeof(apr_file_t));
+ (*file)->cntxt = cont;
(*file)->filehand = *thefile;
(*file)->ungetchar = -1; /* no char avail */
return APR_SUCCESS;
@@ -422,6 +417,11 @@
APR_DECLARE(apr_status_t) apr_open_stderr(apr_file_t **thefile, apr_pool_t
*cont)
{
+ /* ### should this be rebuilt in terms of apr_put_os_file()?? their
+ ### initializations are slightly different (maybe one or both are
+ ### not init'ing properly?)
+ */
+
(*thefile) = apr_pcalloc(cont, sizeof(apr_file_t));
if ((*thefile) == NULL) {
return APR_ENOMEM;