--- /dev/null
+Bottom: cae235e68f5c1b9ddbefc3f6eb456f6481b17743
+Top: d9b92ddc1535f5f948e377adc72d85702f62d527
+Author: Sean Hefty <sean.hefty@intel.com>
+Date: 2012-11-16 00:44:14 -0800
+
+Refresh of test-udp
+
+---
+
+diff --git a/src/preload.c b/src/preload.c
+index b913091..d516086 100644
+--- a/src/preload.c
++++ b/src/preload.c
+@@ -138,7 +138,7 @@ static int fd_open(void)
+ goto err1;
+ }
+ fdi->udp_fd = real.socket(PF_INET, SOCK_DGRAM, 0);
+- real.fcntl(fdi->udp_fd, F_SETFL, O_NONBLOCK);
++ ret = real.fcntl(fdi->udp_fd, F_SETFL, O_NONBLOCK);
+
+ fdi->dupfd = -1;
+ atomic_init(&fdi->refcnt);
+@@ -191,6 +191,14 @@ static inline int fd_getd(int index)
+ return fdi ? fdi->fd : index;
+ }
+
++static inline int fd_getudp(int index)
++{
++ struct fd_info *fdi;
++
++ fdi = idm_lookup(&idm, index);
++ return fdi->udp_fd;
++}
++
+ static inline enum fd_fork_state fd_gets(int index)
+ {
+ struct fd_info *fdi;
+@@ -218,6 +226,7 @@ static enum fd_type fd_close(int index, int *fd)
+ *fd = fdi->fd;
+ type = fdi->type;
+ real.close(index);
++ real.close(fdi->udp_fd);
+ free(fdi);
+ } else {
+ *fd = index;
+@@ -440,9 +449,7 @@ real:
+ int bind(int socket, const struct sockaddr *addr, socklen_t addrlen)
+ {
+ int fd;
+- printf("%s in\n", __func__);
+-// real.bind(socket, addr, addrlen);
+- printf("%s call out\n", __func__);
++ real.bind(fd_getudp(socket), addr, addrlen);
+ return (fd_get(socket, &fd) == fd_rsocket) ?
+ rbind(fd, addr, addrlen) : real.bind(fd, addr, addrlen);
+ }
+@@ -450,7 +457,6 @@ int bind(int socket, const struct sockaddr *addr, socklen_t addrlen)
+ int listen(int socket, int backlog)
+ {
+ int fd, ret;
+- printf("%s in\n", __func__);
+ if (fd_get(socket, &fd) == fd_rsocket) {
+ ret = rlisten(fd, backlog);
+ } else {
+@@ -458,7 +464,6 @@ int listen(int socket, int backlog)
+ if (!ret && fd_gets(socket) == fd_fork)
+ fd_store(socket, fd, fd_normal, fd_fork_listen);
+ }
+- printf("%s out\n", __func__);
+ return ret;
+ }
+
+@@ -478,7 +483,6 @@ int accept(int socket, struct sockaddr *addr, socklen_t *addrlen)
+ }
+
+ fd_store(index, ret, fd_rsocket, fd_ready);
+- printf("%s out\n", __func__);
+ return index;
+ } else if (fd_gets(socket) == fd_fork_listen) {
+ index = fd_open();
+@@ -645,11 +649,10 @@ int connect(int socket, const struct sockaddr *addr, socklen_t addrlen)
+ {
+ int fd, ret;
+
+- printf("%s in\n", __func__);
+ if (fd_get(socket, &fd) == fd_rsocket) {
+- printf("%s rconnect\n", __func__);
+ ret = rconnect(fd, addr, addrlen);
+- printf("%s ret %d\n", __func__, ret);
++ if (!ret)
++ real.connect(fd_getudp(socket), addr, addrlen);
+ if (!ret || errno == EINPROGRESS)
+ return ret;
+
+@@ -669,9 +672,9 @@ int connect(int socket, const struct sockaddr *addr, socklen_t addrlen)
+ ssize_t recv(int socket, void *buf, size_t len, int flags)
+ {
+ int fd;
+-// struct sockaddr sa;
+-// socklen_t slen = sizeof sa;
+-// real.recvfrom(socket, buf, len, flags, &sa, &slen);
++ struct sockaddr sa;
++ socklen_t slen = sizeof sa;
++ real.recvfrom(fd_getudp(socket), buf, len, flags, &sa, &slen);
+ return (fd_fork_get(socket, &fd) == fd_rsocket) ?
+ rrecv(fd, buf, len, flags) : real.recv(fd, buf, len, flags);
+ }
+@@ -768,13 +771,11 @@ int poll(struct pollfd *fds, nfds_t nfds, int timeout)
+ struct pollfd *rfds;
+ int i, ret;
+
+-// printf("%s in\n", __func__);
+ init_preload();
+ for (i = 0; i < nfds; i++) {
+ if (fd_gett(fds[i].fd) == fd_rsocket)
+ goto use_rpoll;
+ }
+-// printf("%s call real poll\n", __func__);
+
+ return real.poll(fds, nfds, timeout);
+
+@@ -795,7 +796,6 @@ use_rpoll:
+ for (i = 0; i < nfds; i++)
+ fds[i].revents = rfds[i].revents;
+
+-// printf("%s out\n", __func__);
+ return ret;
+ }
+
+@@ -954,7 +954,6 @@ int fcntl(int socket, int cmd, ... /* arg */)
+ void *pparam;
+ int fd, ret;
+
+- printf("%s in\n", __func__);
+ init_preload();
+ va_start(args, cmd);
+ switch (cmd) {
+@@ -985,7 +984,6 @@ int fcntl(int socket, int cmd, ... /* arg */)
+ break;
+ }
+ va_end(args);
+- printf("%s out\n", __func__);
+ return ret;
+ }