Skip to content
This repository has been archived by the owner on Nov 19, 2022. It is now read-only.

Commit

Permalink
Added MONO_IOMAP support
Browse files Browse the repository at this point in the history
svn path=/trunk/mod_mono/; revision=128841
  • Loading branch information
grendello committed Mar 8, 2009
1 parent e94ea41 commit 26683ad
Show file tree
Hide file tree
Showing 5 changed files with 335 additions and 29 deletions.
39 changes: 21 additions & 18 deletions configure.in
Expand Up @@ -10,6 +10,23 @@ if test "x$ac_cv_c_bigendian" = "xyes" ; then
AC_DEFINE([MODMONO_BIGENDIAN],,[Compiling on a big-endian machine.])
fi

AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
if test "x$PKG_CONFIG" = "xno"; then
AC_MSG_ERROR([You need to install pkg-config])
fi

PKG_PATH=""
AC_ARG_WITH(crosspkgdir, [ --with-crosspkgdir=/path/to/pkg-config/dir],
if test x$with_crosspkgdir = "x"; then
if test -s $PKG_CONFIG_PATH; then
PKG_PATH=$PKG_CONFIG_PATH
fi
else
PKG_PATH=$with_crosspkgdir
PKG_CONFIG_PATH=$PKG_PATH
export PKG_CONFIG_PATH
fi
)

# Checks for header files.
AC_HEADER_SYS_WAIT
Expand All @@ -27,6 +44,10 @@ AC_HEADER_STDC
AC_FUNC_SELECT_ARGTYPES
AC_CHECK_FUNCS([memset mkdir unsetenv putenv setenv setrlimit select strcasecmp strerror strrchr dup2])

GLIB_REQUIRED_VERSION=1.3.11

PKG_CHECK_MODULES(GLIB_DEPENDENCIES, glib-2.0 >= $GLIB_REQUIRED_VERSION)

#
# --enable-debug
#
Expand Down Expand Up @@ -358,24 +379,6 @@ if test "x$enable_gcov" = "xyes" ; then
CFLAGS="$CFLAGS -DGCOV -O0 -fprofile-arcs -ftest-coverage"
fi

AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
if test "x$PKG_CONFIG" = "xno"; then
AC_MSG_ERROR([You need to install pkg-config])
fi

PKG_PATH=
AC_ARG_WITH(crosspkgdir, [ --with-crosspkgdir=/path/to/pkg-config/dir],
if test x$with_crosspkgdir = "x"; then
if test -s $PKG_CONFIG_PATH; then
PKG_PATH=$PKG_CONFIG_PATH
fi
else
PKG_PATH=$with_crosspkgdir
PKG_CONFIG_PATH=$PKG_PATH
export PKG_CONFIG_PATH
fi
)

AM_CONDITIONAL(APACHE2, true)

dnl Sources are recompiled if we change the target version
Expand Down
6 changes: 3 additions & 3 deletions src/Makefile.am
@@ -1,10 +1,10 @@
CLEANFILES = .libs/libmod_mono.so .libs/libmod_mono_old.so *~

lib_LTLIBRARIES = mod_mono.la
mod_mono_la_SOURCES = mod_mono.c mod_mono.h
mod_mono_la_LDFLAGS = -module
mod_mono_la_SOURCES = mod_mono.c mod_mono.h mono-io-portability.c mono-io-portability.h
mod_mono_la_LDFLAGS = -module $(GLIB_DEPENDENCIES_LIBS)
#/usr/sbin/apxs -c -I../include -I. -D HAVE_CONFIG_H mod_mono.c
mod_mono_la_CFLAGS = -Wall -DDFLT_MONO_CONFIG_DIR=\"$(DFLT_MONO_CONFIG_DIR)\"
mod_mono_la_CFLAGS = -Wall -DDFLT_MONO_CONFIG_DIR=\"$(DFLT_MONO_CONFIG_DIR)\" $(GLIB_DEPENDENCIES_CFLAGS)

install: $(lib_LTLIBRARIES)
$(mkinstalldirs) "$(DESTDIR)$(APXS_LIBEXECDIR)"
Expand Down
42 changes: 34 additions & 8 deletions src/mod_mono.c
Expand Up @@ -40,6 +40,7 @@

#include <stdlib.h>
#include "mod_mono.h"
#include "mono-io-portability.h"

DEFINE_MODULE (mono_module);

