You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by bj...@locus.apache.org on 2000/05/25 05:05:29 UTC
cvs commit: apache-2.0/src/lib/apr/threadproc/os2 proc.c threadproc.h
bjh 00/05/24 20:05:28
Modified: src/lib/apr/threadproc/os2 proc.c threadproc.h
Log:
OS/2: Adapt to new ap_proc_t type & add missing ap_setprocattr_child*
functions.
Revision Changes Path
1.24 +65 -47 apache-2.0/src/lib/apr/threadproc/os2/proc.c
Index: proc.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/threadproc/os2/proc.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- proc.c 2000/04/28 18:27:47 1.23
+++ proc.c 2000/05/25 03:05:27 1.24
@@ -144,6 +144,54 @@
return APR_SUCCESS;
}
+ap_status_t ap_setprocattr_childin(ap_procattr_t *attr, ap_file_t *child_in,
+ ap_file_t *parent_in)
+{
+ if (attr->child_in == NULL && attr->parent_in == NULL)
+ ap_create_pipe(&attr->child_in, &attr->parent_in, attr->cntxt);
+
+ if (child_in != NULL)
+ ap_dupfile(&attr->child_in, child_in, attr->cntxt);
+
+ if (parent_in != NULL)
+ ap_dupfile(&attr->parent_in, parent_in, attr->cntxt);
+
+ return APR_SUCCESS;
+}
+
+
+ap_status_t ap_setprocattr_childout(ap_procattr_t *attr, ap_file_t *child_out,
+ ap_file_t *parent_out)
+{
+ if (attr->child_out == NULL && attr->parent_out == NULL)
+ ap_create_pipe(&attr->child_out, &attr->parent_out, attr->cntxt);
+
+ if (child_out != NULL)
+ ap_dupfile(&attr->child_out, child_out, attr->cntxt);
+
+ if (parent_out != NULL)
+ ap_dupfile(&attr->parent_out, parent_out, attr->cntxt);
+
+ return APR_SUCCESS;
+}
+
+
+ap_status_t ap_setprocattr_childerr(ap_procattr_t *attr, ap_file_t *child_err,
+ ap_file_t *parent_err)
+{
+ if (attr->child_err == NULL && attr->parent_err == NULL)
+ ap_create_pipe(&attr->child_err, &attr->parent_err, attr->cntxt);
+
+ if (child_err != NULL)
+ ap_dupfile(&attr->child_err, child_err, attr->cntxt);
+
+ if (parent_err != NULL)
+ ap_dupfile(&attr->parent_err, parent_err, attr->cntxt);
+
+ return APR_SUCCESS;
+}
+
+
ap_status_t ap_setprocattr_dir(ap_procattr_t *attr, const char *dir)
{
attr->currdir = ap_pstrdup(attr->cntxt, dir);
@@ -166,24 +214,24 @@
return APR_SUCCESS;
}
-ap_status_t ap_fork(ap_proc_t **proc, ap_pool_t *cont)
+ap_status_t ap_fork(ap_proc_t *proc, ap_pool_t *cont)
{
int pid;
- (*proc) = ap_palloc(cont, sizeof(ap_proc_t));
-
if ((pid = fork()) < 0) {
return errno;
- } else if (pid == 0) {
- (*proc)->pid = pid;
- (*proc)->attr = NULL;
- (*proc)->running = TRUE;
+ }
+ else if (pid == 0) {
+ proc->pid = pid;
+ proc->in = NULL;
+ proc->out = NULL;
+ proc->err = NULL;
return APR_INCHILD;
}
-
- (*proc)->pid = pid;
- (*proc)->attr = NULL;
- (*proc)->running = TRUE;
+ proc->pid = pid;
+ proc->in = NULL;
+ proc->out = NULL;
+ proc->err = NULL;
return APR_INPARENT;
}
@@ -217,7 +265,7 @@
-ap_status_t ap_create_process(ap_proc_t **new, const char *progname,
+ap_status_t ap_create_process(ap_proc_t *proc, const char *progname,
char *const args[], char **env,
ap_procattr_t *attr, ap_pool_t *cont)
{
@@ -235,15 +283,6 @@
char *env_block, *env_block_pos;
RESULTCODES rescodes;
- (*new) = (ap_proc_t *)ap_palloc(cont, sizeof(ap_proc_t));
-
- if ((*new) == NULL) {
- return APR_ENOMEM;
- }
-
- (*new)->cntxt = cont;
- (*new)->running = FALSE;
-
/* Prevent other threads from running while these process-wide resources are modified */
if (attr->child_in || attr->child_out || attr->child_err || attr->currdir) {
criticalsection = TRUE;
@@ -402,7 +441,7 @@
attr->detached ? EXEC_BACKGROUND : EXEC_ASYNCRESULT,
cmdline, env_block, &rescodes, cmdline);
- (*new)->pid = rescodes.codeTerminate;
+ proc->pid = rescodes.codeTerminate;
if (attr->currdir != NULL) {
chdir(savedir);
@@ -432,32 +471,15 @@
if (criticalsection)
DosExitCritSec();
- (*new)->attr = attr;
- (*new)->running = status == APR_SUCCESS;
+ proc->in = attr->parent_in;
+ proc->err = attr->parent_err;
+ proc->out = attr->parent_out;
return status;
}
-ap_status_t ap_get_childin(ap_file_t **new, ap_proc_t *proc)
-{
- (*new) = proc->attr->parent_in;
- return APR_SUCCESS;
-}
-
-ap_status_t ap_get_childout(ap_file_t **new, ap_proc_t *proc)
-{
- (*new) = proc->attr->parent_out;
- return APR_SUCCESS;
-}
-
-ap_status_t ap_get_childerr(ap_file_t **new, ap_proc_t *proc)
-{
- (*new) = proc->attr->parent_err;
- return APR_SUCCESS;
-}
-
-ap_status_t ap_wait_proc(ap_proc_t *proc,
+ap_status_t ap_wait_proc(ap_proc_t *proc,
ap_wait_how_e wait)
{
RESULTCODES codes;
@@ -467,13 +489,9 @@
if (!proc)
return APR_ENOPROC;
- if (!proc->running)
- return APR_CHILD_DONE;
-
rc = DosWaitChild(DCWA_PROCESS, wait == APR_WAIT ? DCWW_WAIT : DCWW_NOWAIT, &codes, &pid, proc->pid);
if (rc == 0) {
- proc->running = 0;
return APR_CHILD_DONE;
} else if (rc == ERROR_CHILD_NOT_COMPLETE) {
return APR_CHILD_NOTDONE;
1.7 +0 -7 apache-2.0/src/lib/apr/threadproc/os2/threadproc.h
Index: threadproc.h
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/threadproc/os2/threadproc.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- threadproc.h 2000/04/14 15:58:49 1.6
+++ threadproc.h 2000/05/25 03:05:27 1.7
@@ -95,13 +95,6 @@
ap_int32_t detached;
};
-struct ap_proc_t {
- ap_pool_t *cntxt;
- pid_t pid;
- struct ap_procattr_t *attr;
- int running;
-};
-
typedef void (*os2_thread_start_t)(void *);
#endif /* ! THREAD_PROC_H */