File: prot-events.rst.txt

package info (click to toggle)
cyrus-imapd 3.12.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 60,540 kB
  • sloc: ansic: 280,382; perl: 146,834; javascript: 9,624; sh: 5,730; yacc: 2,660; cpp: 2,263; makefile: 2,103; lex: 675; xml: 621; awk: 303; python: 273; asm: 262
file content (59 lines) | stat: -rw-r--r-- 2,166 bytes parent folder | download | duplicates (18)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
.. _imap-developer-thoughts-prot-events:

..  Note: This document was converted from the original by Nic Bernstein
    (Onlight).  Any formatting mistakes are my fault and not the
    original author's.  Converted via the pandoc tool from HTML.

Cyrus IMAP Server: Prot Events
==============================

From an email exchange between Ken Murchison and Lawrence Greenfield,
dated 03 Feb 2002 (slightly redacted and formatted for your viewing
pleasure):

|    From: Ken Murchison
|    To: Lawrence Greenfield
|    Subject: Re: prot events
|

    Lawrence Greenfield wrote:

        Can you give me some details on how the event API in the prot
        layer works?  I'm a little unclear about the memory management,
        what should be returned from the event callback,

    Either the event pointer (if the event is still active), or NULL
    (if the event has been removed by the callback).

        and how to reschedule an event.

    Simply set the 'mark' time in the event to the wall time you want
    it to run again.

        (I'd like to make an event called every X seconds of idle time;
        I know the API can't do exactly that but I suspect I can fake
        it well enough.)

    Look at backend_timeout() in proxyd.c and/or drac_ping() in
    contrib/drac_auth.patch, they do exactly this.

    The API is pretty simple:

    *   use prot_addwaitevent() to add an event (linked list) callback
        onto a stream.  takes the stream, the 'mark' time at which to
        run the event (NOT an interval, but the future clock value),
        the function pointer, and a rock to pass to the callback as
        args, and returns a pointer to the event (to use for future
        removal).

    *   use prot_removewaitevent() to remove an event.  takes the
        stream and a pointer to the event as args.

    *   the event callback gets the stream, a pointer to the event
        and the rock as args.  To reschedule an event, simply set the
        'mark' time and return the event pointer.  If the callback
        removes the event, then return NULL.

    If you see and flaws in this API, feel free to go ahead and change it.

    Ken