Changeset 9754
- Timestamp:
- Dec 14, 2009, 2:25:22 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/web.c
r9750 r9754 26 26 DEFAULT_TIMER_MSEC = 1500 /* arbitrary */ 27 27 }; 28 29 static tr_bool tr_multi_perform( tr_web * g, int fd );30 28 31 29 #if 0 … … 46 44 { 47 45 tr_bool closing; 46 tr_bool haveAddr; 48 47 int taskCount; 49 48 long timer_msec; 50 49 CURLM * multi; 51 50 tr_session * session; 52 tr_bool haveAddr;53 51 tr_address addr; 54 52 struct event timer_event; … … 56 54 57 55 static void 58 web_ close( tr_web * g )56 web_free( tr_web * g ) 59 57 { 60 58 curl_multi_cleanup( g->multi ); … … 194 192 mcode = curl_multi_add_handle( web->multi, e ); 195 193 ++web->taskCount; 196 /*tr_multi_perform( web, CURL_SOCKET_TIMEOUT );*/197 194 } 198 195 } … … 244 241 } 245 242 246 static tr_bool243 static void 247 244 tr_multi_perform( tr_web * g, int fd ) 248 245 { 249 246 CURLMcode mcode; 250 tr_bool closed = FALSE;251 247 252 248 dbgmsg( "check_run_count: %d taskCount", g->taskCount ); 253 249 254 250 /* invoke libcurl's processing */ 255 do {251 do 256 252 mcode = curl_multi_socket_action( g->multi, fd, 0, &g->taskCount ); 257 }while( mcode == CURLM_CALL_MULTI_SOCKET );253 while( mcode == CURLM_CALL_MULTI_SOCKET ); 258 254 259 255 remove_finished_tasks( g ); 260 256 261 if( ( closed = g->closing && !g->taskCount ))262 web_ close( g );257 if( g->closing && !g->taskCount ) 258 web_free( g ); 263 259 else 264 260 restart_timer( g ); 265 266 return closed;267 261 } 268 262 … … 276 270 /* CURLMOPT_SOCKETFUNCTION */ 277 271 static int 278 sock_cb( CURL * e asyUNUSED, curl_socket_t fd, int action,272 sock_cb( CURL * e UNUSED, curl_socket_t fd, int action, 279 273 void * vweb, void * vevent ) 280 274 { … … 282 276 struct tr_web * web = vweb; 283 277 struct event * io_event = vevent; 284 dbgmsg( "sock_cb: action is %d, fd is %d, io_event is %p", 285 action, (int)fd, io_event ); 278 dbgmsg( "sock_cb: action %d, fd %d, io_event %p", action, (int)fd, io_event ); 286 279 287 280 if( action == CURL_POLL_REMOVE ) … … 334 327 { 335 328 tr_web * g = vg; 336 tr_bool closed = FALSE; 337 338 if( timer_msec < 1 ) { 339 if( timer_msec == 0 ) /* call it immediately */ 340 closed = tr_multi_perform( g, CURL_SOCKET_TIMEOUT ); 341 timer_msec = DEFAULT_TIMER_MSEC; 342 } 343 344 if( !closed ) { 345 g->timer_msec = timer_msec; 346 restart_timer( g ); 347 } 329 330 g->timer_msec = timer_msec > 0 ? timer_msec : DEFAULT_TIMER_MSEC; 331 332 if( timer_msec < 1 ) 333 tr_multi_perform( g, CURL_SOCKET_TIMEOUT ); 348 334 } 349 335 … … 370 356 task->tag = ++tag; 371 357 task->response = evbuffer_new( ); 372 373 358 tr_runInEventThread( session, addTask, task ); 374 359 } … … 412 397 *web_in = NULL; 413 398 if( web->taskCount < 1 ) 414 web_ close( web );399 web_free( web ); 415 400 else 416 401 web->closing = 1; … … 473 458 474 459 void 475 tr_http_escape( struct evbuffer * out, const char * str, int len, tr_bool escape_slashes ) 460 tr_http_escape( struct evbuffer * out, 461 const char * str, int len, tr_bool escape_slashes ) 476 462 { 477 463 int i;
Note: See TracChangeset
for help on using the changeset viewer.