static int proxy_fdpass2_canon(request_rec *r, char *url)
{
- const char *path, sfx[16];
+ const char *path;
+ char sfx[16];
#if ALTOUT_DEBUG > 1
{
}
/* TODO: In APR 2.x: Extend apr_sockaddr_t to possibly be a path !!! */
-static apr_status_t socket_connect_un(request_rec *r, apr_socket_t *sock,
+static apr_status_t socket_connect_un(apr_socket_t *sock,
struct sockaddr_un *sa)
{
apr_status_t rv;
rv = apr_os_sock_get(&rawsock, sock);
if (rv != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL,
"proxy: FD: apr_os_sock_get failed");
return rv;
}
rv = apr_socket_timeout_get(sock, &t);
if (rv != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL,
"proxy: FD: apr_socket_timeout_get failed");
return rv;
}
/* ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
"proxy: FD: pre_connect"); */
rv = connect(rawsock, (struct sockaddr*)sa,
- sizeof(*sa) /* + strlen(sa->sun_path)*/ );
+ sizeof(*sa) /* + strlen(sa->sun_path)*/ );
/* ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
"proxy: FD: post_connect %d", rv); */
} while (rv == -1 && errno == EINTR);
}
if (rv == -1 && errno != EISCONN) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
- "proxy: FD: socket_connect_un preexit %d", errno);
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL,
+ "proxy: FD: socket_connect_un preexit %d", errno);
return errno;
}
return APR_SUCCESS;
}
-static apr_status_t get_socket_from_path(request_rec *r, apr_pool_t *p,
+static apr_status_t get_socket_from_path(apr_pool_t *p,
const char* path,
apr_socket_t **out_sock)
{
*out_sock = NULL;
/*
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
- "proxy: FD: Failed to connect to '%s' %d xxx",
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL,
+ "proxy: FD: Failed to connect to '%s' %d xxx",
url, rv);
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL,
"proxy: FD: get_socket_from_path::START");
*/
rv = apr_socket_create(&s, AF_UNIX, SOCK_STREAM, 0, p);
if (rv != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL,
"proxy: FD: get_socket_from_path::create %d", rv);
return rv;
}
sa.sun_family = AF_UNIX;
apr_cpystrn(sa.sun_path, path, sizeof(sa.sun_path));
- rv = socket_connect_un(r, s, &sa);
+ rv = socket_connect_un(s, &sa);
if (rv != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL,
"proxy: FD: get_socket_from_path::connect_un %d", rv);
return rv;
}
return errno;
}
-
- return APR_SUCCESS;
-}
-
-static int headers_builder(void *rec, const char *key, const char *value)
-{
- char *s;
-
- s = (char *)rec;
-
-#if ALTOUT_DEBUG > 1
- {
- int mop_fd;
- char mop_bf[512];
-
- mop_fd = open(ALTOUT_DBG_FILE, O_WRONLY | O_APPEND | O_CREAT, 0644);
- sprintf(mop_bf, "HEADERS_BUILDER: [%s:%s]\n", key, value);
- write(mop_fd, mop_bf, strlen(mop_bf));
- close(mop_fd);
- }
-#endif
-
- // TODO: verify length
- // sprintf(s, "%s%s:%s\n", s, key, value);
- strcat(s, key);
- strcat(s, ":");
- strcat(s, value);
- strcat(s, "\n");
-}
-
-#define CTRL_BUFF_MAX_SZ (8*1024)
-
-#define DEFAULT_ENCTYPE "application/x-www-form-urlencoded"
-
-int util_read(request_rec *r, const char **rbuf)
-{
- int rc;
-
- if ((rc = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR)) != OK) {
- return rc;
- }
-
- if (ap_should_client_block(r)) {
- char argsbuffer[HUGE_STRING_LEN];
- int rsize, len_read, rpos=0;
- long length = r->remaining;
- *rbuf = (char *)apr_pcalloc(r->pool, length +1);
- if ((len_read = ap_get_client_block(r, argsbuffer,
- sizeof(argsbuffer))) > 0) {
- if ((rpos + len_read) > length) {
- rsize = length - rpos;
- } else {
- rsize = len_read;
- }
-
- memcpy((char *)*rbuf + rpos, argsbuffer, rsize);
- rpos += rsize;
- }
-
- }
-
- return rc;
-}
-
-int read_post(request_rec *r, const char **data)
-{
- const char *type;
- char *p, s_type[256];
- int rc = OK;
-
- s_type[255] = '\0';
-close(mop_fd);
-#endif
-
- if (rv == -1) {
- return errno;
- }
-
-
- return APR_SUCCESS;
-}
-
-static int headers_builder(void *rec, const char *key, const char *value)
-{
- char *s;
-
- s = (char *)rec;
-
-#if ALTOUT_DEBUG > 1
- {
- int mop_fd;
- char mop_bf[512];
-
- mop_fd = open(ALTOUT_DBG_FILE, O_WRONLY | O_APPEND | O_CREAT, 0644);
- sprintf(mop_bf, "HEADERS_BUILDER: [%s:%s]\n", key, value);
- write(mop_fd, mop_bf, strlen(mop_bf));
- close(mop_fd);
- }
-#endif
-
- // TODO: verify length
- // sprintf(s, "%s%s:%s\n", s, key, value);
- strcat(s, key);
- strcat(s, ":");
- strcat(s, value);
- strcat(s, "\n");
-}
-
-#define CTRL_BUFF_MAX_SZ (8*1024)
-
-#define DEFAULT_ENCTYPE "application/x-www-form-urlencoded"
-
-int util_read(request_rec *r, const char **rbuf)
-{
- int rc;
-
- if ((rc = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR)) != OK) {
- return rc;
- }
-
- if (ap_should_client_block(r)) {
- char argsbuffer[HUGE_STRING_LEN];
- int rsize, len_read, rpos=0;
- long length = r->remaining;
- *rbuf = (char *)apr_pcalloc(r->pool, length +1);
- if ((len_read = ap_get_client_block(r, argsbuffer,
- sizeof(argsbuffer))) > 0) {
- if ((rpos + len_read) > length) {
- rsize = length - rpos;
- } else {
- rsize = len_read;
- }
-
- memcpy((char *)*rbuf + rpos, argsbuffer, rsize);
- rpos += rsize;
- }
-
- }
-
- return rc;
-}
-
-int read_post(request_rec *r, const char **data)
-{
- const char *type;
- char *p, s_type[256];
- int rc = OK;
-
- s_type[255] = '\0';
-close(mop_fd);
-#endif
-
- if (rv == -1) {
- return errno;
- }
-
- return APR_SUCCESS;
-}
-
-static int headers_builder(void *rec, const char *key, const char *value)
-{
- char *s;
-
- s = (char *)rec;
-
-#if ALTOUT_DEBUG > 1
- {
- int mop_fd;
- char mop_bf[512];
-
- mop_fd = open(ALTOUT_DBG_FILE, O_WRONLY | O_APPEND | O_CREAT, 0644);
- sprintf(mop_bf, "HEADERS_BUILDER: [%s:%s]\n", key, value);
- write(mop_fd, mop_bf, strlen(mop_bf));
- close(mop_fd);
- }
-#endif
-
- // TODO: verify length
- // sprintf(s, "%s%s:%s\n", s, key, value);
- strcat(s, key);
- strcat(s, ":");
- strcat(s, value);
- strcat(s, "\n");
-}
-
-#define CTRL_BUFF_MAX_SZ (8*1024)
-
-#define DEFAULT_ENCTYPE "application/x-www-form-urlencoded"
-
-int util_read(request_rec *r, const char **rbuf)
-{
- int rc;
-
- if ((rc = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR)) != OK) {
- return rc;
- }
-
- if (ap_should_client_block(r)) {
- char argsbuffer[HUGE_STRING_LEN];
- int rsize, len_read, rpos=0;
- long length = r->remaining;
- *rbuf = (char *)apr_pcalloc(r->pool, length +1);
- if ((len_read = ap_get_client_block(r, argsbuffer,
- sizeof(argsbuffer))) > 0) {
- if ((rpos + len_read) > length) {
- rsize = length - rpos;
- } else {
- rsize = len_read;
- }
-
- memcpy((char *)*rbuf + rpos, argsbuffer, rsize);
- rpos += rsize;
- }
-
- }
-
- return rc;
-}
-
-int read_post(request_rec *r, const char **data)
-{
- const char *type;
- char *p, s_type[256];
- int rc = OK;
-
- s_type[255] = '\0';
-close(mop_fd);
-#endif
-
- if (rv == -1) {
- return errno;
- }
-
return APR_SUCCESS;
}
return DECLINED;
}
- rv = get_socket_from_path(r, r->pool, url, &sock);
+ rv = get_socket_from_path(r->pool, url, &sock);
#if ALTOUT_DEBUG > 0
- time_t t_cur;
- t_cur = time();
+ long long t_cur;
+ int t_rnd;
+ t_cur = (long long)time(NULL);
t_rnd = rand();
#endif
char mop_bf[512];
mop_fd = open(ALTOUT_DBG_FILE, O_WRONLY | O_APPEND | O_CREAT, 0644);
- sprintf(mop_bf, "%d: (%d) proxy_fdpass2_handler: start\n", t_cur, t_rnd);
+ sprintf(mop_bf, "%lld: (%d) proxy_fdpass2_handler: start\n", t_cur, t_rnd);
write(mop_fd, mop_bf, strlen(mop_bf));
close(mop_fd);
}
}
rv = apr_os_sock_put(&ctrlsock, &(ctrlrawsock[0]), r->connection->pool);
if (rv != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01152)
"proxy: FD: apr_os_sock_put failed");
return HTTP_INTERNAL_SERVER_ERROR;
}
rv = apr_os_sock_put(&clientctrlsock, &(ctrlrawsock[1]), r->connection->pool);
if (rv != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01152)
"proxy: FD: apr_os_sock_put failed");
return HTTP_INTERNAL_SERVER_ERROR;
}
{
int status;
- /* const char *flush_method = worker->flusher ? worker->flusher : "flush"; */
+ /* const char *flush_method = worker->s->flusher ? worker->s->flusher : "flush"; */
const char *flush_method = "flush";
proxy_fdpass2_flush *flush = ap_lookup_provider(PROXY_FDPASS_FLUSHER,
- flush_method, "0");
+ flush_method, "0");
if (!flush) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01153)
"proxy: FD: Unable to find configured flush "
"provider '%s'", flush_method);
return HTTP_INTERNAL_SERVER_ERROR;
/* XXXXX: THIS IS AN EVIL HACK */
/* There should really be a (documented) public API for this ! */
- clientsock = ap_get_module_config(r->connection->conn_config, &core_module);
+ /* oldmop clientsock = ap_get_module_config(r->connection->conn_config, &core_module); */
+ clientsock = ap_get_core_module_config(r->connection->conn_config);
+
rv = send_socket(r->pool, sock, clientsock, clientctrlsock);
if (rv != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01154)
"proxy: FD: send_socket failed:");
return HTTP_INTERNAL_SERVER_ERROR;
}
}
}
apr_socket_shutdown(ctrlsock, APR_SHUTDOWN_READWRITE);
- if (headers_out)
+ if (headers_out) {
free(headers_out);
+ }
{
apr_socket_t *dummy;
rv = apr_socket_create(&dummy, APR_INET, SOCK_STREAM, APR_PROTO_TCP,
r->connection->pool);
if (rv != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(01155)
"proxy: FD: failed to create dummy socket");
return HTTP_INTERNAL_SERVER_ERROR;
}
- ap_set_module_config(r->connection->conn_config, &core_module, dummy);
+ ap_set_core_module_config(r->connection->conn_config, dummy);
}
#if ALTOUT_DEBUG > 0
char mop_bf[512];
mop_fd = open(ALTOUT_DBG_FILE, O_WRONLY | O_APPEND | O_CREAT, 0644);
- sprintf(mop_bf, "%d: (%d) proxy_fdpass2_handler: end\n", t_cur, t_rnd);
+ sprintf(mop_bf, "%lld: (%d) proxy_fdpass2_handler: end\n", t_cur, t_rnd);
write(mop_fd, mop_bf, strlen(mop_bf));
close(mop_fd);
}
#endif
+ /* close socket pair before end proxy */
+ close(ctrlrawsock[0]);
+ close(ctrlrawsock[1]);
return OK;
}
status = ap_pass_brigade(r->output_filters, bb);
if (status != OK) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r,
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, APLOGNO(01156)
"proxy: FD: ap_pass_brigade failed:");
return status;
}
+#if ALTOUT_DEBUG > 0
+ long long t_cur;
+ int t_rnd;
+ t_cur = (long long)time(NULL);
+ t_rnd = rand();
+#endif
+
+#if ALTOUT_DEBUG > 0
+ {
+ int mop_fd;
+ char mop_bf[512];
+
+ mop_fd = open(ALTOUT_DBG_FILE, O_WRONLY | O_APPEND | O_CREAT, 0644);
+ sprintf(mop_bf, "%lld: (%d) proxy_fdpass2_handler: flusher\n", t_cur, t_rnd);
+ write(mop_fd, mop_bf, strlen(mop_bf));
+ close(mop_fd);
+ }
+#endif
+
return OK;
}