Revision: 14424
Author: adrian.chadd
Date: Fri Feb 19 23:53:43 2010
Log: Add a remote_address hook which will hopefully track the remote address
after accept() / connect().


http://code.google.com/p/lusca-cache/source/detail?r=14424

Modified:
 /branches/LUSCA_HEAD/libiapp/comm.c
 /branches/LUSCA_HEAD/libiapp/comm.h

=======================================
--- /branches/LUSCA_HEAD/libiapp/comm.c Wed Feb 10 22:50:10 2010
+++ /branches/LUSCA_HEAD/libiapp/comm.c Fri Feb 19 23:53:43 2010
@@ -267,6 +267,7 @@
     F = &fd_table[new_socket];

     sqinet_init(&(F->local_address));
+    sqinet_init(&(F->remote_address));
     sqinet_copy(&(F->local_address), a);

     F->tos = tos;
@@ -560,6 +561,7 @@
     else
        return COMM_ERROR;
     sqinet_ntoa(addr, F->ipaddrstr, MAX_IPSTRLEN, 0);
+    sqinet_copy(&F->remote_address, addr);
     F->remote_port = sqinet_get_port(addr);
     if (status == COMM_OK) {
        debug(5, 10) ("comm_connect_addr: FD %d connected to %s:%d\n",
@@ -614,6 +616,7 @@
     fd_note_static(sock, "HTTP Request");
     F = &fd_table[sock];
     sqinet_ntoa(&rem, F->ipaddrstr, MAX_IPSTRLEN, 0);
+    sqinet_copy(&F->remote_address, &rem);
     F->remote_port = sqinet_get_port(&rem);
     F->local_port = sqinet_get_port(&loc);
     commSetNonBlocking(sock);
@@ -730,6 +733,7 @@
 comm_close_finish(int fd)
 {
     sqinet_done(&fd_table[fd].local_address);
+    sqinet_done(&fd_table[fd].remote_address);
     fd_close(fd);              /* update fdstat */
     close(fd);
     CommStats.syscalls.sock.closes++;
@@ -1589,6 +1593,10 @@
         sqinet_init(&fd_table[*cwfd].local_address);
         sqinet_init(&fd_table[*crfd].local_address);
         sqinet_init(&fd_table[*pwfd].local_address);
+        sqinet_init(&fd_table[*prfd].remote_address);
+        sqinet_init(&fd_table[*cwfd].remote_address);
+        sqinet_init(&fd_table[*crfd].remote_address);
+        sqinet_init(&fd_table[*pwfd].remote_address);

        return 1;
 }
@@ -1610,6 +1618,8 @@
         fd_open(*crfd = *cwfd = fds[1], FD_PIPE, "IPC UNIX STREAM Parent");
         sqinet_init(&fd_table[*prfd].local_address);
         sqinet_init(&fd_table[*crfd].local_address);
+        sqinet_init(&fd_table[*prfd].remote_address);
+        sqinet_init(&fd_table[*crfd].remote_address);

        return 1;
 }
@@ -1626,6 +1636,8 @@
        fd_open(*crfd = *cwfd = fds[1], FD_PIPE, "IPC UNIX DGRAM Parent");
         sqinet_init(&fd_table[*prfd].local_address);
         sqinet_init(&fd_table[*crfd].local_address);
+        sqinet_init(&fd_table[*prfd].remote_address);
+        sqinet_init(&fd_table[*crfd].remote_address);

        return 1;
 }
=======================================
--- /branches/LUSCA_HEAD/libiapp/comm.h Wed Sep 30 00:25:34 2009
+++ /branches/LUSCA_HEAD/libiapp/comm.h Fri Feb 19 23:53:43 2010
@@ -64,6 +64,7 @@
     u_short local_port;
     u_short remote_port;
     sqaddr_t local_address;
+    sqaddr_t remote_address;
     unsigned char tos;
char ipaddrstr[MAX_IPSTRLEN]; /* dotted decimal address of peer - XXX should be MAX_IPSTRLEN */
     const char *desc;

--
You received this message because you are subscribed to the Google Groups 
"lusca-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/lusca-commit?hl=en.

Reply via email to