ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev_port.c
(Generate patch)

Comparing libev/ev_port.c (file contents):
Revision 1.5 by root, Fri Nov 23 19:13:33 2007 UTC vs.
Revision 1.8 by root, Wed Dec 5 13:54:37 2007 UTC

1/* 1/*
2 * libev solaris event port backend
3 *
2 * Copyright 2007 Marc Alexander Lehmann <libev@schmorp.de> 4 * Copyright (c) 2007 Marc Alexander Lehmann <libev@schmorp.de>
5 * All rights reserved.
3 * 6 *
4 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions are
6 * are met: 9 * met:
7 * 10 *
8 * 1. Redistributions of source code must retain the above copyright 11 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 14 * * Redistributions in binary form must reproduce the above
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 15 * copyright notice, this list of conditions and the following
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 16 * disclaimer in the documentation and/or other materials provided
17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 17 * with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 30 */
25 31
26#include <sys/types.h> 32#include <sys/types.h>
27#include <sys/time.h> 33#include <sys/time.h>
28#include <poll.h> 34#include <poll.h>
95 } 101 }
96 102
97 if (expect_false (nget == port_eventmax)) 103 if (expect_false (nget == port_eventmax))
98 { 104 {
99 ev_free (port_events); 105 ev_free (port_events);
100 port_eventmax = array_roundsize (port_event_t, port_eventmax << 1); 106 port_eventmax = array_nextsize (sizeof (port_event_t), port_eventmax, port_eventmax + 1);
101 port_events = (port_event_t *)ev_malloc (sizeof (port_event_t) * port_eventmax); 107 port_events = (port_event_t *)ev_malloc (sizeof (port_event_t) * port_eventmax);
102 } 108 }
103} 109}
104 110
105static int 111int inline_size
106port_init (EV_P_ int flags) 112port_init (EV_P_ int flags)
107{ 113{
108 /* Initalize the kernel queue */ 114 /* Initalize the kernel queue */
109 if ((backend_fd = port_create ()) < 0) 115 if ((backend_fd = port_create ()) < 0)
110 return 0; 116 return 0;
119 port_events = (port_event_t *)ev_malloc (sizeof (port_event_t) * port_eventmax); 125 port_events = (port_event_t *)ev_malloc (sizeof (port_event_t) * port_eventmax);
120 126
121 return EVBACKEND_PORT; 127 return EVBACKEND_PORT;
122} 128}
123 129
124static void 130void inline_size
125port_destroy (EV_P) 131port_destroy (EV_P)
126{ 132{
127 close (backend_fd);
128
129 ev_free (port_events); 133 ev_free (port_events);
130} 134}
131 135
132static void 136void inline_size
133port_fork (EV_P) 137port_fork (EV_P)
134{ 138{
135 close (backend_fd); 139 close (backend_fd);
136 140
137 while ((backend_fd = port_create ()) < 0) 141 while ((backend_fd = port_create ()) < 0)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines