OLD | NEW |
1 /* | 1 /* |
2 * Submitted by David Pacheco (dp.spambait@gmail.com) | 2 * Submitted by David Pacheco (dp.spambait@gmail.com) |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 int ed_pending[EVENTS_PER_GETN]; /* fd's with pending events */ | 115 int ed_pending[EVENTS_PER_GETN]; /* fd's with pending events */ |
116 }; | 116 }; |
117 | 117 |
118 static void* evport_init (struct event_base *); | 118 static void* evport_init (struct event_base *); |
119 static int evport_add (void *, struct event *); | 119 static int evport_add (void *, struct event *); |
120 static int evport_del (void *, struct event *); | 120 static int evport_del (void *, struct event *); |
121 static int evport_dispatch (struct event_base *, void *, struct timeval *); | 121 static int evport_dispatch (struct event_base *, void *, struct timeval *); |
122 static void evport_dealloc (struct event_base *, void *); | 122 static void evport_dealloc (struct event_base *, void *); |
123 | 123 |
124 const struct eventop evportops = { | 124 const struct eventop evportops = { |
125 » "event ports", | 125 » "evport", |
126 evport_init, | 126 evport_init, |
127 evport_add, | 127 evport_add, |
128 evport_del, | 128 evport_del, |
129 evport_dispatch, | 129 evport_dispatch, |
130 evport_dealloc, | 130 evport_dealloc, |
131 1 /* need reinit */ | 131 1 /* need reinit */ |
132 }; | 132 }; |
133 | 133 |
134 /* | 134 /* |
135 * Initialize the event port implementation. | 135 * Initialize the event port implementation. |
136 */ | 136 */ |
137 | 137 |
138 static void* | 138 static void* |
139 evport_init(struct event_base *base) | 139 evport_init(struct event_base *base) |
140 { | 140 { |
141 struct evport_data *evpd; | 141 struct evport_data *evpd; |
142 int i; | 142 int i; |
143 /* | 143 /* |
144 * Disable event ports when this environment variable is set | 144 * Disable event ports when this environment variable is set |
145 */ | 145 */ |
146 » if (getenv("EVENT_NOEVPORT")) | 146 » if (evutil_getenv("EVENT_NOEVPORT")) |
147 return (NULL); | 147 return (NULL); |
148 | 148 |
149 if (!(evpd = calloc(1, sizeof(struct evport_data)))) | 149 if (!(evpd = calloc(1, sizeof(struct evport_data)))) |
150 return (NULL); | 150 return (NULL); |
151 | 151 |
152 if ((evpd->ed_port = port_create()) == -1) { | 152 if ((evpd->ed_port = port_create()) == -1) { |
153 free(evpd); | 153 free(evpd); |
154 return (NULL); | 154 return (NULL); |
155 } | 155 } |
156 | 156 |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 struct evport_data *evpd = arg; | 504 struct evport_data *evpd = arg; |
505 | 505 |
506 evsignal_dealloc(base); | 506 evsignal_dealloc(base); |
507 | 507 |
508 close(evpd->ed_port); | 508 close(evpd->ed_port); |
509 | 509 |
510 if (evpd->ed_fds) | 510 if (evpd->ed_fds) |
511 free(evpd->ed_fds); | 511 free(evpd->ed_fds); |
512 free(evpd); | 512 free(evpd); |
513 } | 513 } |
OLD | NEW |