Skip to content

Commit

Permalink
Merge pull request #263 from jajik/return-500
Browse files Browse the repository at this point in the history
Use defined macro instead of magic contants
  • Loading branch information
jajik authored Aug 12, 2024
2 parents d0714c2 + eef34f7 commit 2c3e759
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions native/include/mod_proxy_cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct balancer_method
* @param r request_rec structure
* @param id ident of the worker
* @param load load factor to set if test is ok
* @return 0: All OK 500 : Error
* @return 0 in case of success, HTTP_INTERNAL_SERVER_ERROR otherwise
*/
int (*proxy_node_isup)(request_rec *r, int id, int load);
/**
Expand All @@ -52,7 +52,7 @@ struct balancer_method
* @param scheme something like ajp, http or https
* @param host the hostname
* @param port the port on which the node connector is running
* @return 0: All OK 500 : Error
* @return 0 in case of success, HTTP_INTERNAL_SERVER_ERROR otherwise
*/
int (*proxy_host_isup)(request_rec *r, const char *scheme, const char *host, const char *port);
/**
Expand Down
6 changes: 3 additions & 3 deletions native/mod_manager/mod_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -3411,7 +3411,7 @@ static int manager_handler(request_rec *r)

if (status != APR_SUCCESS) {
process_error(r, apr_psprintf(r->pool, SREADER, r->method), TYPESYNTAX);
return 500;
return HTTP_INTERNAL_SERVER_ERROR;
}
buff[bufsiz] = '\0';

Expand All @@ -3422,7 +3422,7 @@ static int manager_handler(request_rec *r)
ptr = process_buff(r, buff);
if (ptr == NULL) {
process_error(r, SMESPAR, TYPESYNTAX);
return 500;
return HTTP_INTERNAL_SERVER_ERROR;
}
if (strstr(r->filename, NODE_COMMAND)) {
global = 1;
Expand Down Expand Up @@ -3450,7 +3450,7 @@ static int manager_handler(request_rec *r)
/* Check error string and build the error message */
if (errstring) {
process_error(r, errstring, errtype);
return 500;
return HTTP_INTERNAL_SERVER_ERROR;
}

ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "manager_handler: %s OK", r->method);
Expand Down
18 changes: 9 additions & 9 deletions native/mod_proxy_cluster/mod_proxy_cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -1844,10 +1844,10 @@ static int proxy_node_isup(request_rec *r, int id, int load)
char *ptr;

if (node_storage->read_node(id, &node) != APR_SUCCESS) {
return 500;
return HTTP_INTERNAL_SERVER_ERROR;
}
if (node->mess.remove) {
return 500;
return HTTP_INTERNAL_SERVER_ERROR;
}

/* Calculate the address of our shared memory that corresponds to the stat info of the worker */
Expand Down Expand Up @@ -1875,7 +1875,7 @@ static int proxy_node_isup(request_rec *r, int id, int load)
if (worker == NULL) {
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
"proxy_cluster_isup: Can't find worker for %d. Check balancer names.", id);
return 500;
return HTTP_INTERNAL_SERVER_ERROR;
}

/* Try a ping/pong to check the node */
Expand All @@ -1887,7 +1887,7 @@ static int proxy_node_isup(request_rec *r, int id, int load)
if (worker->s->status & PROXY_WORKER_NOT_USABLE_BITMAP) {
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
"proxy_cluster_isup: health check says PROXY_WORKER_IN_ERROR");
return 500;
return HTTP_INTERNAL_SERVER_ERROR;
}

ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "proxy_cluster_isup: health check says OK");
Expand All @@ -1904,7 +1904,7 @@ static int proxy_node_isup(request_rec *r, int id, int load)
if (proxy_cluster_try_pingpong(r, worker, url, conf, node->mess.ping, node->mess.timeout) != APR_SUCCESS) {
worker->s->status |= PROXY_WORKER_IN_ERROR;
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "proxy_cluster_isup: pingpong %s failed", url);
return 500;
return HTTP_INTERNAL_SERVER_ERROR;
}
}
}
Expand Down Expand Up @@ -1936,27 +1936,27 @@ static int proxy_host_isup(request_rec *r, const char *scheme, const char *host,
rv = apr_socket_create(&sock, APR_INET, SOCK_STREAM, 0, r->pool);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_WARNING, 0, r->server, "proxy_host_isup: pingpong (apr_socket_create) failed");
return 500;
return HTTP_INTERNAL_SERVER_ERROR;
}
rv = apr_sockaddr_info_get(&to, host, APR_INET, nport, 0, r->pool);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_WARNING, 0, r->server,
"proxy_host_isup: pingpong (apr_sockaddr_info_get(%s, %d)) failed", host, nport);
return 500;
return HTTP_INTERNAL_SERVER_ERROR;
}

rv = apr_socket_connect(sock, to);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "proxy_host_isup: pingpong (apr_socket_connect) failed");
return 500;
return HTTP_INTERNAL_SERVER_ERROR;
}

/* XXX: For the moment we support only AJP */
if (strcasecmp(scheme, "AJP") == 0) {
rv = ajp_handle_cping_cpong(sock, r, apr_time_from_sec(10));
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "proxy_host_isup: cping_cpong failed");
return 500;
return HTTP_INTERNAL_SERVER_ERROR;
}
} else {
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, r->server, "proxy_host_isup: %s no yet supported", scheme);
Expand Down

0 comments on commit 2c3e759

Please sign in to comment.