apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bnicho...@apache.org
Subject cvs commit: apr/misc/netware aprlib.def
Date Tue, 05 Mar 2002 19:48:55 GMT
bnicholes    02/03/05 11:48:55

  Modified:    threadproc/netware proc.c
               file_io/netware pipe.c
               include/arch/netware fileio.h
               misc/netware aprlib.def
  Log:
  Second cut at fork/exec and pipe functionality on NetWare.  Still a work in
  progress.
  
  Revision  Changes    Path
  1.7       +57 -18    apr/threadproc/netware/proc.c
  
  Index: proc.c
  ===================================================================
  RCS file: /home/cvs/apr/threadproc/netware/proc.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- proc.c	29 Jan 2002 00:36:22 -0000	1.6
  +++ proc.c	5 Mar 2002 19:48:54 -0000	1.7
  @@ -333,36 +333,65 @@
       else
           envSpec.esEnv = NULL;
   
  +    envSpec.esStdin.ssType = NX_OBJ_FIFO;
  +    envSpec.esStdin.ssHandle = -1;
  +    envSpec.esStdin.ssPathCtx = 0;
       if (attr->child_in) {
  -        envSpec.esStdin.ssType = NX_OBJ_FIFO;
  -        envSpec.esStdin.ssHandle = attr->child_in->filedes;
  +        apr_pool_cleanup_kill(apr_file_pool_get(attr->child_in), 
  +                              attr->child_in, apr_netware_pipe_cleanup);
  +        envSpec.esStdin.ssPath = attr->child_in->fname;
  +        apr_file_close(attr->child_in);
  +        if (attr->parent_in) {
  +            apr_file_close(attr->parent_in);
  +        }
  +    }
  +    else if (attr->parent_in) {
  +        envSpec.esStdin.ssPath = attr->parent_in->fname;
  +        apr_file_close(attr->parent_in);
       }
       else {
  -        envSpec.esStdin.ssType = NX_OBJ_DEFAULT;
  -        envSpec.esStdin.ssHandle = -1;
  +        envSpec.esStdin.ssPath = NULL;
       }
  -    envSpec.esStdin.ssPathCtx = NULL;
  -    envSpec.esStdin.ssPath = NULL;
  +
  +    envSpec.esStdout.ssType = NX_OBJ_FIFO;
  +    envSpec.esStdout.ssHandle = -1;
  +    envSpec.esStdout.ssPathCtx = 0;
       if (attr->child_out) {
  -        envSpec.esStdout.ssType = NX_OBJ_FIFO;
  -        envSpec.esStdout.ssHandle = attr->child_out->filedes;
  +        apr_pool_cleanup_kill(apr_file_pool_get(attr->child_out),
  +                              attr->child_out, apr_netware_pipe_cleanup);
  +        envSpec.esStdout.ssPath = attr->child_out->fname;
  +        apr_file_close(attr->child_out);
  +        if (attr->parent_out) {
  +            apr_file_close(attr->parent_out);
  +        }
  +    }
  +    else if (attr->parent_out) {
  +        envSpec.esStdout.ssPath = attr->parent_out->fname;
  +        apr_file_close(attr->parent_out);
       }
       else {
  -        envSpec.esStdout.ssType = NX_OBJ_DEFAULT;
  -        envSpec.esStdout.ssHandle = -1;
  +        envSpec.esStdout.ssPath = NULL;
       }
  -    envSpec.esStdout.ssPathCtx = NULL;
  -    envSpec.esStdout.ssPath = NULL;
  +
  +    envSpec.esStderr.ssType = NX_OBJ_FIFO;
  +    envSpec.esStderr.ssHandle = -1;
  +    envSpec.esStderr.ssPathCtx = 0;
       if (attr->child_err) {
  -        envSpec.esStderr.ssType = NX_OBJ_FIFO;
  -        envSpec.esStderr.ssHandle = attr->child_err->filedes;
  +        apr_pool_cleanup_kill(apr_file_pool_get(attr->child_err),
  +                              attr->child_err, apr_netware_pipe_cleanup);
  +        envSpec.esStderr.ssPath = attr->child_err->fname;
  +        apr_file_close(attr->child_err);
  +        if (attr->parent_err) {
  +            apr_file_close(attr->parent_err);
  +        }
  +    }
  +    else if (attr->parent_err) {
  +        envSpec.esStderr.ssPath = attr->parent_err->fname;
  +        apr_file_close(attr->parent_err);
       }
       else {
  -        envSpec.esStderr.ssType = NX_OBJ_DEFAULT;
  -        envSpec.esStderr.ssHandle = -1;
  +        envSpec.esStderr.ssPath = NULL;
       }
  -    envSpec.esStderr.ssPathCtx = NULL;
  -    envSpec.esStderr.ssPath = NULL;
   
       if (attr->detached) {
           flags = NX_VM_CREATE_DETACHED;
  @@ -376,6 +405,16 @@
       }
       else { 
           newproc->pid = newVM;
  +        if (attr->parent_out) {
  +    	    attr->parent_out->filedes = pipe_open(attr->parent_out->fname, O_WRONLY);
  +        }
  +        if (attr->parent_in) {
  +    	    attr->parent_in->filedes = pipe_open(attr->parent_in->fname, O_RDONLY);
  +        }
  +        if (attr->parent_err) {
  +    	    attr->parent_err->filedes = pipe_open(attr->parent_err->fname, O_RDONLY);
  +        }
  +
           apr_pool_cleanup_register(cont, (void *)newproc, apr_netware_proc_cleanup,
                            apr_pool_cleanup_null);
       }
  
  
  
  1.5       +19 -60    apr/file_io/netware/pipe.c
  
  Index: pipe.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/netware/pipe.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- pipe.c	8 Feb 2002 19:13:43 -0000	1.4
  +++ pipe.c	5 Mar 2002 19:48:55 -0000	1.5
  @@ -59,27 +59,13 @@
   #include "fileio.h"
   #include "apr_strings.h"
   
  -static int convert_error (int err)
  -{
  -	switch (err)
  -	{
  -		default :			break;
  -		case NX_EINVAL:	    return APR_EINVAL;
  -		case NX_EBADF:		return APR_EBADF;
  -		case NX_ENOENT:		return APR_ENOENT;
  -		case NX_ENAMETOOLONG:return APR_ENAMETOOLONG;
  -	}
  -
  -    return err;
  -}
  -
   apr_status_t apr_netware_pipe_cleanup(void *thefile)
   {
       apr_file_t *file = thefile;
       apr_status_t rv = APR_SUCCESS;
       int rc;
   
  -	rc = NXClose(file->filedes);
  +	rc = close(file->filedes);
       if (rc == 0) {
           file->filedes = -1;
           if (file->thlock) {
  @@ -93,31 +79,19 @@
       return rv;
   }
   
  -#ifdef WAITING_FOR_UPDATE
  -#ifndef NX_CTL_FLAGS
  -#define NX_CTL_FLAGS             0x00000001
  -int   NXGetCtlInfo(NXHandle_t handle, unsigned long command, ...);
  -int   NXSetCtlInfo(NXHandle_t handle, unsigned long command, ...);
  -#endif
  -#endif
  -
   static apr_status_t pipeblock(apr_file_t *thepipe)
   {
   	int				err;
  -#ifdef WAITING_FOR_UPDATE
   	unsigned long	flags;
   
  -	if (!(err = NXGetCtlInfo(thepipe->filedes, NX_CTL_FLAGS, &flags)))
  +	if (fcntl(thepipe->filedes, F_GETFL, &flags) != -1)
   	{
  -		flags &= ~NX_O_NONBLOCK;
  -		err    = NXSetCtlInfo(thepipe->filedes, NX_CTL_FLAGS, flags);
  +		flags &= ~FNDELAY;
  +		fcntl(thepipe->filedes, F_SETFL, flags);
   	}
  -#else
  -    err = NXIoSetBlockingState(thepipe->filedes, 1);
  -#endif
   
  -    if (err)
  -        return convert_error (err);
  +    if (errno)
  +        return errno;
   
       thepipe->blocking = BLK_ON;
       return APR_SUCCESS;
  @@ -126,20 +100,17 @@
   static apr_status_t pipenonblock(apr_file_t *thepipe)
   {
   	int				err;
  -#ifdef WAITING_FOR_UPDATE
   	unsigned long	flags;
   
  -	if (!(err = NXGetCtlInfo(thepipe->filedes, NX_CTL_FLAGS, &flags)))
  +    errno = 0;
  +	if (fcntl(thepipe->filedes, F_GETFL, &flags) != -1)
   	{
  -		flags |= NX_O_NONBLOCK;
  -		err    = NXSetCtlInfo(thepipe->filedes, NX_CTL_FLAGS, flags);
  +		flags |= FNDELAY;
  +		fcntl(thepipe->filedes, F_SETFL, flags);
   	}
  -#else
  -    err = NXIoSetBlockingState(thepipe->filedes, 0);
  -#endif
   
  -    if (err)
  -        return convert_error (err);
  +    if (errno)
  +        return errno;
   
       thepipe->blocking = BLK_OFF;
       return APR_SUCCESS;
  @@ -176,14 +147,14 @@
   APR_DECLARE(apr_status_t) apr_file_pipe_create(apr_file_t **in, apr_file_t **out, apr_pool_t
*cont)
   {
   	char        tname[L_tmpnam+1];
  -	NXHandle_t	filedes[2];
  +	int     	filedes[2];
   	int 		err;
   
   	if (!tmpnam(tname))
   		return errno;
   
  -	if (  !(err = NXFifoOpen(0, tname, NX_O_RDONLY, 0, &filedes[0]))
  -		&& !(err = NXFifoOpen(0, tname, NX_O_WRONLY, 0, &filedes[1])))
  +	if ((filedes[0] = pipe_open(tname, O_RDONLY) != -1)
  +		&& (filedes[1] = pipe_open(tname, O_WRONLY) != -1))
   	{
           (*in) = (apr_file_t *)apr_pcalloc(cont, sizeof(apr_file_t));
           (*out) = (apr_file_t *)apr_pcalloc(cont, sizeof(apr_file_t));
  @@ -208,12 +179,9 @@
   	}
   	else
   	{
  -		if (filedes[0] != (NXHandle_t) -1)
  -			NXClose(filedes[0]);
  -
  -        if (err)
  -            return convert_error (err);
  -
  +		if (filedes[0] != -1)
  +			close(filedes[0]);
  +        return errno;
   	}
   
       apr_pool_cleanup_register((*in)->cntxt, (void *)(*in), apr_netware_pipe_cleanup,
  @@ -227,16 +195,7 @@
   APR_DECLARE(apr_status_t) apr_file_namedpipe_create(const char *filename, 
                                                       apr_fileperms_t perm, apr_pool_t *cont)
   {
  -    mode_t mode = apr_unix_perms2mode(perm);
  -	NXHandle_t	filedes;
  -	int err;
  -
  -	err = NXFifoOpen(0, filename, mode, 0, &filedes);
  -
  -    if (err)
  -        return convert_error (err);
  -
  -    return APR_SUCCESS;
  +    return APR_ENOTIMPL;
   } 
   
       
  
  
  
  1.4       +1 -5      apr/include/arch/netware/fileio.h
  
  Index: fileio.h
  ===================================================================
  RCS file: /home/cvs/apr/include/arch/netware/fileio.h,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- fileio.h	26 Nov 2001 19:06:00 -0000	1.3
  +++ fileio.h	5 Mar 2002 19:48:55 -0000	1.4
  @@ -162,11 +162,7 @@
   apr_status_t filepath_compare_drive(const char *path1, const char *path2, apr_pool_t *p);
   
   apr_status_t apr_unix_file_cleanup(void *);
  -
  -//mode_t apr_unix_perms2mode(apr_fileperms_t perms);
  -//apr_fileperms_t apr_unix_mode2perms(mode_t mode);
  -//
  -//int apr_mkstemp(char *template);
  +apr_status_t apr_netware_pipe_cleanup(void *thefile);
   
   #endif  /* ! FILE_IO_H */
   
  
  
  
  1.5       +0 -3      apr/misc/netware/aprlib.def
  
  Index: aprlib.def
  ===================================================================
  RCS file: /home/cvs/apr/misc/netware/aprlib.def,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- aprlib.def	8 Feb 2002 19:13:43 -0000	1.4
  +++ aprlib.def	5 Mar 2002 19:48:55 -0000	1.5
  @@ -1,6 +1,3 @@
   MODULE  LIBC.NLM
   MODULE  WS2_32.NLM
  -IMPORT  NXGetRandom
  -IMPORT  NXGetCtlInfo
  -IMPORT  NXSetCtlInfo
   EXPORT	@aprlib.imp
  
  
  

Mime
View raw message