Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

git-svn-id: svn://cherokee-project.com/cherokee/trunk@370 5dc97367-97…

…f1-0310-9951-d761b3857238
  • Loading branch information...
commit 423d6fa8d6112bdf6f1be74c42be83b4f44edc36 1 parent 4ec2fcc
@alobbs alobbs authored
View
4 cherokee/Makefile.am
@@ -812,7 +812,9 @@ nonce.c \
ext_source.h \
ext_source.c \
config_node.h \
-config_node.c
+config_node.c \
+balancer.h \
+balancer.c
libcherokee_config_la_SOURCES = \
$(config_common) \
View
11 cherokee/handler.c
@@ -52,16 +52,9 @@ cherokee_handler_init_base (cherokee_handler_t *hdl, void *conn, cherokee_handle
}
-ret_t
-cherokee_handler_free_base (cherokee_handler_t *hdl)
-{
- free (hdl);
- return ret_ok;
-}
-
-
-/* Virtual method hidding layer
+/* Virtual method hidding layer
*/
+
ret_t
cherokee_handler_free (cherokee_handler_t *hdl)
{
View
1  cherokee/handler.h
@@ -67,7 +67,6 @@ typedef struct {
*/
typedef ret_t (* handler_func_new_t) (void **handler, void *cnt, cherokee_handler_props_t *properties);
typedef ret_t (* handler_func_init_t) (void *handler);
-typedef ret_t (* handler_func_free_t) (void *handler);
typedef ret_t (* handler_func_step_t) (void *handler, cherokee_buffer_t *buffer);
typedef ret_t (* handler_func_add_headers_t) (void *handler, cherokee_buffer_t *buffer);
View
2  cherokee/handler_cgi.c
@@ -120,7 +120,7 @@ cherokee_handler_cgi_new (cherokee_handler_t **hdl, void *cnt, cherokee_handler
/* Virtual methods
*/
MODULE(n)->init = (handler_func_init_t) cherokee_handler_cgi_init;
- MODULE(n)->free = (handler_func_free_t) cherokee_handler_cgi_free;
+ MODULE(n)->free = (module_func_free_t) cherokee_handler_cgi_free;
/* Virtual methods: implemented by handler_cgi_base
*/
View
2  cherokee/handler_error.c
@@ -43,7 +43,7 @@ cherokee_handler_error_new (cherokee_handler_t **hdl, cherokee_connection_t *cnt
HANDLER(n)->support = hsupport_error | hsupport_length;
MODULE(n)->init = (handler_func_init_t) cherokee_handler_error_init;
- MODULE(n)->free = (handler_func_free_t) cherokee_handler_error_free;
+ MODULE(n)->free = (module_func_free_t) cherokee_handler_error_free;
HANDLER(n)->step = (handler_func_step_t) cherokee_handler_error_step;
HANDLER(n)->add_headers = (handler_func_add_headers_t) cherokee_handler_error_add_headers;
View
2  cherokee/handler_fastcgi.c
@@ -242,7 +242,7 @@ cherokee_handler_fastcgi_new (cherokee_handler_t **hdl, void *cnt, cherokee_hand
/* Virtual methods
*/
MODULE(n)->init = (handler_func_init_t) cherokee_handler_fastcgi_init;
- MODULE(n)->free = (handler_func_free_t) cherokee_handler_fastcgi_free;
+ MODULE(n)->free = (module_func_free_t) cherokee_handler_fastcgi_free;
/* Virtual methods: implemented by handler_cgi_base
*/
View
2  cherokee/handler_fcgi.c
@@ -255,7 +255,7 @@ cherokee_handler_fcgi_new (cherokee_handler_t **hdl, void *cnt, cherokee_handler
/* Virtual methods
*/
MODULE(n)->init = (handler_func_init_t) cherokee_handler_fcgi_init;
- MODULE(n)->free = (handler_func_free_t) cherokee_handler_fcgi_free;
+ MODULE(n)->free = (module_func_free_t) cherokee_handler_fcgi_free;
/* Virtual methods: implemented by handler_cgi_base
*/
View
2  cherokee/handler_redir.c
@@ -211,7 +211,7 @@ cherokee_handler_redir_new (cherokee_handler_t **hdl, void *cnt, cherokee_handle
cherokee_handler_init_base(HANDLER(n), cnt, props);
MODULE(n)->init = (handler_func_init_t) cherokee_handler_redir_init;
- MODULE(n)->free = (handler_func_free_t) cherokee_handler_redir_free;
+ MODULE(n)->free = (module_func_free_t) cherokee_handler_redir_free;
HANDLER(n)->add_headers = (handler_func_add_headers_t) cherokee_handler_redir_add_headers;
HANDLER(n)->connection = cnt;
View
2  cherokee/handler_remote_control.c
@@ -46,7 +46,7 @@ cherokee_handler_remote_control_new (cherokee_handler_t **hdl, cherokee_connecti
cherokee_handler_init_base(HANDLER(n), cnt);
MODULE(n)->init = (handler_func_init_t) cherokee_handler_remote_control_init;
- MODULE(n)->free = (handler_func_free_t) cherokee_handler_remote_control_free;
+ MODULE(n)->free = (module_func_free_t) cherokee_handler_remote_control_free;
HANDLER(n)->step = (handler_func_step_t) cherokee_handler_remote_control_step;
HANDLER(n)->add_headers = (handler_func_add_headers_t) cherokee_handler_remote_control_add_headers;
View
2  cherokee/handler_scgi.c
@@ -157,7 +157,7 @@ cherokee_handler_scgi_new (cherokee_handler_t **hdl, void *cnt, cherokee_handler
/* Virtual methods
*/
MODULE(n)->init = (handler_func_init_t) cherokee_handler_scgi_init;
- MODULE(n)->free = (handler_func_free_t) cherokee_handler_scgi_free;
+ MODULE(n)->free = (module_func_free_t) cherokee_handler_scgi_free;
/* Virtual methods: implemented by handler_cgi_base
*/
View
2  cherokee/handler_server_info.c
@@ -405,7 +405,7 @@ cherokee_handler_server_info_new (cherokee_handler_t **hdl, cherokee_connection
cherokee_handler_init_base(HANDLER(n), cnt, props);
MODULE(n)->init = (handler_func_init_t) cherokee_handler_server_info_init;
- MODULE(n)->free = (handler_func_free_t) cherokee_handler_server_info_free;
+ MODULE(n)->free = (module_func_free_t) cherokee_handler_server_info_free;
HANDLER(n)->step = (handler_func_step_t) cherokee_handler_server_info_step;
HANDLER(n)->add_headers = (handler_func_add_headers_t) cherokee_handler_server_info_add_headers;
View
2  cherokee/handler_webcam.c
@@ -38,7 +38,7 @@ cherokee_handler_webcam_new (cherokee_handler_t **hdl, void *cnt, cherokee_table
HANDLER(n)->support = hsupport_length;
MODULE(n)->init = (handler_func_init_t) cherokee_handler_webcam_init;
- MODULE(n)->free = (handler_func_free_t) cherokee_handler_webcam_free;
+ MODULE(n)->free = (module_func_free_t) cherokee_handler_webcam_free;
HANDLER(n)->step = (handler_func_step_t) cherokee_handler_webcam_step;
HANDLER(n)->add_headers = (handler_func_add_headers_t) cherokee_handler_webcam_add_headers;
View
12 cherokee/md5crypt.c
@@ -164,17 +164,17 @@ md5_crypt(const char *pw, const char *salt, const char *magic, char passwd[MD5CR
p = passwd + strlen(passwd);
l = (final[ 0]<<16) | (final[ 6]<<8) | final[12];
- strlcat(passwd, to64(l, 4), MD5CRYPT_PASSWD_LEN);
+ cherokee_strlcat(passwd, to64(l, 4), MD5CRYPT_PASSWD_LEN);
l = (final[ 1]<<16) | (final[ 7]<<8) | final[13];
- strlcat(passwd, to64(l, 4), MD5CRYPT_PASSWD_LEN);
+ cherokee_strlcat(passwd, to64(l, 4), MD5CRYPT_PASSWD_LEN);
l = (final[ 2]<<16) | (final[ 8]<<8) | final[14];
- strlcat(passwd, to64(l, 4), MD5CRYPT_PASSWD_LEN);
+ cherokee_strlcat(passwd, to64(l, 4), MD5CRYPT_PASSWD_LEN);
l = (final[ 3]<<16) | (final[ 9]<<8) | final[15];
- strlcat(passwd, to64(l, 4), MD5CRYPT_PASSWD_LEN);
+ cherokee_strlcat(passwd, to64(l, 4), MD5CRYPT_PASSWD_LEN);
l = (final[ 4]<<16) | (final[10]<<8) | final[ 5];
- strlcat(passwd, to64(l, 4), MD5CRYPT_PASSWD_LEN);
+ cherokee_strlcat(passwd, to64(l, 4), MD5CRYPT_PASSWD_LEN);
l = final[11] ;
- strlcat(passwd, to64(l, 2), MD5CRYPT_PASSWD_LEN);
+ cherokee_strlcat(passwd, to64(l, 2), MD5CRYPT_PASSWD_LEN);
/* Don't leave anything around in vm they could use.
*/
View
90 cherokee/socket.c
@@ -948,12 +948,47 @@ cherokee_socket_read (cherokee_socket_t *socket, cherokee_buffer_t *buf, size_t
ret_t
cherokee_socket_sendfile (cherokee_socket_t *socket, int fd, size_t size, off_t *offset, ssize_t *sent)
{
-#ifndef HAVE_SENDFILE
- SHOULDNT_HAPPEN;
- return ret_error;
-#else
+#if defined(LINUX_SENDFILE_API) || defined(HAVE_SENDFILE64)
-# ifdef FREEBSD_SENDFILE_API
+ /* Linux sendfile
+ *
+ * ssize_t
+ * sendfile (int out_fd, int in_fd, off_t *offset, size_t *count);
+ *
+ * ssize_t
+ * sendfile64 (int out_fd, int in_fd, off64_t *offset, size_t *count);
+ */
+ do {
+ *sent = sendfile (SOCKET_FD(socket), /* int out_fd */
+ fd, /* int in_fd */
+ offset, /* off_t *offset */
+ size); /* size_t count */
+ } while ((*sent == -1) && (errno == EINTR));
+
+ if (*sent < 0) {
+ switch (errno) {
+ case ENOSYS: return ret_no_sys;
+ case EAGAIN: return ret_eagain;
+ }
+
+ return ret_error;
+ }
+
+
+#elif HAVE_SENDFILE_BROKEN
+
+ /* Some Linux 2.4 kernels doesn't support sendfile in a LFS
+ * environment.
+ */
+ return ret_no_sys;
+
+#elif SOLARIS_SENDFILE_API
+
+ /* TODO!!
+ */
+ return ret_no_sys;
+
+#elif FREEBSD_SENDFILE_API
int re;
struct sf_hdtr hdr;
struct iovec hdtrl;
@@ -992,7 +1027,7 @@ cherokee_socket_sendfile (cherokee_socket_t *socket, int fd, size_t size, off_t
}
*offset = *offset + *sent;
-# elif HPUX_SENDFILE_API
+#elif HPUX_SENDFILE_API
/* HP-UX:
*
@@ -1021,49 +1056,12 @@ cherokee_socket_sendfile (cherokee_socket_t *socket, int fd, size_t size, off_t
}
*offset = *offset + *sent;
-# elif SOLARIS_SENDFILE_API
-
- /* TODO!!
- */
- return ret_no_sys;
-
-# elif HAVE_SENDFILE_BROKEN
-
- /* Some Linux 2.4 kernels doesn't support sendfile in a LFS environment
- */
- return ret_no_sys;
-
-# elif LINUX_SENDFILE_API
-
- /* Linux sendfile
- *
- * ssize_t
- * sendfile (int out_fd, int in_fd, off_t *offset, size_t *count);
- */
- do {
- *sent = sendfile (SOCKET_FD(socket), /* int out_fd */
- fd, /* int in_fd */
- offset, /* off_t *offset */
- size); /* size_t count */
- } while ((*sent == -1) && (errno == EINTR));
-
- if (*sent < 0) {
- switch (errno) {
- case ENOSYS: return ret_no_sys;
- case EAGAIN: return ret_eagain;
- }
-
- return ret_error;
- }
-
-# else
+#else
SHOULDNT_HAPPEN;
- return ret_no_sys;
-# endif
+ return ret_error;
+#endif
return ret_ok;
-
-#endif /* HAVE_SENDFILE */
}
View
57 cherokee/util.c
@@ -271,34 +271,57 @@ strcasestr (register char *s, register char *find)
#endif
-/* strlcat():
- * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
/* Appends src to string dst of size siz (unlike strncat, siz is the
* full size of dst, not space left). At most siz-1 characters
* will be copied. Always NUL terminates (unless siz <= strlen(dst)).
* Returns strlen(src) + MIN(siz, strlen(initial dst)).
* If retval >= siz, truncation occurred.
*/
+size_t
+cherokee_strlcat (char *dst, const char *src, size_t siz)
+{
+#ifdef HAVE_STRLCAT
+ return strlcat (dst, src, siz);
+#else
+ /* The following few lines has been copy and pasted from Todd
+ * C. Miller <Todd.Miller@courtesan.com> code. BSD licensed.
+ */
+ register char *d = dst;
+ register const char *s = src;
+ register size_t n = siz;
+ size_t dlen;
+
+ /* Find the end of dst and adjust bytes left but do not go
+ * past end.
+ */
+ while (n-- != 0 && *d != '\0')
+ d++;
+ dlen = d - dst;
+ n = siz - dlen;
+
+ if (n == 0)
+ return(dlen + strlen(s));
+ while (*s != '\0') {
+ if (n != 1) {
+ *d++ = *s;
+ n--;
+ }
+ s++;
+ }
+ *d = '\0';
+
+ /* Count does not include NUL
+ */
+ return(dlen + (s - src));
+#endif
+}
+
#ifndef HAVE_STRLCAT
size_t
strlcat (char *dst, const char *src, size_t siz)
{
- register char *d = dst;
+ register char *d = dst;
register const char *s = src;
register size_t n = siz;
size_t dlen;
View
17 cherokee/util.h
@@ -67,11 +67,12 @@ ret_t cherokee_tls_init (void);
/* String management functions
*/
-int cherokee_hexit (char c);
-int cherokee_isbigendian (void);
-char *cherokee_min_str (char *s1, char *s2);
-char *cherokee_strfsize (unsigned long long size, char *buf);
-int cherokee_estimate_va_length (char *format, va_list ap);
+int cherokee_hexit (char c);
+int cherokee_isbigendian (void);
+char *cherokee_min_str (char *s1, char *s2);
+char *cherokee_strfsize (unsigned long long size, char *buf);
+size_t cherokee_strlcat (char *dst, const char *src, size_t siz);
+int cherokee_estimate_va_length (char *format, va_list ap);
/* Time management functions
*/
@@ -82,9 +83,9 @@ long *cherokee_get_timezone_ref (void);
/* Thread safe functions
*/
-int cherokee_readdir (DIR *dirstream, struct dirent *entry, struct dirent **result);
-ret_t cherokee_gethostbyname (const char *hostname, void *addr);
-ret_t cherokee_syslog (int priority, cherokee_buffer_t *buf);
+int cherokee_readdir (DIR *dirstream, struct dirent *entry, struct dirent **result);
+ret_t cherokee_gethostbyname (const char *hostname, void *addr);
+ret_t cherokee_syslog (int priority, cherokee_buffer_t *buf);
/* Misc
*/
View
12 configure.in
@@ -457,6 +457,18 @@ dnl Check for vsyslog
dnl
AC_CHECK_FUNCS(syslog vsyslog strsep strcasestr memmove strerror bcopy strlcat)
+dnl
+dnl Check for Glib (usually Linux)
+dnl
+AC_PREPROC_IFELSE([
+#include <features.h>
+#ifndef __GLIBC__
+ chokeme
+#endif
+], [
+ AC_DEFINE([HAVE_GLIBC], [1], [Define to 1 if you have glibc.])
+ AC_DEFINE([_GNU_SOURCE], [1], [Define to 1 if you have glibc.])
+])
dnl
dnl Does this platform require array notation to assign to a va_list?
View
2  qa/run-tests.py
@@ -181,7 +181,7 @@
os.execl (server, name, "-C", cfg_file)
else:
print "PID: %d - %s" % (pid, CHEROKEE_PATH)
- time.sleep(3)
+ time.sleep(7)
its_clean = False
def clean_up():
Please sign in to comment.
Something went wrong with that request. Please try again.