summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root>2008-05-10 23:33:40 +0000
committerroot <root>2008-05-10 23:33:40 +0000
commit6ecb7a8b6f0c086d9d5aba1bda289a0383e8f83f (patch)
tree7a3a638fd033cde1ab393a24e62a38719938d1ed
parentbd850bb93a4c5f48c254c9c7ddd44d16ffde99cb (diff)
*** empty log message ***
-rw-r--r--eio.c39
-rw-r--r--eio.h7
2 files changed, 28 insertions, 18 deletions
diff --git a/eio.c b/eio.c
index 6c2ba72..eb62d71 100644
--- a/eio.c
+++ b/eio.c
@@ -241,7 +241,7 @@ static eio_req *reqq_shift (reqq *q)
abort ();
}
-static void grp_feed (eio_req *grp)
+static void grp_try_feed (eio_req *grp)
{
while (grp->size < grp->int2 && !EIO_CANCELLED (grp))
{
@@ -253,23 +253,23 @@ static void grp_feed (eio_req *grp)
if (old_len == grp->size)
{
grp->feed = 0;
- grp->int2 = 0;
+ break;
}
}
}
-static int eio_invoke (eio_req *req);
+static int eio_finish (eio_req *req);
static int grp_dec (eio_req *grp)
{
--grp->size;
/* call feeder, if applicable */
- grp_feed (grp);
+ grp_try_feed (grp);
/* finish, if done */
if (!grp->size && grp->int1)
- return eio_invoke (grp);
+ return eio_finish (grp);
else
return 0;
}
@@ -282,7 +282,7 @@ void eio_destroy (eio_req *req)
EIO_DESTROY (req);
}
-static int eio_invoke (eio_req *req)
+static int eio_finish (eio_req *req)
{
int res = EIO_FINISH (req);
@@ -445,7 +445,7 @@ int eio_poll (void)
{
--npending;
- if (!res_queue.size)
+ if (!res_queue.size && done_poll_cb)
done_poll_cb ();
}
@@ -463,7 +463,7 @@ int eio_poll (void)
}
else
{
- int res = eio_invoke (req);
+ int res = eio_finish (req);
if (res)
return res;
}
@@ -919,7 +919,7 @@ X_THREAD_PROC (eio_proc)
++npending;
- if (!reqq_push (&res_queue, req))
+ if (!reqq_push (&res_queue, req) && want_poll_cb)
want_poll_cb ();
self->req = 0;
@@ -938,7 +938,7 @@ quit:
/*****************************************************************************/
-static void atfork_prepare (void)
+static void eio_atfork_prepare (void)
{
X_LOCK (wrklock);
X_LOCK (reqlock);
@@ -951,7 +951,7 @@ static void atfork_prepare (void)
#endif
}
-static void atfork_parent (void)
+static void eio_atfork_parent (void)
{
#if !HAVE_READDIR_R
X_UNLOCK (readdirlock);
@@ -964,7 +964,7 @@ static void atfork_parent (void)
X_UNLOCK (wrklock);
}
-static void atfork_child (void)
+static void eio_atfork_child (void)
{
eio_req *prv;
@@ -991,7 +991,7 @@ static void atfork_child (void)
nready = 0;
npending = 0;
- atfork_parent ();
+ eio_atfork_parent ();
}
int eio_init (void (*want_poll)(void), void (*done_poll)(void))
@@ -1010,7 +1010,7 @@ int eio_init (void (*want_poll)(void), void (*done_poll)(void))
X_COND_CHECK (reqwait);
#endif
- X_THREAD_ATFORK (atfork_prepare, atfork_parent, atfork_child);
+ X_THREAD_ATFORK (eio_atfork_prepare, eio_atfork_parent, eio_atfork_child);
}
#if 0
@@ -1416,10 +1416,19 @@ aio_nop (SV *callback=&PL_sv_undef)
#endif
-void eio_grp_feed (eio_req *grp, int limit, void (*feed)(eio_req *req))
+void eio_grp_feed (eio_req *grp, void (*feed)(eio_req *req), int limit)
{
grp->int2 = limit;
grp->feed = feed;
+
+ grp_try_feed (grp);
+}
+
+void eio_grp_limit (eio_req *grp, int limit)
+{
+ grp->int2 = limit;
+
+ grp_try_feed (grp);
}
void eio_grp_add (eio_req *grp, eio_req *req)
diff --git a/eio.h b/eio.h
index 9de84d0..d34c3eb 100644
--- a/eio.h
+++ b/eio.h
@@ -46,8 +46,8 @@ struct eio_req
size_t size; /* read, write, readahead, sendfile: length */
void *ptr1; /* all applicable requests: pathname, old name */
void *ptr2; /* all applicable requests: new name or memory buffer */
- eio_tstamp nv1; /* utime, futime: atime; busy: sleep time */
- eio_tstamp nv2; /* utime, futime: mtime */
+ eio_tstamp nv1; /* utime, futime: atime; busy: sleep time */
+ eio_tstamp nv2; /* utime, futime: mtime */
int type; /* EIO_xxx constant */
int int1; /* all applicable requests: file descriptor; sendfile: output fd; open: flags */
@@ -145,7 +145,8 @@ eio_req *eio_nop (eio_cb cb); /* does nothing except go through the whole
/* for groups */
eio_req *eio_grp (eio_cb cb);
-void eio_grp_feed (eio_req *grp, int limit, void (*feed)(eio_req *req));
+void eio_grp_feed (eio_req *grp, void (*feed)(eio_req *req), int limit);
+void eio_grp_limit (eio_req *grp, int limit);
void eio_grp_add (eio_req *grp, eio_req *req);
void eio_grp_cancel (eio_req *grp); /* cancels all sub requests but not the group */