~ubuntu-branches/ubuntu/vivid/syslog-ng/vivid-proposed

« back to all changes in this revision

Viewing changes to lib/ivykis/modules/test/iv_event_test.c

  • Committer: Package Import Robot
  • Author(s): Gergely Nagy, Gergely Nagy
  • Date: 2013-11-04 15:27:37 UTC
  • mfrom: (1.3.12)
  • Revision ID: package-import@ubuntu.com-20131104152737-mqh6eqtna2xk97jq
Tags: 3.5.1-1
[ Gergely Nagy <algernon@madhouse-project.org> ]
* New upstream release.
  + Support auto-loading modules (Closes: #650814)
  + The SMTP module is available in syslog-ng-mod-smtp (Closes: #722746)
  + New modules: amqp, geoip, stomp, redis and smtp.
  + Multi-line input support (indented multiline and regexp-based)
  + Template type hinting for the MongoDB destination and $(format-json)
  + Support for unit suffixes in the configuration file
  + New filters, template functions and other miscellaneous changes
* New (team) maintainer, Laszlo Boszormenyi, Attila Szalay and myself
  added to Uploaders.
* Ship /var/lib/syslog-ng in the syslog-ng-core package, instead of
  creating it in the init script. Thanks Michael Biebl
  <biebl@debian.org> for the report & assistance. (Closes: #699942, #719910)
* Use dh-systemd for proper systemd-related maintainer scripts. Based on
  a patch by Michael Biebl <biebl@debian.org>. (Closes: #713982,
  #690067)
* Do not wait for syslog-ng to settle down during installation / update.
  This also fixes installing via debootstrap and a fake
  start-stop-daemon. (Closes: #714254)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * ivykis, an event handling library
3
 
 * Copyright (C) 2010 Lennert Buytenhek
4
 
 * Dedicated to Marija Kulikova.
5
 
 *
6
 
 * This library is free software; you can redistribute it and/or modify
7
 
 * it under the terms of the GNU Lesser General Public License version
8
 
 * 2.1 as published by the Free Software Foundation.
9
 
 *
10
 
 * This library is distributed in the hope that it will be useful,
11
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 * GNU Lesser General Public License version 2.1 for more details.
14
 
 *
15
 
 * You should have received a copy of the GNU Lesser General Public
16
 
 * License version 2.1 along with this library; if not, write to the
17
 
 * Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
18
 
 * Boston, MA 02110-1301, USA.
19
 
 */
20
 
 
21
 
#include <stdio.h>
22
 
#include <stdlib.h>
23
 
#include <iv.h>
24
 
#include <iv_event.h>
25
 
#include <pthread.h>
26
 
#include <unistd.h>
27
 
 
28
 
static struct iv_event ev0;
29
 
static struct iv_timer tim0;
30
 
static struct iv_event ev1;
31
 
static struct iv_timer tim1;
32
 
 
33
 
static void got_ev0(void *_dummy)
34
 
{
35
 
        printf("%p: got ev0, starting tim0\n", (void *)pthread_self());
36
 
 
37
 
        iv_validate_now();
38
 
        tim0.expires = iv_now;
39
 
        tim0.expires.tv_sec++;
40
 
        iv_timer_register(&tim0);
41
 
}
42
 
 
43
 
static void got_tim0(void *_dummy)
44
 
{
45
 
        printf("%p: tim0 expired, signaling ev1\n", (void *)pthread_self());
46
 
 
47
 
        iv_event_post(&ev1);
48
 
}
49
 
 
50
 
static void got_ev1(void *_dummy)
51
 
{
52
 
        printf("%p: got ev1, starting tim1\n", (void *)pthread_self());
53
 
 
54
 
        iv_validate_now();
55
 
        tim1.expires = iv_now;
56
 
        tim1.expires.tv_sec++;
57
 
        iv_timer_register(&tim1);
58
 
}
59
 
 
60
 
static void got_tim1(void *_dummy)
61
 
{
62
 
        printf("%p: tim1 expired, signaling ev0\n", (void *)pthread_self());
63
 
 
64
 
        iv_event_post(&ev0);
65
 
}
66
 
 
67
 
static void *thread1(void *_dummy)
68
 
{
69
 
        iv_init();
70
 
 
71
 
        IV_EVENT_INIT(&ev1);
72
 
        ev1.handler = got_ev1;
73
 
        iv_event_register(&ev1);
74
 
 
75
 
        IV_TIMER_INIT(&tim1);
76
 
        tim1.handler = got_tim1;
77
 
 
78
 
        iv_main();
79
 
 
80
 
        return NULL;
81
 
}
82
 
 
83
 
int main()
84
 
{
85
 
        pthread_t foo;
86
 
 
87
 
        iv_init();
88
 
 
89
 
        IV_EVENT_INIT(&ev0);
90
 
        ev0.handler = got_ev0;
91
 
        iv_event_register(&ev0);
92
 
 
93
 
        IV_TIMER_INIT(&tim0);
94
 
        tim0.handler = got_tim0;
95
 
 
96
 
        pthread_create(&foo, NULL, thread1, NULL);
97
 
 
98
 
        iv_validate_now();
99
 
        tim0.expires = iv_now;
100
 
        tim0.expires.tv_sec++;
101
 
        iv_timer_register(&tim0);
102
 
 
103
 
        iv_main();
104
 
 
105
 
        iv_deinit();
106
 
 
107
 
        return 0;
108
 
}