diff options
author | Christian Pointner <equinox@helsinki.at> | 2009-11-19 17:54:40 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2009-11-19 17:54:40 (GMT) |
commit | c704199bb4a1ba50961be03d586e162593909549 (patch) | |
tree | b599188843a00d8f46297ab494d6eee81475f217 /rhdropbox.c | |
parent | e3dea264db4f4d0edd093114a52f9a52da163407 (diff) |
got rid of useless cmd_q
Diffstat (limited to 'rhdropbox.c')
-rw-r--r-- | rhdropbox.c | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/rhdropbox.c b/rhdropbox.c index f5de265..b12ee16 100644 --- a/rhdropbox.c +++ b/rhdropbox.c @@ -30,12 +30,14 @@ #include "sig_handler.h" #include "options.h" -#include "command_queue.h" #include "client_list.h" #include "daemon.h" #include "utils.h" +enum cmd_id_enum { ADD, REMOVE, STATUS, LOG, LISTEN }; +typedef enum cmd_id_enum cmd_id_t; + int send_response(int fd, const char* response) { if(!response) @@ -95,11 +97,11 @@ void process_cmd_listen(const char* param, int fd, client_t* client_lst) } } -int process_cmd(const char* cmd, int fd, cmd_t **cmd_q, client_t* client_lst, options_t* opt) +int process_cmd(const char* cmd, int fd, client_t* client_lst, options_t* opt) { log_printf(DEBUG, "processing command from %d", fd); - if(!cmd_q || !cmd) + if(!cmd) return -1; cmd_id_t cmd_id; @@ -167,7 +169,6 @@ int main_loop(int cmd_listen_fd, options_t* opt) FD_ZERO(&readfds); FD_SET(cmd_listen_fd, &readfds); int max_fd = cmd_listen_fd; - cmd_t* cmd_q = NULL; client_t* client_lst = NULL; read_buffer_t switch_buffer; @@ -180,28 +181,17 @@ int main_loop(int cmd_listen_fd, options_t* opt) max_fd = (max_fd < sig_fd) ? sig_fd : max_fd; int return_value = 0; - struct timeval timeout; while(!return_value) { memcpy(&tmpfds, &readfds, sizeof(tmpfds)); - timeout.tv_sec = 0; - timeout.tv_usec = 200000; - int ret = select(max_fd+1, &tmpfds, NULL, NULL, &timeout); + int ret = select(max_fd+1, &tmpfds, NULL, NULL, NULL); if(ret == -1 && errno != EINTR) { log_printf(ERROR, "select returned with error: %s", strerror(errno)); return_value = -1; break; } - if(ret == -1) + if(ret == -1 || !ret) continue; - if(!ret) { - if(cmd_q && cmd_has_expired(*cmd_q)) { - log_printf(ERROR, "last command expired"); - cmd_pop(&cmd_q); - } - else - continue; - } if(FD_ISSET(sig_fd, &tmpfds)) { if(signal_handle()) { @@ -227,7 +217,7 @@ int main_loop(int cmd_listen_fd, options_t* opt) client_t* lst = client_lst; while(lst) { if(FD_ISSET(lst->fd, &tmpfds)) { - return_value = nonblock_recvline(&(lst->buffer), lst->fd, &cmd_q, client_lst, opt); + return_value = nonblock_recvline(&(lst->buffer), lst->fd, client_lst, opt); if(return_value == 2) { log_printf(DEBUG, "removing closed command connection (fd=%d)", lst->fd); client_t* deletee = lst; @@ -245,7 +235,6 @@ int main_loop(int cmd_listen_fd, options_t* opt) } } - cmd_clear(&cmd_q); client_clear(&client_lst); signal_stop(); return return_value; |