ext/revdispatch/libdispatch-0.1/src/ev_http.cc in evdispatch-0.2.4 vs ext/revdispatch/libdispatch-0.1/src/ev_http.cc in evdispatch-0.2.5
- old
+ new
@@ -18,32 +18,32 @@
static void multi_error_report(CURLMcode rc)
{
switch(rc) {
case CURLM_CALL_MULTI_PERFORM:
- printf("curlm:perform\n");
+ printf("curlm:perform: %s\n", curl_multi_strerror(rc) );
break;
case CURLM_OK:
// printf("curlm:ok\n");
break;
case CURLM_BAD_HANDLE:
- printf("curlm:bad handle\n");
+ printf("curlm:bad handle: %s\n", curl_multi_strerror(rc) );
break;
case CURLM_BAD_EASY_HANDLE:
- printf("curlm:bad easy handle\n");
+ printf("curlm:bad easy handle: %s\n", curl_multi_strerror(rc) );
break;
case CURLM_OUT_OF_MEMORY:
- printf("curlm:oh shit out of memory\n");
+ printf("curlm:oh shit out of memory: %s\n", curl_multi_strerror(rc) );
break;
case CURLM_INTERNAL_ERROR:
- printf("curlm:oh shit internal error\n");
+ printf("curlm:oh shit internal error: %s\n", curl_multi_strerror(rc) );
break;
case CURLM_BAD_SOCKET:
- printf("curlm:bad socket\n");
+ printf("curlm:bad socket: %s\n", curl_multi_strerror(rc) );
break;
case CURLM_UNKNOWN_OPTION:
- printf("curlm:unknown option\n");
+ printf("curlm:unknown option: %s\n", curl_multi_strerror(rc) );
break;
}
}
void HttpClient::SocketInfo::response_cb(struct ev_loop *loop, struct ev_io *w, int revents)
@@ -101,11 +101,11 @@
}
switch( action ){
case CURL_POLL_REMOVE: // (4) unregister
// make sure we clear it out
-// printf( " del sock: 0x%X\n", sockinfo );
+ //printf( " del sock: 0x%X\n", sockinfo );
curl_multi_assign(client->m_handle, sock, NULL);
sockinfo->finish();
delete sockinfo;
client->check_handles();
break;
@@ -159,13 +159,15 @@
ev_timer_stop( client->m_disp->get_loop(), &(client->m_timer) );
ev_timer_init( &(client->m_timer), timeout_cb, timeout, timeout );
ev_timer_start( client->m_disp->get_loop(), &(client->m_timer) );
}
else {
+ //printf( "start up http client timer\n" );
ev_timer_init( &(client->m_timer), timeout_cb, timeout, timeout );
client->m_timer.data = client;
ev_timer_start( client->m_disp->get_loop(), &(client->m_timer) );
+ client->m_timer_set = true;
}
return 0;
}
@@ -219,10 +221,18 @@
req->finish(rc);
delete req;
}
} while( easy );
+
+ if( msgs_left == 0 && m_timer_set ) {
+ // stop the event timer
+ //printf( "stop http client timer, no pending requests\n" );
+ ev_timer_stop( m_disp->get_loop(), &m_timer );
+ m_timer_set = false;
+ }
+
}
// CURLOPT_WRITEFUNCTION
size_t HttpRequest::write_cb(void *ptr, size_t size, size_t nmemb, void *data)
{
@@ -305,10 +315,11 @@
if( m_client ) {
do {
rc = curl_multi_socket_all( m_client->m_handle, &m_client->m_active );
} while( rc == CURLM_CALL_MULTI_PERFORM && m_client );
}
-
+ // XXX: it's really strange that m_client could be 0x0 all of a sudden here... but that's currently what must be happening
+ // in order for the final return code to be CURLM_CALL_MULTI_PERFORM.
if( m_client ) {
m_client->check_handles();
}
multi_error_report(rc);
return (rc == CURLM_OK || rc == CURLM_CALL_MULTI_PERFORM);