@@ -99,6 +99,25 @@ tac_event_loop_global_shutdown(void)
9999#endif
100100}
101101
102+ void tac_session_reset_timeouts (struct tac_session * sess , bool on )
103+ {
104+ struct timeval tv = { sess -> tac_timeout , 0 };
105+
106+ TACDEBUG (LOG_DEBUG , "session %p reset_timeouts %u %s" , sess , sess -> tac_timeout , (on ? "on" : "off" ));
107+
108+ if (!sess -> bufev )
109+ return ;
110+
111+ /* nothing will be enabled if we haven't yet connected... */
112+ if (bufferevent_get_enabled (sess -> bufev ) == 0 )
113+ return ;
114+
115+ if (on )
116+ bufferevent_set_timeouts (sess -> bufev , & tv , & tv );
117+ else
118+ bufferevent_set_timeouts (sess -> bufev , NULL , NULL );
119+ }
120+
102121static void eventcb (struct bufferevent * bev , short events , void * ptr )
103122{
104123 struct cb_ctx * ctx = (struct cb_ctx * )ptr ;
@@ -125,6 +144,8 @@ static void eventcb(struct bufferevent *bev, short events, void *ptr)
125144 if (sess -> oob_cb ) {
126145 if (events & BEV_EVENT_CONNECTED ) {
127146 TACDEBUG (LOG_DEBUG , "session %p connected" , sess );
147+ /* change for setup timeout to read/write timeout values */
148+ tac_session_reset_timeouts (sess , true);
128149 (sess -> oob_cb )(sess , & sess -> context , CONNECTED );
129150 }
130151 if (events & BEV_EVENT_ERROR ) {
@@ -214,10 +235,13 @@ static void readcb(struct bufferevent *bev, void *ptr)
214235 /* copy out... */
215236 i = evbuffer_remove (evbuf , pkt , length );
216237
217- if (i < 0 || (unsigned ) i != n )
218- TACDEBUG (LOG_DEBUG , "%s: evbuffer_remove want %ld got %d" , __FUNCTION__ , n , i );
238+ if (i < 0 || (unsigned ) i != length )
239+ TACDEBUG (LOG_DEBUG , "%s: evbuffer_remove want %u got %d" , __FUNCTION__ , length , i );
219240
220- tac_parse_pkt (ctx -> sess , ctx , pkt , length );
241+ /* turn off timeouts */
242+ tac_session_reset_timeouts (sess , false);
243+
244+ tac_parse_pkt (sess , ctx , pkt , ((i > 0 ) ? i : 0 ));
221245
222246 free (pkt );
223247}
@@ -292,6 +316,9 @@ tac_authen_send_ev(struct tac_session *sess,
292316 /* generate the packet */
293317 tac_authen_send_pkt (sess , user , pass , tty , r_addr , action , & pkt , & pkt_total );
294318
319+ /* if reusing connection, reset timeouts */
320+ tac_session_reset_timeouts (sess , true);
321+
295322 /*
296323 * make evbuffer wrap around our packet, and call cleanup (free)
297324 * when done
@@ -328,6 +355,9 @@ tac_author_send_ev(struct tac_session *sess,
328355 /* generate the packet */
329356 tac_author_send_pkt (sess , user , tty , r_addr , attr , & pkt , & pkt_total );
330357
358+ /* if reusing connection, reset timeouts */
359+ tac_session_reset_timeouts (sess , true);
360+
331361 /*
332362 * make evbuffer wrap around our packet, and call cleanup (free)
333363 * when done
@@ -364,6 +394,9 @@ tac_acct_send_ev(struct tac_session *sess,
364394 /* generate the packet */
365395 tac_acct_send_pkt (sess , type , user , tty , r_addr , attr , & pkt , & pkt_total );
366396
397+ /* if reusing connection, reset timeouts */
398+ tac_session_reset_timeouts (sess , true);
399+
367400 /*
368401 * make evbuffer wrap around our packet, and call cleanup (free)
369402 * when done
@@ -397,6 +430,9 @@ tac_cont_send_ev(struct tac_session *sess, const char *pass) {
397430 /* generate the packet */
398431 tac_cont_send_pkt (sess , pass , & pkt , & pkt_total );
399432
433+ /* if reusing connection, reset timeouts */
434+ tac_session_reset_timeouts (sess , true);
435+
400436 /*
401437 * make evbuffer wrap around our packet, and call cleanup (free)
402438 * when done
0 commit comments