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 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 | * |
… | |
… | |
92 | EV_ACQUIRE_CB; |
92 | EV_ACQUIRE_CB; |
93 | |
93 | |
94 | if (res == -1) |
94 | if (res == -1) |
95 | { |
95 | { |
96 | if (errno != EINTR && errno != ETIME) |
96 | if (errno != EINTR && errno != ETIME) |
97 | ev_syserr ("(libev) port_getn"); |
97 | ev_syserr ("(libev) port_getn (see http://bugs.opensolaris.org/view_bug.do?bug_id=6268715, try LIBEV_FLAGS=3 env variable)"); |
98 | |
98 | |
99 | return; |
99 | return; |
100 | } |
100 | } |
101 | |
101 | |
102 | for (i = 0; i < nget; ++i) |
102 | for (i = 0; i < nget; ++i) |
… | |
… | |
125 | } |
125 | } |
126 | |
126 | |
127 | int inline_size |
127 | int inline_size |
128 | port_init (EV_P_ int flags) |
128 | port_init (EV_P_ int flags) |
129 | { |
129 | { |
130 | /* Initalize the kernel queue */ |
130 | /* Initialize the kernel queue */ |
131 | if ((backend_fd = port_create ()) < 0) |
131 | if ((backend_fd = port_create ()) < 0) |
132 | return 0; |
132 | return 0; |
133 | |
133 | |
134 | fcntl (backend_fd, F_SETFD, FD_CLOEXEC); /* not sure if necessary, hopefully doesn't hurt */ |
134 | fcntl (backend_fd, F_SETFD, FD_CLOEXEC); /* not sure if necessary, hopefully doesn't hurt */ |
135 | |
135 | |
136 | backend_fudge = 1e-3; /* needed to compensate for port_getn returning early */ |
136 | backend_fudge = 1e-3; /* needed to compensate for port_getn returning early */ |
137 | backend_modify = port_modify; |
137 | backend_modify = port_modify; |
138 | backend_poll = port_poll; |
138 | backend_poll = port_poll; |
139 | |
139 | |
140 | port_eventmax = 64; /* intiial number of events receivable per poll */ |
140 | port_eventmax = 64; /* initial number of events receivable per poll */ |
141 | port_events = (port_event_t *)ev_malloc (sizeof (port_event_t) * port_eventmax); |
141 | port_events = (port_event_t *)ev_malloc (sizeof (port_event_t) * port_eventmax); |
142 | |
142 | |
143 | return EVBACKEND_PORT; |
143 | return EVBACKEND_PORT; |
144 | } |
144 | } |
145 | |
145 | |