ioloop.c revision e2588872c1fe79642589b805aaab9fbb6750771b
1968N/A/* Copyright (c) 2002-2016 Dovecot authors, see the included COPYING file */ 1968N/A /* we're adding an istream whose only way to get notified 2616N/A is to call i_stream_set_input_pending() */ 2301N/A /* if we got here from an I/O handler callback, make sure we 2301N/A don't try to handle this one next. */ 1968N/A /* make sure the callback doesn't get called anymore. 1968N/A kqueue code relies on this. */ 1978N/A /* remove io before it's freed */ 2301N/A /* remove io from the ioloop before unreferencing the istream, 2301N/A because a destroyed istream may automatically close the 2301N/A /* we don't want microsecond accuracy or this function will be 2301N/A called all the time - millisecond is more than enough */ 2301N/A /* start this timeout in the next run cycle */ 2301N/A /* trigger zero timeouts as soon as possible */ 2142N/A /* if we came here from io_loop_handle_timeouts(), 2142N/A next_run must be larger than tv_now or we could go to 2142N/A infinite loop. +1000 to get 1 ms further, another +1000 to 2142N/A account for timeout_update_next()'s truncation. */ 2028N/A /* round wait times up to next millisecond */ 1968N/A /* no timeouts. use INT_MAX msecs for timeval and 1968N/A /* update ioloop_timeval - this is meant for io_loop_handle_timeouts()'s 1968N/A ioloop_wait_usecs calculation. normally after this we go to the 1968N/A ioloop and after that we update ioloop_timeval immediately again. */ 1968N/A /* Don't bother comparing usecs. */ 1968N/A /* the callback may have slept, so check the time again. */ 2028N/A /* use tv_call to make sure we don't get to infinite loop in 2028N/A case callbacks update ioloop_timeval. */ 2510N/A /* remove timeout from queue */ 2028N/A /* update timeout's next_run and reposition it in the queue */ 2028N/A /* recursive io_loop_run() isn't allowed for the same ioloop. 2028N/A /* ->prev won't work unless loops are destroyed in create order */ 2693N/A /* cur_ctx itself keeps a reference */ 2510N/A /* simply mark it as deleted, since we could get 2616N/A i_panic(
"io_loop_context_remove_callbacks() context not found");
2510N/A /* we just added this callback. don't deactivate it 2510N/A before it gets first activated. */ 1968N/A /* reference before io_remove() */ 2132N/A /* update istream io after it was removed with io_remove() */