diff options
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -10,6 +10,7 @@ #include "command.h" #include "conn_data.h" #include "db.h" +#include "net.h" #include "runloop.h" #include "user_data.h" @@ -111,7 +112,7 @@ static bool server_socket_callback(int fd){ do sock=accept(fd,NULL,NULL); while(sock<0&&errno==EINTR); if(sock<0)die_perror("accept"); - runloop_add_fd(sock,client_socket_callback); + runloop_add_fd(sock,client_socket_callback,true); struct hash_item *item=malloc(1,struct hash_item); conn_data_init(&item->cd,sock); @@ -121,6 +122,11 @@ static bool server_socket_callback(int fd){ return false; } +static bool timeout_callback(int fd){ + net_send_raw_text(fd,"_push ping\n",11); + return false; // We aren't going to get closure info from a send() +} + #ifndef __APPLE__ void srandomdev(void){ FILE *f=fopen("/dev/urandom","r"); @@ -139,7 +145,9 @@ int main(void){ db_init(); int sock=create_server_socket(); printf("Listening on port %d\n",PORT); - runloop_add_fd(sock,server_socket_callback); + runloop_set_timeout(60*1000000,timeout_callback); + runloop_add_fd(sock,server_socket_callback,false); runloop_run(); + printf("Runloop empty, shutting down\n"); db_close(); } |