Changeset 4024
- Timestamp:
- Nov 30, 2007, 11:37:44 PM (14 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/torrent.c
r3970 r4024 171 171 tor->error = TR_ERROR_TC_ERROR; 172 172 strlcpy( tor->errorString, event->text, sizeof(tor->errorString) ); 173 tr_torrentStop( tor ); 173 174 break; 174 175 -
trunk/libtransmission/tracker.c
r4021 r4024 36 36 { 37 37 /* seconds between tracker pulses */ 38 PULSE_INTERVAL_MSEC = 750,38 PULSE_INTERVAL_MSEC = 1000, 39 39 40 40 /* maximum number of concurrent tracker socket connections */ … … 111 111 time_t reannounceAt; 112 112 time_t scrapeAt; 113 114 time_t resendRequestAt;115 int resendRequestType;116 113 117 114 unsigned int isRunning : 1; … … 216 213 publishMessage( tr_tracker * t, const char * msg, int type ) 217 214 { 218 tr_tracker_event event = emptyEvent; 219 event.hash = t->hash; 220 event.messageType = type; 221 event.text = msg; 222 tr_publisherPublish( t->publisher, t, &event ); 215 if( t != NULL ) 216 { 217 tr_tracker_event event = emptyEvent; 218 event.hash = t->hash; 219 event.messageType = type; 220 event.text = msg; 221 tr_publisherPublish( t->publisher, t, &event ); 222 } 223 223 } 224 224 … … 230 230 231 231 static void 232 publishErrorMessage( tr_tracker * t, const char * msg ) 233 { 232 publishErrorMessageAndStop( tr_tracker * t, const char * msg ) 233 { 234 t->isRunning = 0; 234 235 publishMessage( t, msg, TR_TRACKER_ERROR ); 235 236 } … … 412 413 if(( tmp = tr_bencDictFind( &benc, "failure reason" ))) { 413 414 dbgmsg( t, "got failure message [%s]", tmp->val.s.s ); 414 publishErrorMessage ( t, tmp->val.s.s );415 publishErrorMessageAndStop( t, tmp->val.s.s ); 415 416 } 416 417 … … 497 498 else if( 400<=responseCode && responseCode<=499 ) 498 499 { 499 dbgmsg( t, "got a 4xx error." ); 500 const char * err = req && req->response_code_line 501 ? req->response_code_line 502 : "Unspecified 4xx error from tracker."; 503 dbgmsg( t, err ); 500 504 501 505 /* The request could not be understood by the server due to 502 506 * malformed syntax. The client SHOULD NOT repeat the 503 507 * request without modifications. */ 504 if( req && req->response_code_line ) 505 publishErrorMessage( t, req->response_code_line ); 508 publishErrorMessageAndStop( t, err ); 506 509 t->manualAnnounceAllowedAt = ~(time_t)0; 507 510 t->reannounceAt = 0; … … 526 529 /* WTF did we get?? */ 527 530 if( req && req->response_code_line ) 528 publish ErrorMessage( t, req->response_code_line );531 publishWarning( t, req->response_code_line ); 529 532 t->manualAnnounceAllowedAt = ~(time_t)0; 530 533 t->reannounceAt = time(NULL) + 60; … … 539 542 tr_tracker * t = findTrackerFromHash( vhash ); 540 543 541 dbgmsg( t, "Got scrape response for '%s': %s ", (t ? t->name : "(null)"), (req ? req->response_code_line : "(no line)") );544 dbgmsg( t, "Got scrape response for '%s': %s (%d)", (t ? t->name : "(null)"), (req ? req->response_code_line : "(no line)"), (req ? req->response_code : -1) ); 542 545 543 546 tr_free( vhash ); … … 825 828 --handle->tracker->socketCount; 826 829 dbgmsg( NULL, "decrementing socket count to %d", handle->tracker->socketCount ); 830 pulse( handle ); 827 831 } 828 832 … … 835 839 } 836 840 837 static int841 static void 838 842 invokeRequest( tr_handle * handle, const struct tr_tracker_request * req ) 839 843 { 840 int err;841 844 struct evhttp_connection * evcon = getConnection( handle, req->address, req->port ); 842 dbgmsg( NULL, "sending '%s' to tracker %s:%d, timeout is %d", req->uri, req->address, req->port, (int)req->timeout ); 845 tr_tracker * t = findTracker( handle, req->torrent_hash ); 846 dbgmsg( t, "sending '%s' to tracker %s:%d, timeout is %d", req->uri, req->address, req->port, (int)req->timeout ); 843 847 evhttp_connection_set_timeout( evcon, req->timeout ); 844 err = evhttp_make_request( evcon, req->req, EVHTTP_REQ_GET, req->uri ); 845 if( !err ) { 848 if( evhttp_make_request( evcon, req->req, EVHTTP_REQ_GET, req->uri )) 849 publishErrorMessageAndStop( t, "Tracker could not be reached." ); 850 else { 846 851 ++handle->tracker->socketCount; 847 dbgmsg( NULL, "incremented socket count to %d", handle->tracker->socketCount ); 848 } 849 return err; 852 dbgmsg( t, "incremented socket count to %d", handle->tracker->socketCount ); 853 } 850 854 } 851 855 … … 854 858 { 855 859 struct tr_tracker_request * req = tr_list_pop_front( list ); 856 const int err = invokeRequest( handle, req ); 857 858 if( err ) 859 { 860 tr_tracker * t = findTracker( handle, req->torrent_hash ); 861 if( t != NULL ) 862 { 863 if( req->reqtype == TR_REQ_SCRAPE ) { 864 t->scrapeAt = time(NULL) + 30; 865 dbgmsg( t, "scrape failed... retrying in 30 seconds" ); 866 } 867 else { 868 dbgmsg( t, "request [%s] failed... retrying in 30 seconds", req->uri ); 869 t->resendRequestAt = time(NULL) + 30; 870 t->resendRequestType = req->reqtype; 871 } 872 } 873 } 874 860 invokeRequest( handle, req ); 875 861 freeRequest( req ); 876 862 } … … 902 888 } 903 889 904 /**905 * This function is called when there's been an error invoking a request,906 * or when the tracker has returned back a server error that might require907 * the request to be re-sent.908 */909 static void910 maybeRequeueRequest( tr_handle * handle, const tr_tracker * tracker, int reqtype )911 {912 /* FIXME */913 enqueueRequest( handle, tracker, reqtype );914 }915 916 890 static int 917 891 pulse( void * vhandle ) … … 929 903 { 930 904 tr_tracker * t = tor->tracker; 931 932 if( t->resendRequestAt && ( now >= t->resendRequestAt ) ) {933 t->resendRequestAt = 0;934 maybeRequeueRequest( handle, t, t->resendRequestType );935 }936 905 937 906 if( t->scrapeAt && trackerSupportsScrape( t ) && ( now >= t->scrapeAt ) ) {
Note: See TracChangeset
for help on using the changeset viewer.