diff -N -c -r -X exclude_files squid-1.0.beta7/src/comm.c squid-1.0.beta7.henrik/src/comm.c *** squid-1.0.beta7/src/comm.c Thu May 9 04:31:53 1996 --- squid-1.0.beta7.henrik/src/comm.c Mon May 13 20:43:15 1996 *************** *** 37,50 **** struct sockaddr_in addr; int addr_len = 0; - if (fd_table[fd].port) - return fd_table[fd].port; - /* If the fd is closed already, just return */ if (!fd_table[fd].openned) { debug(5, 0, "comm_port: FD %d has been closed.\n", fd); return (COMM_ERROR); } addr_len = sizeof(addr); if (getsockname(fd, (struct sockaddr *) &addr, &addr_len)) { debug(5, 1, "comm_port: Failed to retrieve TCP/UDP port number for socket: FD %d: %s\n", fd, xstrerror()); --- 37,51 ---- struct sockaddr_in addr; int addr_len = 0; /* If the fd is closed already, just return */ if (!fd_table[fd].openned) { debug(5, 0, "comm_port: FD %d has been closed.\n", fd); return (COMM_ERROR); } + + if (fd_table[fd].port) + return fd_table[fd].port; + addr_len = sizeof(addr); if (getsockname(fd, (struct sockaddr *) &addr, &addr_len)) { debug(5, 1, "comm_port: Failed to retrieve TCP/UDP port number for socket: FD %d: %s\n", fd, xstrerror()); *************** *** 52,57 **** --- 53,79 ---- } debug(5, 6, "comm_port: FD %d: sockaddr %u.\n", fd, addr.sin_addr.s_addr); fd_table[fd].port = ntohs(addr.sin_port); + + if (fd_table[fd].port == 0 ) { + comm_close (fd); + debug(5,0,"Invalid TCP/UDP port number for socket: FD %d\n",fd); + debug(5,0,"FD %d: %s\n",fd,fd_table[fd].ascii_note); + if(fd_table[fd].store_entry) { + StoreEntry *e=fd_table[fd].store_entry; + debug(5,0,"FD %d: key=%s",fd,e->key?e->key:"NULL"); + debug(5,0,"FD %d: url=%s",fd,e->url?e->url:"NULL"); + debug(5,0,"FD %d: flag=%lx\n",fd,e->flag); + debug(5,0,"FD %d: timestamp=%ld lastref=%ld refcount=%ld expires=%ld\n", + fd,e->flag,e->timestamp,e->lastref,e->refcount,e->expires); + debug(5,0,"FD %d: memstat=%d pingstat=%d storestat=%d swapstat=%d\n", + fd,e->mem_status,e->ping_status,e->store_status,e->swap_status); + debug(5,0,"FD %d: method=%d lock_count=%d",e->method,e->lock_count); + } + + return (COMM_ERROR); + } + + return fd_table[fd].port; }