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.12 by root, Wed Oct 29 06:32:48 2008 UTC vs.
Revision 1.22 by root, Sat Oct 16 00:59:56 2010 UTC

1/* 1/*
2 * libev solaris event port backend 2 * libev solaris event port backend
3 * 3 *
4 * Copyright (c) 2007,2008 Marc Alexander Lehmann <libev@schmorp.de> 4 * Copyright (c) 2007,2008,2009,2010 Marc Alexander Lehmann <libev@schmorp.de>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without modifica- 7 * Redistribution and use in source and binary forms, with or without modifica-
8 * tion, are permitted provided that the following conditions are met: 8 * tion, are permitted provided that the following conditions are met:
9 * 9 *
83{ 83{
84 int res, i; 84 int res, i;
85 struct timespec ts; 85 struct timespec ts;
86 uint_t nget = 1; 86 uint_t nget = 1;
87 87
88 ts.tv_sec = (time_t)timeout; 88 EV_RELEASE_CB;
89 ts.tv_nsec = (long)(timeout - (ev_tstamp)ts.tv_sec) * 1e9; 89 EV_TS_SET (ts, timeout);
90 res = port_getn (backend_fd, port_events, port_eventmax, &nget, &ts); 90 res = port_getn (backend_fd, port_events, port_eventmax, &nget, &ts);
91 EV_ACQUIRE_CB;
91 92
92 if (res < 0) 93 if (res == -1)
93 { 94 {
94 if (errno != EINTR && errno != ETIME) 95 if (errno != EINTR && errno != ETIME)
95 ev_syserr ("(libev) port_getn"); 96 ev_syserr ("(libev) port_getn (see http://bugs.opensolaris.org/view_bug.do?bug_id=6268715, try LIBEV_FLAGS=3 env variable)");
96 97
97 return; 98 return;
98 } 99 }
99 100
100 for (i = 0; i < nget; ++i) 101 for (i = 0; i < nget; ++i)
108 fd, 109 fd,
109 (port_events [i].portev_events & (POLLOUT | POLLERR | POLLHUP) ? EV_WRITE : 0) 110 (port_events [i].portev_events & (POLLOUT | POLLERR | POLLHUP) ? EV_WRITE : 0)
110 | (port_events [i].portev_events & (POLLIN | POLLERR | POLLHUP) ? EV_READ : 0) 111 | (port_events [i].portev_events & (POLLIN | POLLERR | POLLHUP) ? EV_READ : 0)
111 ); 112 );
112 113
113 port_associate_and_check (EV_A_ fd, anfds [fd].events); 114 fd_change (EV_A_ fd, EV__IOFDSET);
114 } 115 }
115 } 116 }
116 117
117 if (expect_false (nget == port_eventmax)) 118 if (expect_false (nget == port_eventmax))
118 { 119 {
123} 124}
124 125
125int inline_size 126int inline_size
126port_init (EV_P_ int flags) 127port_init (EV_P_ int flags)
127{ 128{
128 /* Initalize the kernel queue */ 129 /* Initialize the kernel queue */
129 if ((backend_fd = port_create ()) < 0) 130 if ((backend_fd = port_create ()) < 0)
130 return 0; 131 return 0;
131 132
132 fcntl (backend_fd, F_SETFD, FD_CLOEXEC); /* not sure if necessary, hopefully doesn't hurt */ 133 fcntl (backend_fd, F_SETFD, FD_CLOEXEC); /* not sure if necessary, hopefully doesn't hurt */
133 134
134 backend_fudge = 1e-3; /* needed to compensate for port_getn returning early */ 135 backend_fudge = 1e-3; /* needed to compensate for port_getn returning early */
135 backend_modify = port_modify; 136 backend_modify = port_modify;
136 backend_poll = port_poll; 137 backend_poll = port_poll;
137 138
138 port_eventmax = 64; /* intiial number of events receivable per poll */ 139 port_eventmax = 64; /* initial number of events receivable per poll */
139 port_events = (port_event_t *)ev_malloc (sizeof (port_event_t) * port_eventmax); 140 port_events = (port_event_t *)ev_malloc (sizeof (port_event_t) * port_eventmax);
140 141
141 return EVBACKEND_PORT; 142 return EVBACKEND_PORT;
142} 143}
143 144

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines