Re: Network TCP Handler: stale socket disposal

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: Network TCP Handler: stale socket disposal

Weili Yao
Hello John, Gary, and Andrew:
   It seemed that John's patch proposal in the following post
      https://www.sourceware.org/ml/ecos-patches/2007-08/msg00059.html 
   was not adopted by ECOS, but the patch indeed works for us. I put two devices using ECOS and put in our cooperation LAN side by side, one device with the patch and the other device without the patch. The device without the patch lost socketIDs, and the device with the patch has been running great. The backtrace shows as follows. I am not sure how to reproduce the problem, but when the devices are put in a big network, the patch code will be triggered and helped the free of socketIDs. Without the patch, the system slowly runs out of sockets and caused the system unaccessable.  
    My question is when the patch will be officially adopted by ECOS?
    Thank you a lot!

Weili
   
(ECONNRESET is the so->error value) when reaching the patch code below:

(gdb) list *0x0010C8F0
0x10c8f0 is in debug_socket_patch (ecos/web/web_netinfo.c:501).
496     #include <sys/socketvar.h>
497     void debug_socket_patch(struct socket *so)
498     {
499       static int count = 0;
500       count++;
501       app_warning_error(fe_expro(), (count << 16) + so->so_error);
502     }
503
504     // end of the file
505
(gdb) list *0x003141D4
0x3141d4 is in cyg_sofree (/ecos_build/ecos_sources/packages/net/bsd_tcpip/current/src/sys/kern/uipc_socket.c:260).
255                             head->so_incqlen--;
256                     } else if (so->so_state & SS_COMP) {
257
258                 if((so->so_error == ECONNRESET) ||
259                    (so->so_error == ECONNREFUSED)){ // forced drop if flagged
260                       debug_socket_patch(so);
261                       TAILQ_REMOVE(&head->so_comp, so, so_list);
262                       head->so_qlen--;
263                 }
264                 else
(gdb) list *0x003048F8
0x3048f8 is in cyg_in_pcbdetach (/ecos_build/ecos_sources/packages/net/bsd_tcpip/current/src/sys/netinet/in_pcb.c:528).
523             ipsec4_delete_pcbpolicy(inp);
524     #endif /*IPSEC*/
525             inp->inp_gencnt = ++ipi->ipi_gencnt;
526             in_pcbremlists(inp);
527             so->so_pcb = 0;
528             sofree(so);
529             if (inp->inp_options)
530                     (void)m_free(inp->inp_options);
531             if (rt) {
532                     /*
(gdb) list *0x00310FDC
0x310fdc is in cyg_tcp_close (/ecos_build/ecos_sources/packages/net/bsd_tcpip/current/src/sys/netinet/tcp_subr.c:748).
743     #ifdef INET6
744             if (INP_CHECK_SOCKAF(so, AF_INET6))
745                     in6_pcbdetach(inp);
746             else
747     #endif /* INET6 */
748             in_pcbdetach(inp);
749             tcpstat.tcps_closed++;
750             return ((struct tcpcb *)0);
751     }
752
(gdb) list *0x0030DB58
0x30db58 is in cyg_tcp_input (/ecos_build/ecos_sources/packages/net/bsd_tcpip/current/src/sys/netinet/tcp_input.c:2074).
2069                     * If our FIN is now acknowledged, delete the TCB,
2070                     * enter the closed state and return.
2071                     */
2072                    case TCPS_LAST_ACK:
2073                            if (ourfinisacked) {
2074                                    tp = tcp_close(tp);
2075                                    goto drop;
2076                            }
2077                            break;
2078
(gdb) list *0x00308700
0x308700 is in cyg_ip_input (/ecos_build/ecos_sources/packages/net/bsd_tcpip/current/src/sys/netinet/ip_input.c:951).
946               ip->ip_len -= hlen; // subtract the hlen
947         }
948
949     upper_layer:
950
951             (*inetsw[ip_protox[ip->ip_p]].pr_input)(m, off);
952     #ifdef  IPFIREWALL_FORWARD
953             ip_fw_fwd_addr = NULL;  /* tcp needed it */
954     #endif
955             return;
(gdb) list *0x003087A8
0x3087a8 is in ipintr (/ecos_build/ecos_sources/packages/net/bsd_tcpip/current/src/sys/netinet/ip_input.c:979).
974                     s = splimp();
975                     IF_DEQUEUE(&ipintrq, m);
976                     splx(s);
977                     if (m == 0)
978                             return;
979                     ip_input(m);
980             }
981     }
982
983     /*
(gdb) list *0x002F987C
0x2f987c is in cyg_netint (/ecos_build/ecos_sources/packages/net/bsd_tcpip/current/src/ecos/support.c:757).
752                                    CYG_FLAG_WAITMODE_OR|CYG_FLAG_WAITMODE_CLR);
753             spl = splsoftnet(); // Prevent any overlapping "stack" processing
754             for (lvl = NETISR_MIN;  lvl <= NETISR_MAX;  lvl++) {
755                 if (curisr & (1<<lvl)) {
756                     if (NULL != _netisr_handlers[lvl])
757                         (*_netisr_handlers[lvl])();
758                 }
759             }
760             splx(spl);
761         }
(gdb) list *0x002D14B4
0x2d14b4 is in Cyg_HardwareThread::thread_entry(Cyg_Thread*) (/ecos_build/ecos_sources/packages/kernel/current/src/common/thread.cxx:94).
89          Cyg_Scheduler::scheduler.thread_entry( thread );
90
91          // Call entry point in a loop.
92          for(;;)
93          {
94              thread->entry_point(thread->entry_data);
95              thread->exit();
96          }
97      }
98
(gdb) list *0x002D147C
0x2d147c is in Cyg_Thread::exit() (/ecos_build/ecos_sources/packages/kernel/current/src/common/thread.cxx:781).
776
777             Cyg_Scheduler::scheduler.rem_thread(self);
778         }
779
780         Cyg_Scheduler::reschedule();
781     }
782
783     // -------------------------------------------------------------------------
784     // Kill thread. Force the thread into EXITED state externally, or
785     // make it wake up and call exit().
(gdb)

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss