hi,
Please find attached a work-in-progress patch for Monkey git building on
FreeBSD. This patch includes the 201505120-1 patch.
If you would like separate git commit emails I can provide those. I am
not a big github user and have not looked at the support it offers.
This patch fixes the issues with linking on FreeBSD. The configure
script is now clean with FreeBSD's default /bin/sh and I have changed
the message a little ready for RTEMS to added. :)
The build info is:
ruru monkey.git $ ./build/src/monkey --build
Monkey HTTP Server v1.6.0
Built : May 12 2015 09:51:36 (/usr/bin/cc 4.2.1)
Home : http://monkey-project.com
[system: FreeBSD]
FreeBSD-10.1-RELEASE-p6
[configure]
[setup]
configuration dir: /usr/local/etc/monkey/
I am not sure how I am to run it from within the git repo. I also think
it will fail given the warnings I posted in the last email.
Chris
diff --git a/configure b/configure
index 31e1b95..583e55c 100755
--- a/configure
+++ b/configure
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
#
# Monkey HTTP Server
# ==================
@@ -17,12 +17,19 @@
# limitations under the License.
#
-BOLD="\033[1m"
-END_COLOR="\033[0m"
-GREEN="\033[0;32m"
-YELLOW="\033[1;33m"
-RED="\033[0;31m"
-BLUE="\033[0;34m"
+if [ "x$(uname)" = "xLinux" ]; then
+ BOLD="\033[1m"
+ END_COLOR="\033[0m"
+ GREEN="\033[0;32m"
+ YELLOW="\033[1;33m"
+ RED="\033[0;31m"
+ BLUE="\033[0;34m"
+ ECHO_OPTS="-en"
+ ECHO_LF="\n"
+else
+ ECHO_OPTS=""
+ ECHO_LF=""
+fi
#---------------------------#
# Starting configure
@@ -175,20 +182,22 @@ for arg in $*; do
esac
done
-echo -en $RED"********************************************\n"
-echo -en $RED"*"$GREEN$BOLD" Monkey HTTP Server
"$RED"*\n"
-echo -en $RED"*"$YELLOW" monkey-project.com "$RED"*\n"
-echo -en "*"$BLUE" ---------------------------------------- "$RED"*\n"
-echo -en "*"$YELLOW" Monkey is the next generation "$RED"*\n"
-echo -en "*"$YELLOW" Web Server for Linux and Embedded Linux "$RED"*\n"
-echo -en "*"$YELLOW" "$RED"*\n"
-echo -en "*"$YELLOW" Feel free to reach us at: "$RED"*\n"
-echo -en "*"$YELLOW" "$RED"*\n"
-echo -en "*"$YELLOW" irc.freenode.net #monkey "$RED"*\n"
-echo -en "*"$YELLOW" "$RED"*\n"
-echo -en "*"$YELLOW" Thanks for using Monkey!!! "$RED"*\n"
-echo -en "*"$YELLOW" "$RED"*\n"
-echo -en "********************************************"$END_COLOR"\n"
+echo $ECHO_OPTS $RED"********************************************"$ECHO_LF
+echo $ECHO_OPTS $RED"*"$GREEN$BOLD" Monkey HTTP Server
"$RED"*"$ECHO_LF
+echo $ECHO_OPTS $RED"*"$YELLOW" monkey-project.com
"$RED"*"$ECHO_LF
+echo $ECHO_OPTS "*"$BLUE" ----------------------------------------
"$RED"*"$ECHO_LF
+echo $ECHO_OPTS "*"$YELLOW" Monkey is the next generation
"$RED"*"$ECHO_LF
+echo $ECHO_OPTS "*"$YELLOW" Web Server for Unix and Embedded Unix
"$RED"*"$ECHO_LF
+echo $ECHO_OPTS "*"$YELLOW" Supports Linux, FreeBSD, and MacOS
"$RED"*"$ECHO_LF
+echo $ECHO_OPTS "*"$YELLOW"
"$RED"*"$ECHO_LF
+echo $ECHO_OPTS "*"$YELLOW" Feel free to reach us at:
"$RED"*"$ECHO_LF
+echo $ECHO_OPTS "*"$YELLOW"
"$RED"*"$ECHO_LF
+echo $ECHO_OPTS "*"$YELLOW" irc.freenode.net #monkey
"$RED"*"$ECHO_LF
+echo $ECHO_OPTS "*"$YELLOW"
"$RED"*"$ECHO_LF
+echo $ECHO_OPTS "*"$YELLOW" Thanks for using Monkey!!!
"$RED"*"$ECHO_LF
+echo $ECHO_OPTS "*"$YELLOW"
"$RED"*"$ECHO_LF
+echo $ECHO_OPTS
"********************************************"$END_COLOR$ECHO_LF
+echo $ECHO_OPTS "Build: $(uname)"$ECHO_LF
cd build/
rm -rf CMakeCache.txt
diff --git a/include/monkey/mk_event_kqueue.h b/include/monkey/mk_event_kqueue.h
index d5c398b..840c543 100644
--- a/include/monkey/mk_event_kqueue.h
+++ b/include/monkey/mk_event_kqueue.h
@@ -59,7 +59,6 @@ static inline int filter_mask(int16_t f)
#define mk_event_foreach(event, evl) \
int __i; \
struct mk_event_ctx *ctx = evl->data; \
- struct mk_event_fd_state *st = NULL; \
\
if (evl->n_events > 0) { \
event = ctx->events[0].udata; \
diff --git a/plugins/liana/liana.c b/plugins/liana/liana.c
index 7b08ab1..1185415 100644
--- a/plugins/liana/liana.c
+++ b/plugins/liana/liana.c
@@ -169,6 +169,20 @@ int mk_liana_send_file(int socket_fd, int file_fd, off_t
*file_offset,
return len;
}
return ret;
+#elif defined (__FreeBSD__)
+ off_t offset = *file_offset;
+ off_t len = (off_t) file_count;
+
+ ret = sendfile(file_fd, socket_fd, offset, len, NULL, 0, 0);
+ if (ret == -1 && errno != EAGAIN) {
+ PLUGIN_TRACE("[FD %i] error from sendfile(): %s",
+ socket_fd, strerror(errno));
+ }
+ else if (len > 0) {
+ *file_offset += len;
+ return len;
+ }
+ return ret;
#else
#error Sendfile not supported on platform
#endif
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 5b8c562..92c015d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -27,7 +27,13 @@ set(src
)
add_executable(monkey ${src})
-target_link_libraries(monkey dl ${CMAKE_THREAD_LIBS_INIT}
${STATIC_PLUGINS_LIBS})
+if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ target_link_libraries(monkey dl)
+endif()
+if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
+ target_link_libraries(monkey execinfo)
+endif()
+target_link_libraries(monkey ${CMAKE_THREAD_LIBS_INIT} ${STATIC_PLUGINS_LIBS})
if(NOT WITH_SYSTEM_MALLOC)
target_link_libraries(monkey libjemalloc ${CMAKE_THREAD_LIBS_INIT})
diff --git a/src/mk_event_kqueue.c b/src/mk_event_kqueue.c
index 73fb8b8..e95a04d 100644
--- a/src/mk_event_kqueue.c
+++ b/src/mk_event_kqueue.c
@@ -166,7 +166,13 @@ static inline int _mk_event_timeout_create(struct
mk_event_ctx *ctx,
event->type = MK_EVENT_NOTIFICATION;
event->mask = MK_EVENT_EMPTY;
- EV_SET(&ke, fd, EVFILT_TIMER, EV_ADD, NOTE_SECONDS, expire, event);
+#if defined(NOTE_SECONDS)
+ #define _EV_FFLAGS NOTE_SECONDS
+#else
+ #define _EV_FFLAGS 0
+#endif
+
+ EV_SET(&ke, fd, EVFILT_TIMER, EV_ADD, _EV_FFLAGS, expire, event);
ret = kevent(ctx->kfd, &ke, 1, NULL, 0, NULL);
if (ret < 0) {
close(fd);
diff --git a/src/mk_plugin.c b/src/mk_plugin.c
index f3a9518..45fb20d 100644
--- a/src/mk_plugin.c
+++ b/src/mk_plugin.c
@@ -615,6 +615,7 @@ int mk_plugin_event_add(int socket, int mode,
struct mk_sched_worker *sched;
struct plugin_event *event;
struct mk_list *list;
+ (void) mode;
(void) behavior;
sched = mk_sched_get_thread_conf();
diff --git a/src/mk_socket.c b/src/mk_socket.c
index 84d6fb0..0834ecd 100644
--- a/src/mk_socket.c
+++ b/src/mk_socket.c
@@ -32,6 +32,7 @@
#include <time.h>
#include <netinet/tcp.h>
+#include <sys/socket.h>
static void mk_socket_safe_event_write(int socket)
{
@@ -51,10 +52,10 @@ int mk_socket_set_cork_flag(int fd, int state)
{
MK_TRACE("Socket, set Cork Flag FD %i to %s", fd, (state ? "ON" : "OFF"));
-#if defined (__linux__)
+#if defined (TCP_CORK)
return setsockopt(fd, SOL_TCP, TCP_CORK, &state, sizeof(state));
-#elif defined (__APPLE__)
- return setsockopt(fd, SOL_TCP, TCP_NOPUSH, &state, sizeof(state));
+#elif defined (TCP_NOPUSH)
+ return setsockopt(fd, SOL_SOCKET, TCP_NOPUSH, &state, sizeof(state));
#endif
}
@@ -96,7 +97,15 @@ int mk_socket_set_tcp_nodelay(int sockfd)
{
int on = 1;
+#if defined (SOL_TCP)
return setsockopt(sockfd, SOL_TCP, TCP_NODELAY, &on, sizeof(on));
+#eif defined (SOL_SOCKET)
+ return setsockopt(sockfd, SOL_SOCKET, TCP_NODELAY, &on, sizeof(on));
+#else
+ (void) sockfd;
+ (void) on;
+ return 0;
+#endif
}
int mk_socket_set_tcp_defer_accept(int sockfd)
_______________________________________________
Monkey mailing list
[email protected]
http://lists.monkey-project.com/listinfo/monkey