|
View:
New views
1 Messages
—
Rating Filter:
Alert me
|
|
|
[PATCH] fix IDLE_WAIT handlingBy Michael Douglass <mikedoug@...>
Signed-off-by: James Cameron <james.cameron@...> I noticed that my pptpd processes were not terminating when the remote pptp client went off the network unexpectedly. I straced the pptpd process and noticed that the select() loop in pptctrl.c was never timing out because the /dev/ptmx descriptor was sending data to pptpd every 10 seconds. Since the select() loop was never timing out, the IDLE_WAIT mechanism never triggered. The patch below makes the following changes: * select() returning 0 is no longer a direct trigger case for sending an ECHO REQ * Track the last time we heard anything from our TCP socket in last_time (initialized to now on startup) * Any time we go through the loop and we don't hear from our TCP socket, we check to see if our last_time is older than IDLE_WAIT -- if so, send an ECHO REQ I've tested this successfully with my installation. Index: pptpctrl.c =================================================================== RCS file: /cvsroot/poptop/poptop/pptpctrl.c,v retrieving revision 1.21 diff -u -u -r1.21 pptpctrl.c --- pptpctrl.c 7 Oct 2008 23:17:38 -0000 1.21 +++ pptpctrl.c 15 Jun 2009 02:43:49 -0000 @@ -226,6 +226,7 @@ int echo_wait = FALSE; /* Waiting for echo? */ u_int32_t echo_count = 0; /* Sequence # of echo */ time_t echo_time = 0; /* Time last echo req sent */ + time_t last_time = time(NULL); /* Time last received data */ struct timeval idleTime; /* How long to select() */ /* General local variables */ @@ -281,16 +282,6 @@ } else if (encaps_gre(-1, NULL, 0)) /* Pending ack and nothing else to do */ encaps_gre(gre_fd, NULL, 0); /* send ack with no payload */ - else if (echo_wait != TRUE) { - /* Timeout. Start idle link detection. */ - echo_count++; - if (pptpctrl_debug) - syslog(LOG_DEBUG, "CTRL: Sending ECHO REQ id %d", echo_count); - time(&echo_time); - make_echo_req_packet(rply_packet, &rply_size, echo_count); - echo_wait = TRUE; - send_packet = TRUE; - } break; default: @@ -328,6 +319,7 @@ /* handle control messages */ if (FD_ISSET(clientSocket, &fds)) { + time(&last_time); send_packet = TRUE; switch (read_pptp_packet(clientSocket, packet, rply_packet, &rply_size)) { case 0: @@ -420,6 +412,15 @@ /* Otherwise, the already-formed reply will do fine, so send it */ } + /* send echo request packet if we have not heard from the TCP socket in IDLE_TIME */ + } else if (echo_wait != TRUE && (time(NULL) - last_time) > IDLE_WAIT) { + echo_count++; + if (pptpctrl_debug) + syslog(LOG_DEBUG, "CTRL: Sending ECHO REQ id %d", echo_count); + time(&echo_time); + make_echo_req_packet(rply_packet, &rply_size, echo_count); + echo_wait = TRUE; + send_packet = TRUE; } /* send reply packet - this may block, but it should be very rare */ -- James Cameron http://quozl.netrek.org/ HP Open Source, Volunteer http://opensource.hp.com/ PPTP Client Project, Release Engineer http://pptpclient.sourceforge.net/ ------------------------------------------------------------------------------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ Poptop-server mailing list Poptop-server@... https://lists.sourceforge.net/lists/listinfo/poptop-server |
| Free embeddable forum powered by Nabble | Forum Help |