X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=blobdiff_plain;f=src%2Flibswift%2Fswift.cpp;h=9a7bd89fc1a64f1ca7427886c17d908de3d82597;hb=41816c4e73a12147ee2e83cdb869c9c76cf876ca;hp=c4e5b3bb63598e6022b209f761686ca721ee5ffd;hpb=da188550ca4b16d1f49b0e59938ff93612a6cdbb;p=swifty.git diff --git a/src/libswift/swift.cpp b/src/libswift/swift.cpp index c4e5b3b..9a7bd89 100644 --- a/src/libswift/swift.cpp +++ b/src/libswift/swift.cpp @@ -27,6 +27,7 @@ int OpenSwiftDirectory(const TCHAR* dirname, Address tracker, bool force_check_d void ReportCallback(int fd, short event, void *arg); void EndCallback(int fd, short event, void *arg); void RescanDirCallback(int fd, short event, void *arg); +void TimerCallback(int fd, short event, void *arg); // Gateway stuff @@ -39,7 +40,7 @@ void CmdGwUpdateDLStatesCallback(); // Global variables -struct event evreport, evrescan, evend; +struct event evreport, evrescan, evend, evtimer; int single_fd = -1; bool file_enable_checkpoint = false; bool file_checkpointed = false; @@ -328,6 +329,9 @@ int main (int argc, char** argv) evtimer_add(&evend, tint2tv(wait_time)); } + evtimer_assign(&evtimer, Channel::evbase, TimerCallback, NULL); + evtimer_add(&evtimer, tint2tv(TIMER_USEC)); + // Enter mainloop, if daemonizing if (wait_time == TINT_NEVER || (long)wait_time > 0) { // Arno: always, for statsgw, rate control, etc. @@ -567,6 +571,11 @@ void ReportCallback(int fd, short event, void *arg) { evtimer_add(&evreport, tint2tv(TINT_SEC)); } +void TimerCallback(int fd, short event, void *arg) { + Channel::messageQueue.Flush(); + evtimer_add(&evtimer, tint2tv(TIMER_USEC)); +} + void EndCallback(int fd, short event, void *arg) { // Called when wait timer expires == fixed time daemon event_base_loopexit(Channel::evbase, NULL);