Expand Down Expand Up @@ -110,6 +111,7 @@ typedef struct xsp_data {
char *max_memory;
char *debug;
char *env_vars;
char *iomap;
char status; /* One of the FORK_* in the enum above.
* Don't care if run_xsp is "false" */
char is_virtual; /* is the server virtual? */
Expand All @@ -125,6 +127,7 @@ typedef struct xsp_data {

/* other settings */
unsigned char no_flush;
int portability_level;

/* The dashboard */
apr_shm_t *dashboard_shm;
Expand Down Expand Up @@ -563,6 +566,8 @@ add_xsp_server (apr_pool_t *pool, const char *alias, module_cfg *config, int is_
server->max_memory = NULL;
server->debug = NULL;
server->env_vars = NULL;
server->iomap = NULL;
server->portability_level = PORTABILITY_UNKNOWN;
server->status = FORK_NONE;
server->is_virtual = is_virtual;
server->start_attempts = NULL;
Expand Down Expand Up @@ -910,7 +915,7 @@ read_data_string (apr_pool_t *pool, apr_socket_t *sock, char **ptr, int32_t *siz
}

static int
send_entire_file (request_rec *r, const char *filename, int *result)
send_entire_file (request_rec *r, const char *filename, int *result, xsp_data *xsp)
{
#ifdef APR_LARGEFILE
# define MODMONO_LARGE APR_LARGEFILE
Expand All @@ -922,30 +927,39 @@ send_entire_file (request_rec *r, const char *filename, int *result)
apr_finfo_t info;
apr_size_t nbytes;
const apr_int32_t flags = APR_READ | APR_SENDFILE_ENABLED | MODMONO_LARGE;
int retval = 0;
gchar *file_path = mono_portability_find_file (xsp->portability_level, filename, TRUE);

st = apr_file_open (&file, filename, flags, APR_OS_DEFAULT, r->pool);
st = apr_file_open (&file, file_path ? file_path : filename, flags, APR_OS_DEFAULT, r->pool);
if (st != APR_SUCCESS) {
DEBUG_PRINT (2, "file_open FAILED");
DEBUG_PRINT (2, "file_open FAILED (path: %s)", file_path ? file_path : filename);
*result = HTTP_FORBIDDEN;
return -1;
retval = -1;
goto finish;
}

st = apr_file_info_get (&info, APR_FINFO_SIZE, file);
if (st != APR_SUCCESS) {
DEBUG_PRINT (2, "info_get FAILED");
*result = HTTP_FORBIDDEN;
return -1;
retval = -1;
goto finish;
}

st = ap_send_fd (file, r, 0, info.size, &nbytes);
apr_file_close (file);
if (nbytes < 0) {
DEBUG_PRINT (2, "SEND FAILED");
*result = HTTP_INTERNAL_SERVER_ERROR;
return -1;
retval = -1;
goto finish;
}

return 0;
finish:
if (file_path)
g_free (file_path);

return retval;
}

static int
Expand Down Expand Up @@ -1169,7 +1183,7 @@ do_command (int command, apr_socket_t *sock, request_rec *r, int *result, xsp_da
status = -1;
break;
}
status = send_entire_file (r, str, result);
status = send_entire_file (r, str, result, xsp);
if (status == -1)
error_message = "failed to send file (file data)";
break;
Expand Down Expand Up @@ -1512,6 +1526,9 @@ fork_mod_mono_server (apr_pool_t *pool, xsp_data *config)

set_environment_variables (pool, config->env_vars);

if (config->iomap && *config->iomap)
SETENV (pool, "MONO_IOMAP", config->iomap);

pid = fork ();
if (pid > 0) {
wait (&status);
Expand Down Expand Up @@ -2129,6 +2146,11 @@ mono_execute_request (request_rec *r, char auto_app)
}
}

if (conf->portability_level > PORTABILITY_MAX)
conf->portability_level = PORTABILITY_UNKNOWN;

mono_portability_helpers_init (&conf->portability_level, conf->iomap);

rv = -1; /* avoid a warning about uninitialized value */
retrying = connect_attempts;
was_starting = 0;
Expand Down Expand Up @@ -2847,6 +2869,10 @@ static const command_rec mono_cmds [] = {
" Default value: Default: \"\""
),

MAKE_CMD12 (MonoIOMAP, iomap,
"A string with format the same as the MONO_IOMAP variable (see mod_mono (1))."
" Default value: none"),

MAKE_CMD_ITERATE2 (AddMonoApplications, applications,
"Appends an application."
),
Expand Down

0 comments on commit 26683ad

Please sign in to comment.