File tree Expand file tree Collapse file tree 3 files changed +11
-4
lines changed Expand file tree Collapse file tree 3 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,7 @@ static int cmd_data(const r2tmsg_t *msg, unsigned int len)
102102
103103static int cmd_rconn (const r2tmsg_t * msg , unsigned int len )
104104{
105+ int ret = 0 ;
105106 tunnel_t * tun ;
106107
107108 trace_chan ("len=%u, id=0x%02x" , len , msg -> id );
@@ -110,9 +111,12 @@ static int cmd_rconn(const r2tmsg_t *msg, unsigned int len)
110111 error ("invalid tunnel id 0x%02x" , msg -> id );
111112 return 0 ;
112113 }
114+ if (tun -> connected < 0 ) {
115+ while ((ret = tunnel_sockrecv_event (tun )) > 0 );
116+ }
113117 tun -> connected = 1 ;
114118
115- return 0 ;
119+ return ret ;
116120}
117121
118122const cmdhandler_t cmd_handlers [R2TCMD_MAX ] = {
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ typedef struct _vchannel {
4747typedef struct _tunnel {
4848 struct list_head list ; /**< double-linked list */
4949 sock_t sock ; /**< tunnel socket */
50- unsigned char connected ; /**< 1 if tunnel is connected */
50+ char connected ; /**< 1 if tunnel is connected */
5151 unsigned char server ; /**< 1 for reverse-connect tunnel */
5252 unsigned char id ; /**< tunnel identifier */
5353 HANDLE proc ; /**< child process HANDLE */
@@ -104,6 +104,7 @@ int tunnel_event(tunnel_t *, HANDLE);
104104int tunnel_write (tunnel_t * tun , const void * , unsigned int );
105105void tunnel_close (tunnel_t * );
106106void tunnels_kill (void );
107+ int tunnel_sockrecv_event (tunnel_t * tun );
107108
108109/* errors.c ***/
109110int wsaerror (const char * );
Original file line number Diff line number Diff line change @@ -331,7 +331,7 @@ void tunnel_close(tunnel_t *tun)
331331 free (tun );
332332}
333333
334- static int tunnel_sockrecv_event (tunnel_t * tun )
334+ int tunnel_sockrecv_event (tunnel_t * tun )
335335{
336336 int ret ;
337337 unsigned int r ;
@@ -501,8 +501,10 @@ int tunnel_event(tunnel_t *tun, HANDLE h)
501501
502502 if ((ret >= 0 ) && (evt & FD_READ )) {
503503 debug (0 , "FD_READ" );
504- if (tun -> connected )
504+ if (tun -> connected > 0 )
505505 ret = tunnel_sockrecv_event (tun );
506+ else
507+ tun -> connected = -1 ;
506508 if (evt & FD_CLOSE )
507509 while ((ret = tunnel_sockrecv_event (tun )) > 0 );
508510 }
You can’t perform that action at this time.
0 commit comments