debian-692654_fix-idle-wait.patch 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. Description: fix IDLE_WAIT implementation
  2. Author: Michael Douglass <mikedoug at mikedoug dot net>
  3. Origin: http://poptop.cvs.sourceforge.net/viewvc/poptop/poptop/pptpctrl.c?r1=1.21&r2=1.22
  4. Forwarded: not-needed
  5. Bug-Debian: http://bugs.debian.org/692654
  6. --- a/AUTHORS
  7. +++ b/AUTHORS
  8. @@ -28,6 +28,7 @@
  9. Chris Wilson
  10. Anton Gorlov
  11. Charlie Brady
  12. +Michael Douglass <mikedoug at mikedoug dot net>
  13. The Linux PPTP Server takes advantage of some Linux PPTP client code
  14. written by C. Scott Ananian <cananian at alumni.princeton.edu>
  15. --- a/pptpctrl.c
  16. +++ b/pptpctrl.c
  17. @@ -226,6 +226,7 @@
  18. int echo_wait = FALSE; /* Waiting for echo? */
  19. u_int32_t echo_count = 0; /* Sequence # of echo */
  20. time_t echo_time = 0; /* Time last echo req sent */
  21. + time_t last_time = time(NULL); /* Time last received data */
  22. struct timeval idleTime; /* How long to select() */
  23. /* General local variables */
  24. @@ -281,16 +282,6 @@
  25. } else if (encaps_gre(-1, NULL, 0))
  26. /* Pending ack and nothing else to do */
  27. encaps_gre(gre_fd, NULL, 0); /* send ack with no payload */
  28. - else if (echo_wait != TRUE) {
  29. - /* Timeout. Start idle link detection. */
  30. - echo_count++;
  31. - if (pptpctrl_debug)
  32. - syslog(LOG_DEBUG, "CTRL: Sending ECHO REQ id %d", echo_count);
  33. - time(&echo_time);
  34. - make_echo_req_packet(rply_packet, &rply_size, echo_count);
  35. - echo_wait = TRUE;
  36. - send_packet = TRUE;
  37. - }
  38. break;
  39. default:
  40. @@ -328,6 +319,7 @@
  41. /* handle control messages */
  42. if (FD_ISSET(clientSocket, &fds)) {
  43. + time(&last_time);
  44. send_packet = TRUE;
  45. switch (read_pptp_packet(clientSocket, packet, rply_packet, &rply_size)) {
  46. case 0:
  47. @@ -420,6 +412,15 @@
  48. /* Otherwise, the already-formed reply will do fine, so send it */
  49. }
  50. + /* send echo request packet if we have not heard from the TCP socket in IDLE_TIME */
  51. + } else if (echo_wait != TRUE && (time(NULL) - last_time) > IDLE_WAIT) {
  52. + echo_count++;
  53. + if (pptpctrl_debug)
  54. + syslog(LOG_DEBUG, "CTRL: Sending ECHO REQ id %d", echo_count);
  55. + time(&echo_time);
  56. + make_echo_req_packet(rply_packet, &rply_size, echo_count);
  57. + echo_wait = TRUE;
  58. + send_packet = TRUE;
  59. }
  60. /* send reply packet - this may block, but it should be very rare */