You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rb...@hyperreal.org on 1999/05/26 17:46:00 UTC
cvs commit: apache-apr/include apr_errno.h
rbb 99/05/26 08:45:59
Modified: apr/test client.c testsock.c
apr/threadproc/unix proc.c
include apr_errno.h
Log:
Changes required to get testsock up and working again.
Revision Changes Path
1.7 +7 -2 apache-apr/apr/test/client.c
Index: client.c
===================================================================
RCS file: /home/cvs/apache-apr/apr/test/client.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- client.c 1999/05/25 17:03:53 1.6
+++ client.c 1999/05/26 15:45:56 1.7
@@ -70,6 +70,7 @@
ap_socket_t *sock;
ap_int32_t rv;
ap_ssize_t length;
+ ap_status_t stat;
struct timeval timeout;
char datasend[STRLEN] = "Send data test";
char datarecv[STRLEN];
@@ -105,9 +106,13 @@
fprintf(stdout, "OK\n");
fprintf(stdout, "\tClient: Connecting to socket.......");
- if (ap_connect(sock, "localhost") != APR_SUCCESS) {
+do {
+ stat = ap_connect(sock, "localhost");
+} while (stat == APR_ECONNREFUSED);
+ if (stat != APR_SUCCESS) {
ap_close_socket(sock);
- fprintf(stderr, "Could not connect\n");
+ fprintf(stderr, "Could not connect %d\n", stat);
+ fflush(stderr);
exit(-1);
}
fprintf(stdout, "OK\n");
1.11 +16 -9 apache-apr/apr/test/testsock.c
Index: testsock.c
===================================================================
RCS file: /home/cvs/apache-apr/apr/test/testsock.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- testsock.c 1999/05/26 13:46:58 1.10
+++ testsock.c 1999/05/26 15:45:56 1.11
@@ -58,6 +58,7 @@
#include "apr_thread_proc.h"
#include "apr_errno.h"
#include "apr_general.h"
+#include "apr_lib.h"
#define STRLEN 15
@@ -65,12 +66,13 @@
{
ap_context_t *context;
- ap_procattr_t *attr1;
- ap_procattr_t *attr2;
- ap_proc_t *proc1;
- ap_proc_t *proc2;
+ ap_procattr_t *attr1 = NULL;
+ ap_procattr_t *attr2 = NULL;
+ ap_proc_t *proc1 = NULL;
+ ap_proc_t *proc2 = NULL;
ap_status_t s1;
ap_status_t s2;
+ char *args[2];
fprintf(stdout, "Creating context.......");
if (ap_create_context(NULL, NULL, &context) != APR_SUCCESS) {
@@ -92,18 +94,23 @@
fprintf(stderr, "Problem creating proc attrs\n");
exit(-1);
}
-
- s1 = ap_create_process(context, "server", NULL, NULL, attr1, &proc1);
- s2 = ap_create_process(context, "client", NULL, NULL, attr2, &proc2);
+
+ args[0] = ap_pstrdup(context->pool, "server");
+ args[1] = NULL;
+ s1 = ap_create_process(context, "./server", args, NULL, attr1, &proc1);
+ args[0] = ap_pstrdup(context->pool, "client");
+ s2 = ap_create_process(context, "./client", args, NULL, attr2, &proc2);
+
if (s1 != APR_SUCCESS || s2 != APR_SUCCESS) {
fprintf(stderr, "Problem spawning new process\n");
exit(-1);
}
- while ((s1 = ap_wait_proc(proc1, APR_NOWAIT)) != APR_SUCCESS &&
- (s2 = ap_wait_proc(proc2, APR_NOWAIT)) != APR_SUCCESS)
+ while ((s1 = ap_wait_proc(proc1, APR_NOWAIT)) != APR_CHILD_DONE ||
+ (s2 = ap_wait_proc(proc2, APR_NOWAIT)) != APR_CHILD_DONE) {
continue;
+ }
if (s1 == APR_SUCCESS) {
ap_kill(proc2, SIGTERM);
1.15 +15 -5 apache-apr/apr/threadproc/unix/proc.c
Index: proc.c
===================================================================
RCS file: /home/cvs/apache-apr/apr/threadproc/unix/proc.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- proc.c 1999/05/26 13:47:01 1.14
+++ proc.c 1999/05/26 15:45:57 1.15
@@ -63,6 +63,7 @@
#include <signal.h>
#include <string.h>
#include <sys/wait.h>
+#include <unistd.h>
ap_status_t ap_createprocattr_init(ap_context_t *cont, struct procattr_t **new)
{
@@ -246,15 +247,24 @@
ap_status_t ap_wait_proc(struct proc_t *proc,
ap_wait_how_e wait)
{
+ pid_t stat;
if (!proc)
return APR_ENOPROC;
if (wait == APR_WAIT) {
- if (waitpid(proc->pid, NULL, WUNTRACED) > 0)
- return APR_SUCCESS;
+ if ((stat = waitpid(proc->pid, NULL, WUNTRACED)) > 0) {
+ return APR_CHILD_DONE;
+ }
+ else if (stat == 0) {
+ return APR_CHILD_NOTDONE;
+ }
return errno;
}
- if (waitpid(proc->pid, NULL, WUNTRACED | WNOHANG) > 0)
- return APR_SUCCESS;
- return errno;
+ if ((stat = waitpid(proc->pid, NULL, WUNTRACED | WNOHANG)) > 0) {
+ return APR_CHILD_DONE;
+ }
+ else if (stat == 0) {
+ return APR_CHILD_NOTDONE;
+ }
+ return errno;
}
1.15 +2 -0 apache-apr/include/apr_errno.h
Index: apr_errno.h
===================================================================
RCS file: /home/cvs/apache-apr/include/apr_errno.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- apr_errno.h 1999/05/25 17:04:09 1.14
+++ apr_errno.h 1999/05/26 15:45:58 1.15
@@ -396,6 +396,8 @@
#define APR_INPARENT 5002
#define APR_DETACH 5003
#define APR_NOTDETACH 5004
+#define APR_CHILD_DONE 5005
+#define APR_CHILD_NOTDONE 5006
#ifdef __cplusplus