net: rock: Look up the ctl FD with the listen FD (XCC)
Epoll may need to tap all three FDs when tapping a socket/rock. This is
the glibc portion of the change - epoll still taps only the listen FD.
Even if we don't use this for epoll, tracking the ctlfd doesn't hurt and
may prove useful.
Rebuild glibc.
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
diff --git a/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/Versions b/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/Versions
index bdce76f..3a8d19f 100644
--- a/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/Versions
+++ b/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/Versions
@@ -60,7 +60,7 @@
register_close_cb;
register_fork_cb;
- _sock_lookup_listen_fd;
+ _sock_lookup_rock_fds;
get_sibling_fd;
write_hex_to_fd;
diff --git a/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/plan9_sockets.c b/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/plan9_sockets.c
index 9f2ea48..a7303dd 100644
--- a/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/plan9_sockets.c
+++ b/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/plan9_sockets.c
@@ -351,19 +351,21 @@
return ret;
}
-/* Used by user/iplib (e.g. epoll). Returns an FD for the listen file, opened
- * O_PATH, for this conversation. Returns -1 on error. */
-int _sock_lookup_listen_fd(int sock_fd, bool can_open)
+/* Used by user/iplib (e.g. epoll). Returns the FDs for the ctl_fd and for the
+ * listen file, opened O_PATH, for this conversation. Returns -1 on no FDs. */
+void _sock_lookup_rock_fds(int sock_fd, bool can_open_listen_fd,
+ int *listen_fd_r, int *ctl_fd_r)
{
Rock *r = _sock_findrock(sock_fd, 0);
+ *listen_fd_r = -1;
+ *ctl_fd_r = -1;
if (!r || r->domain == PF_UNIX)
- return -1;
- if (r->has_listen_fd)
- return r->listen_fd;
- if (!can_open)
- return -1;
- return _rock_open_listen_fd(r);
+ return;
+ if (!r->has_listen_fd && can_open_listen_fd)
+ _rock_open_listen_fd(r);
+ *listen_fd_r = r->listen_fd; /* might still be -1. that's OK. */
+ *ctl_fd_r = r->ctl_fd;
}
/* Used by fcntl for F_SETFL. */
diff --git a/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/sys/plan9_helpers.h b/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/sys/plan9_helpers.h
index 74d2f70..a67a8b8 100644
--- a/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/sys/plan9_helpers.h
+++ b/tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/sys/plan9_helpers.h
@@ -75,7 +75,8 @@
const char *);
extern int _sock_strip_opts(int type);
extern int _sock_get_opts(int type);
-extern int _sock_lookup_listen_fd(int sock_fd, bool can_open);
+extern void _sock_lookup_rock_fds(int sock_fd, bool can_open_listen_fd,
+ int *listen_fd_r, int *ctl_fd_r);
extern void _sock_mirror_fcntl(int sock_fd, int cmd, long arg);
int get_sibling_fd(int fd, const char *sibling);
diff --git a/user/iplib/epoll.c b/user/iplib/epoll.c
index a25fc79..8890eb1 100644
--- a/user/iplib/epoll.c
+++ b/user/iplib/epoll.c
@@ -357,7 +357,7 @@
struct ceq_event *ceq_ev;
struct ep_fd_data *ep_fd;
struct fd_tap_req tap_req = {0};
- int ret, filter, sock_listen_fd;
+ int ret, filter, sock_listen_fd, sock_ctl_fd;
struct epoll_event listen_event;
/* Only support ET. Also, we just ignore EPOLLONESHOT. That might work,
@@ -386,7 +386,7 @@
* As far as tracking the FD goes for epoll_wait() reporting, if the app
* wants to track the FD they think we are using, then they already passed
* that in event->data. */
- sock_listen_fd = _sock_lookup_listen_fd(fd, TRUE);
+ _sock_lookup_rock_fds(fd, TRUE, &sock_listen_fd, &sock_ctl_fd);
if (sock_listen_fd >= 0) {
listen_event.events = EPOLLET | EPOLLIN | EPOLLHUP;
listen_event.data = event->data;
@@ -431,7 +431,7 @@
struct ceq_event *ceq_ev;
struct ep_fd_data *ep_fd;
struct fd_tap_req tap_req = {0};
- int ret, sock_listen_fd;
+ int ret, sock_listen_fd, sock_ctl_fd;
/* If we were dealing with a socket shim FD, we tapped both the listen and
* the data file and need to untap both of them.
@@ -440,7 +440,7 @@
* In that case, we don't want to try and open it. If the listen FD isn't
* open, then we know it isn't in an epoll set. We also know the data FD
* isn't epolled either, since we always epoll both FDs for rocks. */
- sock_listen_fd = _sock_lookup_listen_fd(fd, FALSE);
+ _sock_lookup_rock_fds(fd, FALSE, &sock_listen_fd, &sock_ctl_fd);
if (sock_listen_fd >= 0) {
/* It's possible to fail here. Even though we tapped it already, if the
* deletion was triggered from close callbacks, it's possible for the