/[pengfork]/pengfork/src/p3/p3.c
ViewVC logotype

Diff of /pengfork/src/p3/p3.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11 by chupa, Sun Dec 1 01:19:07 2002 UTC revision 1.12 by chupa, Tue Dec 3 18:38:15 2002 UTC
# Line 47  Line 47 
47    
48  struct p3state cli, srv;  struct p3state cli, srv;
49    
50    int ping_sent;
51    
52  const protocol_t p3_protocol = (protocol_t) {  const protocol_t p3_protocol = (protocol_t) {
53    p3_register_to_engine,    p3_register_to_engine,
54    p3_send,    p3_send,
# Line 61  const struct engine_functions p3_fn = (s Line 63  const struct engine_functions p3_fn = (s
63    p3_recv,    p3_recv,
64    NULL,    NULL,
65    p3_timeout,    p3_timeout,
66    NULL    p3_end
67  };  };
68    
69  window_t wsend, wunack, wnack;  window_t wsend, wunack, wnack;
# Line 94  p3_init (bufin, bufout) Line 96  p3_init (bufin, bufout)
96    srv.lastack = 0;              /* We have never received a packet */    srv.lastack = 0;              /* We have never received a packet */
97    srv.lastseq = PACKET_MAX_SEQ;    srv.lastseq = PACKET_MAX_SEQ;
98    srv.want_ssr = 0;    srv.want_ssr = 0;
99      nack_sent = 0;
100      ping_sent = 0;
101    
102    create_buffer (bufin, P3_MAX_SIZE + 1);    create_buffer (bufin, P3_MAX_SIZE + 1);
103    create_buffer (bufout, P3_MAX_SIZE + 1);    create_buffer (bufout, P3_MAX_SIZE + 1);
104    win_alloc (&wsend, WINDOW_SIZE);    win_alloc (&wsend, WINDOW_SIZE);
105    win_alloc (&wunack, WINDOW_SIZE);    win_alloc (&wunack, WINDOW_SIZE);
106    win_alloc (&wnack, WINDOW_SIZE);    /*win_alloc (&wnack, WINDOW_SIZE);*/
107    p3_send_init_packet ();    p3_send_init_packet ();
108  }  }
109    
110  int  int
111    p3_end (bufin, bufout)
112         buffer_t *bufin;
113         buffer_t *bufout;
114    {
115      win_free (&wsend);
116      win_free (&wunack);
117      /*win_free (&wnack);*/
118      return 1;
119    }
120    
121    int
122  p3_want_write (out)  p3_want_write (out)
123       buffer_t *out;       buffer_t *out;
124  {  {
# Line 182  p3_timeout (bufin, bufout, timeout) Line 197  p3_timeout (bufin, bufout, timeout)
197      }      }
198    else    else
199      {      {
200        if (cli.lastseq != srv.lastack)        if ((timeout > 35 && (cli.lastseq != srv.lastack || nack_sent)) ||
201            (timeout > 90 && ping_sent))
202          {          {
203            /* Always some unacknowledged packets??!!            /* Always some data to wait after 40 s...
204             * The server seems out or lost             * The server seems out or lost
205             */             */
206            log (LOG_WARNING, gettext("Server seems dead, disconnecting...\n"));
207            engine_stop();
208            }
209          if (timeout > 60)
210            {
211            /*
212             * No data to wait for more than 1 minute,
213             * send a ping to be sure, we're always connected
214             */
215            ping_sent = 1;
216            p3_put_packet (TYPE_PING, NULL, 0);
217          }          }
218      }      }
219    if (nack_sent)    if (nack_sent)

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26