echo
echo "Checking dependencies"
- @echo "====================="
+ echo "====================="
echo
messages_$lang "7"
check_lib lang
echo
- @echo "Creating Makefiles and scripts"
- @echo "=============================="
+ echo "Creating Makefiles and scripts"
+ echo "=============================="
echo
messages_$lang "1"
all: ../bin/monkey
../bin/monkey: \$(OBJ)
- echo "Compiling Monkey"
- echo "================"
+ @echo "Compiling Monkey"
+ @echo "================"
\$(CC) \$(CFLAGS) \$(LIBS) \$(LDFLAGS) -o \$@ \$(OBJ) $mod_obj
$STRIP ../bin/monkey
- echo
- printf "Compiling Plugins"
- echo "================="
+ @echo
+ @echo "Compiling Plugins"
+ @echo "================="
@(cd plugins && make all && cd ..)
clean:
#include "monkey.h"
#include "socket.h"
+#include "clock.h"
+#include "request.h"
+#include "config.h"
+#include "scheduler.h"
#include "epoll.h"
#define MAX_EVENTS 5000
void *mk_epoll_init(int efd, mk_epoll_calls *calls, int max_events)
{
int i, ret=-1;
+ int num_fds;
+ int fds_timeout;
+ struct epoll_event events[max_events];
+ struct request_idx *req_idx;
+ struct client_request *req_cl;
pthread_mutex_lock(&mutex_wait_register);
pthread_mutex_unlock(&mutex_wait_register);
+ fds_timeout = log_current_utime + config->timeout;
+
while(1){
- struct epoll_event events[max_events];
- int num_fds = epoll_wait(efd, events, max_events, -1);
+ num_fds = epoll_wait(efd, events,
+ max_events, MK_EPOLL_WAIT_TIMEOUT);
- for(i=0; i< num_fds; i++) {
+ for(i=0; i<num_fds; i++) {
// Case 1: Error condition
if (events[i].events & (EPOLLHUP | EPOLLERR)) {
close(events[i].data.fd);
close(events[i].data.fd);
}
}
+
+ /* Check timeouts */
+ if(log_current_utime >= fds_timeout){
+ /* Update next timeout */
+ fds_timeout = log_current_utime + config->timeout;
+
+ req_idx = mk_sched_get_request_index();
+ req_cl = req_idx->first;
+
+ while(req_cl){
+ if(req_cl->status == MK_REQUEST_STATUS_INCOMPLETE){
+ if(req_cl->init_time +
+ config->timeout >= log_current_utime){
+ close(req_cl->socket);
+ }
+ }
+ req_cl = req_cl->next;
+ }
+ }
+
}
}
* later
*/
if(mk_method_post_content_length(cr->body) < 0){
+ cr->status = MK_REQUEST_STATUS_COMPLETED;
return 0;
}
}
else{
+ cr->status = MK_REQUEST_STATUS_COMPLETED;
return 0;
}
}
}
}
+ cr->status = MK_REQUEST_STATUS_COMPLETED;
return 0;
}
#define MK_EPOLL_WRITE 1
#define MK_EPOLL_RW 2
+#define MK_EPOLL_WAIT_TIMEOUT 3000
+
#define MK_EPOLL_BEHAVIOR_DEFAULT 2
#define MK_EPOLL_BEHAVIOR_TRIGGERED 3
#define MAX_REQUEST_PROTOCOL 10
#define MAX_SCRIPTALIAS 3
+#define MK_REQUEST_STATUS_INCOMPLETE -1
+#define MK_REQUEST_STATUS_COMPLETED 0
+
#define EXIT_NORMAL -1
#define EXIT_PCONNECTION 24
config->file_config=0;
opterr = 0;
- while ((opt = getopt(argc, argv, "bDSvhc:")) != -1)
+ while ((opt = getopt(argc, argv, "DSvhc:")) != -1)
{
switch (opt) {
case 'v':
cr->pipelined = FALSE;
cr->counter_connections = 0;
cr->socket = socket;
- cr->request = NULL;
-
+ cr->status = MK_REQUEST_STATUS_INCOMPLETE;
+ cr->request = NULL;
+
mk_pointer_set(&cr->ip, mk_socket_get_ip(socket));
/* creation time in unix time */