ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/src/poll.C
(Generate patch)

Comparing ermyth/src/poll.C (file contents):
Revision 1.5 by pippijn, Thu Aug 30 19:56:26 2007 UTC vs.
Revision 1.6 by pippijn, Wed Sep 5 11:23:15 2007 UTC

3 * Rights to this code are documented in doc/pod/license.pod. 3 * Rights to this code are documented in doc/pod/license.pod.
4 * 4 *
5 * Copyright © 2005-2007 Atheme Project (http://www.atheme.org) 5 * Copyright © 2005-2007 Atheme Project (http://www.atheme.org)
6 */ 6 */
7 7
8static char const rcsid[] = "$Id: poll.C,v 1.5 2007/08/30 19:56:26 pippijn Exp $"; 8static char const rcsid[] = "$Id: poll.C,v 1.6 2007/09/05 11:23:15 pippijn Exp $";
9 9
10#include <sys/poll.h> 10#include <sys/poll.h>
11 11
12#include "atheme.h" 12#include "atheme.h"
13#include "internal.h" 13#include "internal.h"
58 * registered sockets are prepared for the poll() loop. 58 * registered sockets are prepared for the poll() loop.
59 */ 59 */
60static void 60static void
61update_poll_fds (void) 61update_poll_fds (void)
62{ 62{
63 connection_vector::iterator it = connlist.begin (); 63 connection_t::list_type::iterator it = connection_t::list.begin ();
64 connection_vector::iterator et = connlist.end (); 64 connection_t::list_type::iterator et = connection_t::list.end ();
65 int slot = 0; 65 int slot = 0;
66 66
67 while (it != et) 67 while (it != et)
68 { 68 {
69 connection_t *cptr = *it; 69 connection_t *cptr = *it;
101 */ 101 */
102void 102void
103connection_t::select (time_t delay) 103connection_t::select (time_t delay)
104{ 104{
105 int sr; 105 int sr;
106 connection_vector::iterator it = connlist.begin (); 106 connection_t::list_type::iterator it = connection_t::list.begin ();
107 connection_vector::iterator et = connlist.end (); 107 connection_t::list_type::iterator et = connection_t::list.end ();
108 int slot; 108 int slot;
109 109
110 update_poll_fds (); 110 update_poll_fds ();
111 111
112 if ((sr = poll (pollfds, connlist.size (), delay / 100)) > 0) 112 if ((sr = poll (pollfds, connection_t::list.size (), delay / 100)) > 0)
113 { 113 {
114 /* Iterate twice, so we don't touch freed memory if 114 /* Iterate twice, so we don't touch freed memory if
115 * a connection is closed. 115 * a connection is closed.
116 * -- jilles */ 116 * -- jilles */
117 while (it != et) 117 while (it != et)
128 pollfds[slot].events &= ~(POLLRDNORM | POLLIN | POLLHUP | POLLERR); 128 pollfds[slot].events &= ~(POLLRDNORM | POLLIN | POLLHUP | POLLERR);
129 cptr->read_handler (cptr); 129 cptr->read_handler (cptr);
130 } 130 }
131 } 131 }
132 132
133 for (it = connlist.begin (), et = connlist.end (); it != et; ++it) 133 for (it = connection_t::list.begin (), et = connection_t::list.end (); it != et; ++it)
134 { 134 {
135 connection_t *cptr = *it; 135 connection_t *cptr = *it;
136 slot = cptr->pollslot; 136 slot = cptr->pollslot;
137 137
138 if (pollfds[slot].revents == 0) 138 if (pollfds[slot].revents == 0)
145 else 145 else
146 cptr->write_handler (cptr); 146 cptr->write_handler (cptr);
147 } 147 }
148 } 148 }
149 149
150 for (it = connlist.begin (), et = connlist.end (); it != et; ++it) 150 for (it = connection_t::list.begin (), et = connection_t::list.end (); it != et; ++it)
151 { 151 {
152 connection_t *cptr = *it; 152 connection_t *cptr = *it;
153 if (cptr->flags & CF_DEAD) 153 if (cptr->flags & CF_DEAD)
154 cptr->close (); 154 cptr->close ();
155 } 155 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines