From: Jeff Trawick Date: Tue, 9 Jan 2001 04:40:22 +0000 (+0000) Subject: get rid of some bogus uses of perror() X-Git-Tag: APACHE_2_0_BETA_CANDIDATE_1~246 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b7c731a3259653e155a9f2ca0baa695798c4d7e0;p=apache get rid of some bogus uses of perror() git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87627 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/mpm/dexter/scoreboard.c b/server/mpm/dexter/scoreboard.c index 3bf4869a64..e3cbd9b158 100644 --- a/server/mpm/dexter/scoreboard.c +++ b/server/mpm/dexter/scoreboard.c @@ -99,20 +99,23 @@ apr_status_t ap_cleanup_shared_mem(void *d) static void setup_shared_mem(apr_pool_t *p) { char buf[512]; + char errmsg[120]; const char *fname; + apr_status_t rv; fname = ap_server_root_relative(p, ap_scoreboard_fname); - if (apr_shm_init(&scoreboard_shm, SCOREBOARD_SIZE, fname, p) != APR_SUCCESS) { - apr_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard", - ap_server_argv0); - perror(buf); + rv = apr_shm_init(&scoreboard_shm, SCOREBOARD_SIZE, fname, p); + if (rv != APR_SUCCESS) { + apr_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard: %s", + ap_server_argv0, apr_strerror(rv, errmsg, sizeof errmsg)); + fprintf(stderr, "%s\n", buf); exit(APEXIT_INIT); } ap_scoreboard_image = apr_shm_malloc(scoreboard_shm, SCOREBOARD_SIZE); if (ap_scoreboard_image == NULL) { apr_snprintf(buf, sizeof(buf), "%s: cannot allocate scoreboard", ap_server_argv0); - perror(buf); + perror(buf); /* o.k. since MM sets errno */ apr_shm_destroy(scoreboard_shm); exit(APEXIT_INIT); } diff --git a/server/mpm/mpmt_pthread/scoreboard.c b/server/mpm/mpmt_pthread/scoreboard.c index a2c1905049..d701a11dbf 100644 --- a/server/mpm/mpmt_pthread/scoreboard.c +++ b/server/mpm/mpmt_pthread/scoreboard.c @@ -106,27 +106,31 @@ apr_status_t ap_cleanup_shared_mem(void *d) static void setup_shared_mem(apr_pool_t *p) { char buf[512]; + char errmsg[120]; const char *fname; + apr_status_t rv; fname = ap_server_root_relative(p, ap_scoreboard_fname); - if (apr_shm_init(&scoreboard_shm, SCOREBOARD_SIZE, fname, p) != APR_SUCCESS) { - apr_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard", - ap_server_argv0); - perror(buf); + rv = apr_shm_init(&scoreboard_shm, SCOREBOARD_SIZE, fname, p); + if (rv != APR_SUCCESS) { + apr_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard: %s", + ap_server_argv0, apr_strerror(rv, errmsg, sizeof errmsg)); + fprintf(stderr, "%s\n", buf); exit(APEXIT_INIT); } ap_scoreboard_image = apr_shm_malloc(scoreboard_shm, SCOREBOARD_SIZE); - if (apr_shm_init(&status_shm, NEW_SCOREBOARD_SIZE, fname, p) != APR_SUCCESS) { - apr_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard", - ap_server_argv0); - perror(buf); + rv = apr_shm_init(&status_shm, NEW_SCOREBOARD_SIZE, fname, p); + if (rv != APR_SUCCESS) { + apr_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard: %s", + ap_server_argv0, apr_strerror(rv, errmsg, sizeof errmsg)); + fprintf(stderr, "%s\n", buf); exit(APEXIT_INIT); } ap_new_scoreboard_image = apr_shm_malloc(status_shm, NEW_SCOREBOARD_SIZE); if (ap_scoreboard_image == NULL || ap_new_scoreboard_image == NULL) { apr_snprintf(buf, sizeof(buf), "%s: cannot allocate scoreboard", ap_server_argv0); - perror(buf); + perror(buf); /* o.k. since MM sets errno */ apr_shm_destroy(scoreboard_shm); apr_shm_destroy(status_shm); exit(APEXIT_INIT); diff --git a/server/mpm/perchild/scoreboard.c b/server/mpm/perchild/scoreboard.c index 10b0730ad4..7d2e1de890 100644 --- a/server/mpm/perchild/scoreboard.c +++ b/server/mpm/perchild/scoreboard.c @@ -99,20 +99,23 @@ apr_status_t ap_cleanup_shared_mem(void *d) static void setup_shared_mem(apr_pool_t *p) { char buf[512]; + char errmsg[120]; const char *fname; + apr_status_t rv; fname = ap_server_root_relative(p, ap_scoreboard_fname); - if (apr_shm_init(&scoreboard_shm, SCOREBOARD_SIZE, fname, p) != APR_SUCCESS) { - apr_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard", - ap_server_argv0); - perror(buf); + rv = apr_shm_init(&scoreboard_shm, SCOREBOARD_SIZE, fname, p); + if (rv != APR_SUCCESS) { + apr_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard: %s", + ap_server_argv0, apr_strerror(rv, errmsg, sizeof errmsg)); + fprintf(stderr, "%s\n", buf); exit(APEXIT_INIT); } ap_scoreboard_image = apr_shm_malloc(scoreboard_shm, SCOREBOARD_SIZE); if (ap_scoreboard_image == NULL) { apr_snprintf(buf, sizeof(buf), "%s: cannot allocate scoreboard", ap_server_argv0); - perror(buf); + perror(buf); /* o.k. since MM sets errno */ apr_shm_destroy(scoreboard_shm); exit(APEXIT_INIT); } diff --git a/server/mpm/prefork/prefork.c b/server/mpm/prefork/prefork.c index 85b327e980..af40c85b1b 100644 --- a/server/mpm/prefork/prefork.c +++ b/server/mpm/prefork/prefork.c @@ -337,27 +337,31 @@ static apr_status_t cleanup_shared_mem(void *d) static void setup_shared_mem(apr_pool_t *p) { char buf[512]; + char errmsg[120]; const char *fname; + apr_status_t rv; fname = ap_server_root_relative(p, ap_scoreboard_fname); - if (apr_shm_init(&scoreboard_shm, SCOREBOARD_SIZE, fname, p) != APR_SUCCESS) { - apr_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard", - ap_server_argv0); - perror(buf); + rv = apr_shm_init(&scoreboard_shm, SCOREBOARD_SIZE, fname, p); + if (rv != APR_SUCCESS) { + apr_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard: %s", + ap_server_argv0, apr_strerror(rv, errmsg, sizeof errmsg)); + fprintf(stderr, "%s\n", buf); exit(APEXIT_INIT); } ap_scoreboard_image = apr_shm_malloc(scoreboard_shm, SCOREBOARD_SIZE); - if (apr_shm_init(&status_shm, NEW_SCOREBOARD_SIZE, fname, p) != APR_SUCCESS) { - apr_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard", - ap_server_argv0); - perror(buf); + rv = apr_shm_init(&status_shm, NEW_SCOREBOARD_SIZE, fname, p); + if (rv != APR_SUCCESS) { + apr_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard: %s", + ap_server_argv0, apr_strerror(rv, errmsg, sizeof errmsg)); + fprintf(stderr, "%s\n", buf); exit(APEXIT_INIT); } ap_new_scoreboard_image = apr_shm_malloc(status_shm, NEW_SCOREBOARD_SIZE); if (ap_scoreboard_image == NULL || ap_new_scoreboard_image == NULL) { apr_snprintf(buf, sizeof(buf), "%s: cannot allocate scoreboard", ap_server_argv0); - perror(buf); + perror(buf); /* o.k. since MM sets errno */ apr_shm_destroy(scoreboard_shm); apr_shm_destroy(status_shm); exit(APEXIT_INIT);