Pass the wqueue directly to the wqueue callback functions

This commit is contained in:
Nils O. Selåsdal
2015-12-04 22:25:57 +01:00
parent 1d26348bb0
commit 94dcd522aa
3 changed files with 14 additions and 9 deletions
+5 -5
View File
@@ -9,7 +9,7 @@
#include <ucore/fd_utils.h>
int stdout_read(struct IOMux *mux, struct IOMuxFD *fd)
int stdout_read(struct IOMux *mux, struct UCWQueue *wqueue)
{
return 1;
}
@@ -24,9 +24,9 @@ void stdin_read_cb(struct IOMux *mux, struct IOMuxFD *fd, unsigned int event)
printf("Read %d bytes\n", len);
if (len <= 0) {
uc_mbuf_free(mbuf);
iomux_unregister_fd(mux, fd);
uc_wqueue_clear(wqueue);
iomux_unregister_fd(mux, &wqueue->fd);
uc_wqueue_clear(wqueue);
iomux_unregister_fd(mux, fd);
return;
}
@@ -44,7 +44,7 @@ struct IOMuxFD stdin_fd = {
};
int stdout_write(struct IOMux *mux, struct IOMuxFD *fd, struct MBuf *mbuf)
int stdout_write(struct IOMux *mux, struct UCWQueue *wqueue, struct MBuf *mbuf)
{
uint32_t len;
ssize_t wlen;
@@ -52,7 +52,7 @@ int stdout_write(struct IOMux *mux, struct IOMuxFD *fd, struct MBuf *mbuf)
len = uc_mbuf_len(mbuf);
data = uc_mbuf_pull(mbuf, len);
wlen = write(fd->fd, data, len);
wlen = write(wqueue->fd.fd, data, len);
if (wlen < 0) {
if (errno != EWOULDBLOCK) {