ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/IO-AIO/AIO.xs
(Generate patch)

Comparing IO-AIO/AIO.xs (file contents):
Revision 1.22 by root, Tue Aug 16 22:22:18 2005 UTC vs.
Revision 1.25 by root, Wed Aug 17 03:16:56 2005 UTC

31 REQ_QUIT, 31 REQ_QUIT,
32 REQ_OPEN, REQ_CLOSE, 32 REQ_OPEN, REQ_CLOSE,
33 REQ_READ, REQ_WRITE, REQ_READAHEAD, 33 REQ_READ, REQ_WRITE, REQ_READAHEAD,
34 REQ_STAT, REQ_LSTAT, REQ_FSTAT, 34 REQ_STAT, REQ_LSTAT, REQ_FSTAT,
35 REQ_FSYNC, REQ_FDATASYNC, 35 REQ_FSYNC, REQ_FDATASYNC,
36 REQ_UNLINK, REQ_RMDIR, REQ_SYMLINK, 36 REQ_UNLINK, REQ_RMDIR,
37 REQ_SYMLINK, 37 REQ_SYMLINK,
38}; 38};
39 39
40typedef struct aio_cb { 40typedef struct aio_cb {
41 struct aio_cb *volatile next; 41 struct aio_cb *volatile next;
86static int 86static int
87poll_cb () 87poll_cb ()
88{ 88{
89 dSP; 89 dSP;
90 int count = 0; 90 int count = 0;
91 int do_croak = 0;
91 aio_req req, prv; 92 aio_req req, prv;
92 93
93 pthread_mutex_lock (&reslock); 94 pthread_mutex_lock (&reslock);
94 95
95 { 96 {
158 PUTBACK; 159 PUTBACK;
159 call_sv (req->callback, G_VOID | G_EVAL); 160 call_sv (req->callback, G_VOID | G_EVAL);
160 SPAGAIN; 161 SPAGAIN;
161 } 162 }
162 163
164 do_croak = SvTRUE (ERRSV);
165
163 LEAVE; 166 LEAVE;
164 167
165 if (req->callback) 168 if (req->callback)
166 SvREFCNT_dec (req->callback); 169 SvREFCNT_dec (req->callback);
167 170
171 174
172 prv = req; 175 prv = req;
173 req = req->next; 176 req = req->next;
174 Safefree (prv); 177 Safefree (prv);
175 178
176 /* TODO: croak on errors? */ 179 if (do_croak)
180 croak (0);
177 } 181 }
178 182
179 return count; 183 return count;
180} 184}
181 185
263 267
264static int fork_started; 268static int fork_started;
265 269
266static void atfork_prepare (void) 270static void atfork_prepare (void)
267{ 271{
268 pthread_mutex_lock (&frklock); 272 int nstarted;
269
270 fork_started = started;
271 273
272 for (;;) { 274 for (;;) {
273 while (nreqs) 275 while (nreqs)
274 { 276 {
275 poll_wait (); 277 poll_wait ();
276 poll_cb (); 278 poll_cb ();
277 } 279 }
278 280
281 nstarted = started;
279 max_parallel (0); 282 max_parallel (0);
280 283
281 pthread_mutex_lock (&reqlock); 284 pthread_mutex_lock (&reqlock);
282 285
283 if (!nreqs && !started) 286 if (!nreqs && !started)
286 pthread_mutex_unlock (&reqlock); 289 pthread_mutex_unlock (&reqlock);
287 290
288 min_parallel (fork_started); 291 min_parallel (fork_started);
289 } 292 }
290 293
294 pthread_mutex_lock (&frklock);
295 fork_started = nstarted;
291 pthread_mutex_lock (&reslock); 296 pthread_mutex_lock (&reslock);
292 297
293 assert (!started); 298 assert (!started);
294 assert (!nreqs); 299 assert (!nreqs);
295 assert (!reqs && !reqe); 300 assert (!reqs && !reqe);
297} 302}
298 303
299static void atfork_parent (void) 304static void atfork_parent (void)
300{ 305{
301 pthread_mutex_unlock (&reslock); 306 pthread_mutex_unlock (&reslock);
307 pthread_mutex_unlock (&frklock);
308 pthread_mutex_unlock (&reqlock);
309
302 min_parallel (fork_started); 310 min_parallel (fork_started);
303 pthread_mutex_unlock (&reqlock);
304 pthread_mutex_unlock (&frklock);
305} 311}
306 312
307static void atfork_child (void) 313#define atfork_child atfork_parent
308{
309 reqs = reqe = 0;
310
311 atfork_parent ();
312}
313 314
314/*****************************************************************************/ 315/*****************************************************************************/
315/* work around various missing functions */ 316/* work around various missing functions */
316 317
317#if !HAVE_PREADWRITE 318#if !HAVE_PREADWRITE

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines