1 | /* |
1 | /* |
2 | * libev solaris event port backend |
2 | * libev solaris event port backend |
3 | * |
3 | * |
4 | * Copyright (c) 2007 Marc Alexander Lehmann <libev@schmorp.de> |
4 | * Copyright (c) 2007,2008 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 | * |
… | |
… | |
57 | ) |
57 | ) |
58 | { |
58 | { |
59 | if (errno == EBADFD) |
59 | if (errno == EBADFD) |
60 | fd_kill (EV_A_ fd); |
60 | fd_kill (EV_A_ fd); |
61 | else |
61 | else |
62 | syserr ("(libev) port_associate"); |
62 | ev_syserr ("(libev) port_associate"); |
63 | } |
63 | } |
64 | } |
64 | } |
65 | |
65 | |
66 | static void |
66 | static void |
67 | port_modify (EV_P_ int fd, int oev, int nev) |
67 | port_modify (EV_P_ int fd, int oev, int nev) |
… | |
… | |
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 | if (expect_false (suspend_cb)) suspend_cb (EV_A); |
88 | ts.tv_sec = (time_t)timeout; |
89 | ts.tv_sec = (time_t)timeout; |
89 | ts.tv_nsec = (long)(timeout - (ev_tstamp)ts.tv_sec) * 1e9; |
90 | ts.tv_nsec = (long)(timeout - (ev_tstamp)ts.tv_sec) * 1e9; |
90 | res = port_getn (backend_fd, port_events, port_eventmax, &nget, &ts); |
91 | res = port_getn (backend_fd, port_events, port_eventmax, &nget, &ts); |
|
|
92 | if (expect_false (resume_cb)) resume_cb (EV_A); |
91 | |
93 | |
92 | if (res < 0) |
94 | if (res == -1) |
93 | { |
95 | { |
94 | if (errno != EINTR && errno != ETIME) |
96 | if (errno != EINTR && errno != ETIME) |
95 | syserr ("(libev) port_getn"); |
97 | ev_syserr ("(libev) port_getn"); |
96 | |
98 | |
97 | return; |
99 | return; |
98 | } |
100 | } |
99 | |
101 | |
100 | for (i = 0; i < nget; ++i) |
102 | for (i = 0; i < nget; ++i) |
… | |
… | |
151 | port_fork (EV_P) |
153 | port_fork (EV_P) |
152 | { |
154 | { |
153 | close (backend_fd); |
155 | close (backend_fd); |
154 | |
156 | |
155 | while ((backend_fd = port_create ()) < 0) |
157 | while ((backend_fd = port_create ()) < 0) |
156 | syserr ("(libev) port"); |
158 | ev_syserr ("(libev) port"); |
157 | |
159 | |
158 | fcntl (backend_fd, F_SETFD, FD_CLOEXEC); |
160 | fcntl (backend_fd, F_SETFD, FD_CLOEXEC); |
159 | |
161 | |
160 | /* re-register interest in fds */ |
162 | /* re-register interest in fds */ |
161 | fd_rearm_all (EV_A); |
163 | fd_rearm_all (EV_A); |